I want to start my program on Linux on the development board. I thought it was simple, but it had been changed for a long time. It was really easy to go around. It was just that I was too peat at the beginning!
If you do not want to read the full text, this section should be enough. From the perspective of the development board I use, it is generally only required in/etc/init. d. Add your program or script command to the RC To Enable Automatic startup. If you want to press enter on the Super Terminal and run the command after logon, you can add the command to/etc/profile; if you want to remove the phrase "Please press enter to activate this console" after each boot, that is, Enable Automatic Logon upon startup, you can write the following code in/etc/inittab as the inittab of example in busybox, but change: askfirst:-/bin/sh to: respawn:-/bin/sh, if no inittab is found, create one by yourself (this is my cup !!!!). Other boards can modify the script according to their own situation, which is not much different.
Next I will go to the topic to discuss my understanding. The file system on the mini2440 board is root_qtopia. Refer to Article 1. Because the default kernel command line contains init =/linuxrc, after the file system is mounted, the first program to run is linuxrc in the root directory. This is a link to/bin/busybox. That is to say, the first program running after the system is started is busybox itself. In this case, busybox first tries to parse/etc/inittab to obtain further Initialization Configuration Information (refer to the parse_inittab () function in busybox source code init/init. C ). In fact, root_qtopia does not have the/etc/inittab configuration file. According to the busybox logic, it will generate the default configuration.
. Therefore, if necessary, you can add the/etc/inittab configuration file by yourself, and perform a slight modification to busybox by default to meet your requirements.
The initialization script is/etc/init. d/RCS.
#! /Bin/sh
PATH =/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:
Runlevel = S
Prevlevel = N
Umask 022
Export PATH runlevel prevlevel
#
# Trap CTRL-C & c only in this shell so we can interrupt subprocesses.
#
Trap ":" INT QUIT TSTP
/Bin/hostname FriendlyARM
/Bin/mount-n-t proc none/proc
/Bin/mount-n-t sysfs none/sys
/Bin/mount-n-t usbfs none/proc/bus/usb
/Bin/mount-t ramfs none/dev
Echo/sbin/mdev>/proc/sys/kernel/hotplug
/Sbin/mdev-s
/Bin/hotplug
# Mounting file system specified in/etc/fstab
Mkdir-p/dev/pts
Mkdir-p/dev/shm
/Bin/mount-n-t devpts none/dev/pts-o mode = 0622
/Bin/mount-n-t tmpfs/dev/shm
/Bin/mount-n-t ramfs none/tmp
/Bin/mount-n-t ramfs none/var
Mkdir-p/var/empty
Mkdir-p/var/log
Mkdir-p/var/lock
Mkdir-p/var/run
Mkdir-p/var/tmp
/Sbin/hwclock-s
Syslogd
/Etc/rc. d/init. d/netd start
Echo "">/dev/tty1
Echo "Starting networking...">/dev/tty1
Sleep 1
/Etc/rc. d/init. d/httpd start
Echo "">/dev/tty1
Echo "Starting web server...">/dev/tty1
Sleep 1
/Etc/rc. d/init. d/leds start
Echo "">/dev/tty1
Echo "Starting leds service...">/dev/tty1
Echo ""
Sleep 1
/Sbin/ifconfig lo 127.0.0.1
/Etc/init. d/ifconfig-eth0
/Bin/qtopia &
Echo "">/dev/tty1
Echo "Starting Qtopia, please waiting...">/dev/tty1
You can see what operations are performed and finally load qtopia. Refer to article 1 for a thorough explanation. I want to add some programs that need to be added and executed in the background after the startup, such as loading qtopia, but what do we do if we want to display the log file or the information that our application writes to the file in real time after the startup? First, use>/dev/tty1 to redirect the output to tty1 (display screen), and tail-f command, but there are still many problems after some attempts, at this time, you can try to put the program started on your own into/etc/profile as a program that must be executed by this user upon login, the result is the same as that after a command is input in a Super Terminal.
After learning about the Automatic startup settings, you can use busybox to create your own file system. You can refer to the article to complete the file system yourself.
This article from the Linux community website (www.linuxidc.com) original link: http://www.linuxidc.com/Linux/2011-05/36109.htm