Difference between revisions of "Automatically launch your application"

From ArmadeusWiki
Jump to: navigation, search
(System startup)
Line 3: Line 3:
 
==System startup==
 
==System startup==
 
First, a small remainder: when you start your board, here is how all things are started:
 
First, a small remainder: when you start your board, here is how all things are started:
# U-Boot initializes the system and load Linux
+
# U-Boot initializes the processor, vital peripherals and then load Linux image from Flash,
# Linux mounts its rootfs and launches ''/sbin/init''
+
# U-Boot starts Linux image by passing it some parameters, the ''bootargs'',
# ''init'' process checks its ''/etc/inittab'' config file and executes the instructions it contains
+
# Linux starts, mounts its rootfs and launches ''/sbin/init'',
# this config files generally asks ''init'' to launch ''/etc/init.d/rcS''
+
# ''init'' process checks its ''/etc/inittab'' config file and executes the instructions it contains,
# ''/etc/init.d/rcS'' gets all scripts in ''/etc/init.d/'' directory which start with a '''S''', and executes them in ascending order
+
# this config file generally asks ''init'' to launch ''/etc/init.d/rcS'' at some point,
 +
# ''/etc/init.d/rcS'' look at 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==
 
==Adding your own application in the start process==

Revision as of 15:50, 17 April 2013

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 processor, vital peripherals and then load Linux image from Flash,
  2. U-Boot starts Linux image by passing it some parameters, the bootargs,
  3. Linux starts, mounts its rootfs and launches /sbin/init,
  4. init process checks its /etc/inittab config file and executes the instructions it contains,
  5. this config file generally asks init to launch /etc/init.d/rcS at some point,
  6. /etc/init.d/rcS look at 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