Compilation and running of Linux-C test program based on iTOP-4412 development board
[Copy link]
The iTOP-4412 development board can run many file systems. Before implementing specific functions on a specific file system, you can
use Linux-C programs to test the hardware and drivers. Moreover, these programs can be easily ported to Android, Qt/E, and
the minimum file system.
Special reminder: Linux-C programs are cross-platform. As long as you compile according to the method described below, you can
run Linux-C programs and Android systems together, and use Linux-C programs to test the content we are concerned about. In essence, we
can understand that Android is just a large file. Taking the first helloworld below as an example,
two programs "helloworld" + "Android" are running on the Linux kernel.
The Linux-C test program source code and executable program are in the network disk directory "iTOP4412 development board data summary (excluding CD
content)\iTOP-4412 development board system source code and image (others)\small module test program".
8.1 Compiling and running the test program
8.1.1 Setting the compilation environment
The C program application runs on Android, and the compiler used is gcc4.4.1. For the installation method of the compiler, refer to
Chapter 5.
Modify the environment variables as shown in the figure below.
(, downloads: 0)
After the modification, update the environment variables, as shown below
(, downloads: 0)
As shown in the figure below, enter "arm" and press the "TAB" key, and the compiler "arm-
none-linux-gnueabi-gcc-4.4.1" that will be used later will be displayed.
(, downloads: 0)
8.1.2 Compile the helloworld
program The source code of helloworld.c is as follows.
(, downloads: 0)
To compile the helloworld program, enter the command "arm-none-linux-gnueabi-gcc-4.4.1 -o helloworld
helloworld.c -static", as shown in the following figure.
(, downloads: 0)
As shown below, the executable file helloworld is generated.
(, downloads: 0)
8.1.3 Upload helloworld to the development board
The development board runs the factory-installed Android 4.0.3 system. Connect the serial console, start the development board, and
connect the OTG cable after Android is running.
Copy the executable file helloworld to the fastboot flashing directory, as shown in the figure below. This directory is
where the fastboot tool is located. For how to use the fastboot tool, refer to Section 3.6.
(, downloads: 0)
After the Android system of the development board runs stably, connect the OTG interface to the USB of the computer and open
the "cmd.exe" in the "USB_fastboot_tool\platform-tools" directory, as shown in the figure below.
(, downloads: 0)
As shown in the figure below, enter the command "adb push helloworld /data" to upload the program to
the "/data" directory of the development board.
(, downloads: 0)
Of course, you can also upload the executable file helloworld through the mobile assistant, TF card or USB flash drive.
8.1.4 Modify program permissions and run helloworld
As shown in the figure below, in the hyperterminal, enter "cd /data" to enter the "/data" directory, use "chmod 777 helloworld" to modify permissions, and finally enter the command "./helloworld" to run the program.
"Hello world!"
will be printed in the hyperterminal , indicating that the program runs successfully.
(, downloads: 0)
In addition to modifying permissions and running programs through the console, you can also modify permissions and run programs through the adb console. As
shown in the figure below, after uploading the helloworld program, use the command "adb shell" to open the adb command line (for more adb
commands, refer to Section 3.6.4), use "cd /data" to enter the helloworld program upload directory "/data", use the command
"chmod 777 helloworld" to modify permissions, and then use "./helloworld" to run the helloworld executable
program. You can see that the adb console prints "Hello World!".
(, downloads: 0)
The following tests can use the serial console to run the program, or use the adb command to run the program.
|