5 Replies Latest reply on Oct 8, 2014 2:32 PM by mhahn

    Wirelessly program Edison

    sl3

      Does anyone have an existing script that compiles an Arduino sketch and wirelessly transfers the binary to the Edison? We're using the Edison as a wearable device and so it'd greatly improve our workflow if we could program it without having to attach it to the breakout board every time.

        • 1. Re: Wirelessly program Edison
          Intel_Alvarado

          Hi sl3,


          Currently, we don’t have an existing script that wirelessly programs the Edison.


          Regards

          Sergio

          • 2. Re: Wirelessly program Edison
            sl3

            I managed to get something working if anyone's interested. It only works on Linux and Mac, someone should be able to do something similar for Windows.


            To get this to work, modify the upload script in the Arduino folder. For Mac OS X, the location is: <Arduino Application>/Contents/Resources/Java/hardware/arduino/edison/tools/izmir/clupload_osx.sh


            (Make sure to change the $HOST variable below to the IP of your device.)

             

            #!/bin/sh

             

            set -e

             

            HOST=192.168.1.29  # CHANGE THIS TO YOUR DEVICE'S IP

            SKETCH=/sketch/sketch.elf

            OLD_SKETCH=/sketch/sketch.elf.old

            TMP_DIR=/home/root/tmp

            TMP_SKETCH=$TMP_DIR/sketch.elf

            TMUX=/home/root/bin/tmux

             

            ssh root@$HOST "mv -f $SKETCH $OLD_SKETCH"

            scp $2 root@$HOST:$SKETCH

            ssh root@$HOST "chmod +x $SKETCH"

            ssh root@$HOST "killall -q -USR1 launcher.sh || true"

            ssh root@$HOST "killall -q clloader || true"

            ssh root@$HOST "killall -q sketch.elf || true"

            ssh root@$HOST "$SKETCH /dev/pts/0 > /dev/null 2>&1"

             

            echo "Success"

             

            It's a little hacky, but if you SSH into the device before you upload the sketch, the sketch will output its Serial.print statements to the terminal. It's probably a bug, but it's a happy accident for me.

            • 3. Re: Wirelessly program Edison
              mhahn

              You could try modifying clloader - sources are in Intel® Download Center. If you stay with the clloader I'd recommend to use "systemctl stop clloader"

              rather than "killall clloader"  - which should also automatically stop execution of launcher.sh and sketch.elf.

              Rather than starting the sketch manually you could start it with clloader again. I.E:

               

              systemctl stop clloader #stops sketch.elf, launcher.sh, and clloader

              # wait until all 3 have been stopped (e.g. check PIDs)

              # rather than several ssh / scp calls you could also fuser mount Edison via sshfs and just copy over there

              ssh root@$HOST "mv -f $SKETCH $OLD_SKETCH"

              scp $2 root@$HOST:$SKETCH # alternatively rsync over ssh

              systemctl start clloader #starts the new sketch for you

              • 4. Re: Wirelessly program Edison
                sl3

                Thanks, @mhahn. systemctl is much cleaner. Here's an updated version of the script:

                 

                hardware/arduino/edison/tools/izmir/clupload_osx.sh

                #!/bin/sh

                 

                set -e

                 

                HOST=192.168.42.1

                SKETCH=/sketch/sketch.elf

                OLD_SKETCH=/sketch/sketch.elf.old

                 

                ssh root@$HOST "mv -f $SKETCH $OLD_SKETCH"

                scp $2 root@$HOST:$SKETCH

                ssh root@$HOST "chmod +x $SKETCH"

                ssh root@$HOST "systemctl restart clloader"

                 

                echo "Success"

                • 5. Re: Wirelessly program Edison
                  mhahn

                  using "scp -p" would preserve the permissions or better with rsync you can specify "--chmod" in the command; so you could save one more loc (and save one ssh connection)