Automatically launch your application: Difference between revisions

From ArmadeusWiki
(creation)
 
Line 9: Line 9:
# ''/etc/init.d/rcS'' gets all scripts in ''/etc/init.d/'' directory which start with a '''S''', and executes them in ascending order
# ''/etc/init.d/rcS'' gets all scripts in ''/etc/init.d/'' directory which start with a '''S''', and executes them in ascending order


==Adding your own app in the start process==
==Adding your own application in the start process==
* creates a shell script in ''/etc/init.d/'':
* creates a shell script in ''/etc/init.d/'':
<pre class="apf">
<pre class="apf">
Line 24: Line 24:
#!/bin/sh
#!/bin/sh


/usr/bin/your_app &
# Loading the modules needed by my app:
modprobe xxxxx
# Launching my app:
/usr/bin/your_app &         # <-- Don't forget the "&" otherwise other system stuff won't start until you leave your app !!!


exit 0
exit 0
</source>
</source>
* save your changes and that's it !
* save your changes and '''!! Test it !!'''
<pre class="apf">
# /etc/init.d/S99app
</pre>
 
* That's it ! You can now reboot:
<pre class="apf">
# sync
# reboot
</pre>


==Links==
==Links==
* [[Linux_Boot_Logo| How to customize your boot Logo]]
* [[Linux_Boot_Logo| How to customize your boot Logo]]

Revision as of 12:04, 22 February 2011

You've just developed a state of the art application and want it to be launched each time you boot your APF ? Then this small tutorial is for you !

System startup

First, a small remainder: when you start your board, here is how all things are started:

  1. U-Boot initializes the system and load Linux
  2. Linux mounts its rootfs and launches /sbin/init
  3. init process checks its /etc/inittab config file and executes the instructions it contains
  4. this config files generally asks init to launch /etc/init.d/rcS
  5. /etc/init.d/rcS gets all scripts in /etc/init.d/ directory which start with a S, and executes them in ascending order

Adding your own application in the start process

  • creates a shell script in /etc/init.d/:
 # touch /etc/init.d/S99app
 # chmod a+x /etc/init.d/S99app
  • edit it
 # vi /etc/init.d/S99app
  • put in it the following content (replace /usr/bin/your_app with your application name & path):
#!/bin/sh

# Loading the modules needed by my app:
modprobe xxxxx
 
# Launching my app:
/usr/bin/your_app &          # <-- Don't forget the "&" otherwise other system stuff won't start until you leave your app !!!

exit 0
  • save your changes and !! Test it !!
# /etc/init.d/S99app
  • That's it ! You can now reboot:
# sync
# reboot

Links