1 2 Previous Next 18 Replies Latest reply on Jan 17, 2017 2:49 PM by Bill.

    Run Arduino sketch on boot Workaround

    AliDouiyek

      Hi,

      We all know that the latest image release doesn't not run the arduino sketch once we reboot the board, here's how I managed to fix it:

       

      Basically we're going to flash the board to a previous version to get some files, and then reflash to the latest version and copy those files inside.

      Make sure you save whatever files you need before flashing the board, as it will delete everything that is on it.

       

      1. Flash your board with image 146  (ww18-15) using Flashtool Lite
      2. Boot the board and upload any arduino sketch on it.
      3. Connect to the board using serial or SSH
      4. Copy the following files to a SD card or thumbdrive:
        1. /opt/edison/launcher.sh
          /opt/edison/clloader
          /opt/edison/sketch_reset

          /opt/edison/sketch_reset.sh

        2. if you cant copy, kill the process that has the same name as the file by using kill -9
      5. Flash your board with image 159 (ww25-15)  using Flashtool Lite
      6. Connect to the board using serial or SSH
      7. Copy the 4 files from your sd card to their respective folders (again if you cant copy, use kill -9)
      8. make sure the module responsible for launching the sketch is enabled by running the following commands:
        1. systemctl enable clloader
        2. systemctl start clloader
      9. You can now upload a sketch and reboot the board.

       

       

      Hope this will help.

      Ali.

        • 1. Re: Run Arduino sketch on boot Workaround
          droziers

          Thx Ali,

           

          I just tried this workaround myself and got it working. There's however one small additional piece of info I'd add to your list of steps, namely between step 7 and 8 I'd add that one has to make sure that the files copied to the opt/edison directory on the Edison have execution rights. When I first tried this workaround the clloader file that I copied over did not have execution rights and as a result was not started after the "systemctl start clloader" command and as a result wasn't started after a reboot and as a result my latest uploaded Arduino sketch did not run after a reboot. However, a simple "chmod + x clloader" between step 7 and 8 solved that problem.

           

          Just mentioning it here because other people might run into the same issue and struggle finding out what's wrong, thinking that the above workaround does not work, whereas your workaround as described above does work fine if you keep my remark here above in mind.

           

          Thx again Ali

           

          dirk

          • 2. Re: Run Arduino sketch on boot Workaround
            coloradocarlos

            If you are on Ubuntu, you can mount the downloaded image file and copy the files without reflashing the Edison:

             

            unzip -d edison edison-image-ww18-15.zip

            cd edison

            sudo losetup /dev/loop0 edison-image-edison.ext4

            sudo mount -o ro /dev/loop0 /mnt

            cd /mnt/opt/edison

             

            Then copy the files from /mnt/opt/edison using scp. When done, umount and remove loopback:

             

            sudo umount /mnt

            sudo losetup -d /dev/loop0

             

            I found for the sketch to start after a reboot the USB device cable needed to be disconnected.

            • 3. Re: Run Arduino sketch on boot Workaround
              chewcheik

              Hi AliDouiyek,

               

              May I ask how to copy the file using PuTTy?

              root.JPG

              I not yet flash the 146  (ww18-15)   version but I just want to try how to copy the file and paste the file back into.

              I have tried to use WinSCP but sadly I cannot login with this software.

               

              Thank you and have a nice day.

              • 4. Re: Run Arduino sketch on boot Workaround
                Kerney

                Thanks for working out the solution. "Regression tests?" I hear you say.

                I just did this and I uploaded files to DB. https://dl.dropboxusercontent.com/u/13635196/clloader.zip

                • 5. Re: Run Arduino sketch on boot Workaround
                  InPark

                  I trid to the solution. But I have some problems. How can I fix it? There are some errors.

                  I

                   

                  root@edison:~# systemctl status clloader -l
                  ● clloader.service - Daemon to handle arduino sketches
                     Loaded: loaded (/lib/systemd/system/clloader.service; enabled)
                     Active: failed (Result: exit-code) since Tue 2016-01-12 05:52:37 UTC; 1min 35s ago
                    Process: 189 ExecStart=/opt/edison/launcher.sh (code=exited, status=203/EXEC)
                  Main PID: 189 (code=exited, status=203/EXEC)

                  Jan 12 05:52:36 edison systemd[1]: Started Daemon to handle arduino sketches.
                  Jan 12 05:52:37 edison systemd[1]: clloader.service: main process exited, code=exited, status=203/EXEC
                  Jan 12 05:52:37 edison systemd[1]: Unit clloader.service entered failed state.

                   

                   

                  root@edison:~# ls -l /opt/edison

                  -rwxr-xr-x    1 root     root         48676 Mar 31  2015 clloader

                  -rwxr-xr-x    1 root     root           360 Jan  8 07:24 launcher.sh

                  -rwxr-xr-x    1 root     root          5896 Mar 31  2015 sketch_reset

                  -rwxr-xr-x    1 root     root            58 Mar 31  2015 sketch_reset.sh

                   

                   

                  I can't upload sketch on Arduino IDE.

                  • 6. Re: Run Arduino sketch on boot Workaround
                    janunezc

                    To use winscp you have to run a full configure_edison --setup cycle, so that you give it a password, connect it to a WiFi and give it a name.

                    • 7. Re: Run Arduino sketch on boot Workaround
                      janunezc

                      The procedure did not work for us in our Edison.

                       

                      I also added the chmod command to the procedure, but it just doesnt load a sketch from the IDE to the Edison.

                       

                      Is there a scheduled version of the image that will fix this permanently?

                      • 8. Re: Run Arduino sketch on boot Workaround
                        Jonathan Guevara

                        It works for me, I just had the caution to delete de clloader file before copy the new one.

                        • 9. Re: Run Arduino sketch on boot Workaround
                          V1N0

                          Same issue for me, it IDE won't upload the sketch to the Edison, stuck in uploading.

                          There is also:

                          https://software.intel.com/en-us/blogs/2015/08/01/procedure-to-autostart-the-arduino-sketch-on-edison-0

                          Which works, but the sketch crashes after 5 minutes.

                          Maybe there are run options that are missing from the exec command in that solution that casue it to crash.

                          But so far the only thing that fully works for me is to stay in 146..

                          • 10. Re: Run Arduino sketch on boot Workaround
                            Jeanfranco

                            It may be a little late, but I cannot find the edison folder in my opt folder. There is only the intel folder, and the only thing there is edison_image and other files, I cannot find the files specified.

                            • 11. Re: Run Arduino sketch on boot Workaround
                              Ozmo

                              Hi - does anyone know if there is an official fix for this issue yet?

                               

                              I am looking for a way that the Edison wont loose all its Arduino code after a reboot or a switch of the USB mode switch.

                               

                              I tried the latest firmware (iot-devkit-prof-dev-image-edison-20160315) - but unless im doing something wrong, its still not keeping its Arduino code.

                               

                              Is the only fix to go back to 146 ... ?

                               

                              Thanks...A.

                              • 12. Re: Run Arduino sketch on boot Workaround
                                Lane_Lee

                                I don't think so. I just flashed the latest image named by 'iot-devkit-prof-dev-image-edison-20160315.zip' , still the same issue.


                                And also I tried this thread afterwards Procedure to Autostart the Arduino Sketch on Edison | Intel® Developer Zone, Which works, but the sketch crashes after 5 minutes.


                                So I have to flash back again.

                                • 13. Re: Run Arduino sketch on boot Workaround
                                  IoT_srinivas

                                  Hi ,

                                   

                                  Thank for update. I tried this steps. after this Arduino sketch is not working without reboot also.

                                   

                                  Regs,

                                  Sree

                                  • 14. Re: Run Arduino sketch on boot Workaround
                                    sanyaade

                                    @

                                     

                                    If you chmod of the sketch.elf then you may not be able to overwrite it with a new sketch.

                                     

                                    The problem most people are having is that:

                                    1.) Edison saves you sketch by default as sketch.elf so it not use the original file name. May this was a deliberate feature to avoid spaces in file name to could cause a lot of

                                    problems in MCU platform.

                                    2.) If you upload a new sketch or overwrite the old one then you will to again chmod +x to turn the newly upload into executable and run updaterc command for it to work.

                                     

                                    @V1N0: @Lee_Lane:  After 5 minutes it crashes

                                    This has nothing to do with the auto-start script during boot sequence but it may be due to problems in your script which you may need to debug. This could be I/O problems in most cases.

                                     

                                    Generally, I normally rename my sketches e.g. mv sketch.elf  xxxxxxx.elf  since I want to keep them for my incremental coding/debugging sessions. I think you may customise the IDE to prompt you for a name (save..... as) but to reject spaces in filename during upload need to check this further

                                     

                                    I will see if I could produce a guide soon (workload, workload...)

                                     

                                    God blesses!!!

                                     

                                    Best regards,
                                    Sanyaade

                                    1 2 Previous Next