Get access to the new Intel® IoT Developer Kit, a complete hardware and software solution that allows developers to create exciting new solutions with the Intel® Galileo and Intel® Edison boards. Visit the Intel® Developer Zone for IoT.
Running Arduino sketch at System Start-Up
There are many ways to do this, but on Edison I found that the easiest way is using the /etc/init.d directory. There are many references out there for why and how this works, a good one can be found here. If this is your first time using init.d for start-up scripts, you’re going to have to first create the directory else skip to Step 2:
Step 1
root@edison:~# mkdir /etc/init.d
Now lets switch into that directory,
Step 2
root@edison:~# cd /etc/init.d
Next, we’re going to create a bash script in this folder that contains our boot commands. In this case, we’re automating the Arduino sketch to run at startup.
In any case, open your favorite text editor and create the script automateSketch.sh:
root@edison:/etc/init.d# vi automateSketch.sh
Add the following contents into the script.
exec /sketch/sketch.elf /dev/ttyGS0 /dev/ttyGS0
Really, it’s just the two commands and we landed on at the end of our tutorial.
Now we can make the script executable by changing the permissions with chmod.
root@edison:/etc/init.d# chmod +x /etc/init.d/automateSketch.sh
root@edison:/etc/init.d# chmod +x automateSketch.sh
Now, to make sure this script is executed every time linux boots, issue the following command and wait for the return shown below
root@edison:/etc/init.d# update-rc.d automateSketch.sh defaults
Adding system startup for /etc/init.d/automateSketch.sh
Well!!, We are done! we can see if it Worked!
root@edison:/etc# reboot
Now you can see if the Arduino sketch auto starts.