How to Automatically Run a Specific Program After Booting ARM Linux

The command for system services is saved in the /usr/etc/rc.local file of the development board’s root filesystem. Some development boards need to hold down ctrl+c to enter the Linux SHELL prompt after booting to automatically run graphical interface programs. In fact, you can achieve the goal of automatically running user applications at boot by commenting out the commands that call the graphical interface in the rc.local file and adding commands to run user applications.

Below, I will describe the specific implementation steps using an experiment I conducted. This method is sourced from the internet, which I verified and slightly modified, and this article serves as a reprint.

1. Enter the Linux operating system on the PC, create a folder named lz in /nfs/usr/ using the mkdir lz command, and enter the lz folder. Create a hello folder using mkdir hello to store the hello.c file we will write and the compiled executable file.

2. In /nfs/usr/lz/hello, create the hello.c file using the command vi hello.c and edit the following test program:

#include <stdio.h>
int main() {
    printf("Hello, test arm-linux!\n");
    return 0;
}</stdio.h>

After editing, save and exit using :wq.

3. The host compiles hello.c using the following command in the cross-compilation environment:

# arm-linux-gcc -o hello hello.c

4. By using the ls command, you can see that the hello executable file has been generated in /nfs/usr/lz/hello/. We can test the execution of our hello.c on the development board using ./hello.

5. Modify the rc.local file by commenting out the commands that start the graphical interface at the end of the file using ‘#’, and add the command to execute the user application hello. The specific implementation is as follows:

# export PATH=$QPEDIR/bin:$PATH
# qtopia
# /usr/qtopia/bin/qtopia
/usr/lz/hello/./hello

Note: The first three lines are comments to disable starting the graphical interface, and the last line is the command added to execute the hello test program.

6. Restart the development board and configure it using the vivi parameters to mount the host’s filesystem via nfs. At this point, we can see through the super terminal that the development board is running the hello program we wrote.

Leave a Comment