Compile and run the Linux-c test program based on the 4418 development board
[Copy link]
Linux-c test program based on iTOP4418 development board
The iTOP-4418 development board can run many file systems. Before implementing specific functions on a specific file system, you can
use Linux-c programs to test hardware and drivers. Moreover, these programs are easily ported to Android, Qt/E and the smallest
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 test code is in the network disk directory "iTOP4418 development board information summary (excluding CD content)\07_iTOP-4418 development board
Android application development environment software and source code\04_linux-C test program".
8.1 Compile and run the test program
8.1.1 Set up 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 in the figure 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)
Compile the helloworld program and enter the command "arm-none-linux-gnueabi-gcc-4.4.1 -o helloworld
helloworld.c -static", as shown in the figure below, to generate the executable file helloworld.
(, downloads: 0)
8.1.3 Upload helloworld to the development board
Copy the executable file helloworld to the fastboot burning directory, as shown in the figure below. This directory is
where the fastboot tool is burned. For the usage of 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 "fastboot" directory, as shown in the figure below.
(, downloads: 0)
After the development board is fully started, connect the OTG interface. The screen of the development board will prompt "Do you want to allow debugging?" Select
"Allow".
Then enter the command "chmod 777 /data" in the serial console to modify the permissions of the data directory, as shown in the figure below.
(, downloads: 0)
As shown in the figure below, enter the command "adb push helloworld /data" in the "cmd.exe" of the PC to upload the program
to the "/data" directory of the development board. If "Allow USB debugging" is not enabled, the following message will be prompted.
(, downloads: 0)
After enabling "Run USB debugging", use the command "adb push helloworld /data" as shown in the figure below.
(, downloads: 0)
Of course, you can also upload the executable file helloworld through the mobile assistant, TF card or USB flash drive. If it prompts that the command
cannot be used, please note: please refer to Section 10.2.2 of the user manual to update adb.
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 the "chmod 777
helloworld" command to modify permissions, and finally enter the "./helloworld" command to run the program. "Hello world!" will be printed in the hyperterminal
, indicating that the program runs successfully.
(, downloads: 0)
iTOP4418 development board already supports Android 7.1 system
|