The CPU in the X86 architecture uses a Complex Instruction Set (Complex Instruction Set Computer, CICs), while the CPU in the ARM architecture uses a streamlined Instruction Set (RISC ). Because the CPUs of these two architectures use different instruction sets, the X86 architecture can be developed to run on the ARM architecture.ProgramCross-compiler is required. Generally, cross-compiler and related tools contain many executable files, a large number of shared libraries, header files, and other resources. A collection of these resources is called a cross-compilation environment.
On the Internet, you can find the integrated cross-compilation environment, Android ndk and AndroidSource codeCross-compilation environment. Of course, if we need a completely independent cross-compilation environment, we can download the integrated cross-compilation environment or make it by ourselves (complicated. We recommend that you download the integrated cross-compilation environment ). The following describes a codesourcery cross-compilation environment. You can directly download and install this environment.
You can visit the codesourcery download page through the following website.
Http://www.mentor.com/embedded-software/sourcery-tools/sourcery-codebench/editions/lite-edition/
The above page does not directly provide a download link for codesourcery. Readers can click the "download the GNU/Linux release" link and enter email (Gmail is recommended), address, and other information, finally, click "Get lite!" Button submission information. From 2 to 29. Finally, the system will send the email you just entered.
On the download page, you will see the download links for different versions shown in 2-30. Select the latest version.
Figure 2-30 different codesourcery versions
Go to the download page of codesourcery and you will see the download link from 2 to 31. Currently, codesourcery has two versions: Windows and Linux. This book uses 1st (ia32 GNU/Linux installer ).
The Installation File for Linux is in Bin format. You can run the following command to install codesourcery. Package indicates the Installation File Name of codesourcery.
Sh package. Bin
After executing the preceding command, a visual installation interface is displayed, as shown in 2-32. you can install codesourcery as prompted.
For ease of use, we recommend that you add the following path to the PATH environment variable.
/Root/compilers/codesourcery/sourcery_codebench_lite_for_arm_gnu_linux/bin
Write a simple C program to test this cross-compilation environment.
// First. C # include <stdio. h> int main () {printf ("first arm program \ n"); Return 0 ;}
Enter the following command to compile the first. c file (the-static option must be added ).
# Arm-None-Linux-gnueabi-gcc-static-o first. c
Enter the following command to upload the first file to the/data/local directory of any Android device (root permission is not required ).
# ADB push first/data/local
Run the ADB shell command to go To the Android device console and enter the/data/local directory. Run the following command:
#./First
When the above command is executed, the "first arm program" information is output. The first program cannot run in Ubuntu Linux running on the X86 architecture. You can try to run the first program in Ubuntu Linux to see what will happen.
Note: During code sourcery installation, a libc is found in the/lib directory. so.6 library file, but there is no libc In the Ubuntu linux11.04 or later/lib directory. so.6 library file. This library file is stored in another directory. In 32-bit Ubuntu Linux, the file path is/lib/i386-linux-gnu/libc. so.6, in 64-bit Ubuntu Linux, the file path is/lib/x86_64-linux-gnu/libc. so.6. Before installing code sourcery, you can use the ln command to create a link for the libc. so.6 file in the/lib directory.
This article is excerptedAndroid Deep Exploration (Volume 1): Hal and driver development, The following articlesArticleWe will explain in detail how to develop the Linux driver of the ARM architecture, and test the Linux driver by using the android program, ndk, and executable files. Can be in Ubuntu Linux, Android simulator and cloud6410 Development Board (you can buy OK6410-A Development Board, need to brush Android)