Ubuntu Arm_linux I.MX6ULL cross compilation toolchain installation detailed tutorial

I moved the atomic tutorial on time, and some of it is not detailed.

4.3 Ubuntu Cross Compilation Toolchain Installation
4.3.1 Cross Compiler Installation
ARM bare metal, Uboot porting, and Linux porting all need to be compiled under Ubuntu, and a compiler is required for compilation
. Explain how to develop C language in Linux, which
uses the GCC compiler to compile the code, but the gcc compiler that comes with Ubuntu is for the X86 architecture! And what we
want to compile now is the code of the ARM architecture, so we need a GCC compiler that runs on the PC of the X86 architecture and can compile the code of the ARM
architecture . This compiler is called a cross compiler. To sum up, a cross compiler is :
1. It must be a GCC compiler.
2. The GCC compiler runs on a PC with an X86 architecture.
3. The GCC compiler compiles the ARM architecture code, that is, the compiled executable file
runs on the ARM chip.
"Crossing" in a cross compiler means compiling the code of another architecture on one architecture, which is equivalent to
"crossing" the two architectures.

Copy the tutorial compilation tool to Ubuntun

Create a directory in Ubuntu: /usr/local/arm, the command is as follows:
sudo mkdir /usr/local/arm
After the creation is completed, copy the cross compiler just copied to the /usr/local/arm directory, and use the command in the terminal
"cd" enters the directory where the cross compiler is stored. For example, I copied the cross compiler to the directory
"/home/zuozhongkai/linux/tool" before, and then use the following command to copy the cross compiler to /usr/local/ In arm:
sudo cp gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf.tar.xz /usr/local/arm/ -f
insert image description here
Figure 4.3.1.6 Copy the cross compilation tool to the /usr/local/arm directory
After the copy is completed, decompress the cross compilation tool in the /usr/local/arm directory. The decompression command is as follows:
sudo tar -vxf gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf.tar.xz
Wait for the decompression to complete, After the decompression is completed, a folder named "gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf" will be generated
, which is our cross-compilation toolchain.
Modify the environment variables and use VI to open the /etc/profile file with the following command:
sudo vi /etc/profile
After opening /etc/profile, enter the following content at the end:
export PATH=$PATH:/usr/local/arm/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/bin After
adding /etc/profile as shown in Figure 4.3.1.7:
insert image description here
Save and exit, restart the Ubuntu system, and the cross-compilation toolchain (compiler) is successfully installed.
Type in the command line

````````The following is very important. Many tutorials do not have a detailed introduction.

#sudo -s
Enter administrator privileges
#source /root/.bashrc
restart the service

Switch to the normal user and enter the normal user's environment variable
vim ~/.bashrc to
add
export PATH=$PATH:/usr/local/arm/gcc-linaro-4.9.4-2017.01-x86_64_arm-linux-gnueabihf/bin
#source ~ /.bashrc
restart service

Because the environment variables of administrator privileges cannot be used by ordinary users, you need to add the environment variables of ordinary users as well.

````````The above is very important. Many tutorials do not have a detailed introduction.

First check the version number of the cross-compilation tool and enter the following command:

arm-linux-gnueabihf-gcc -v
insert image description here
development environment is built

Guess you like

Origin blog.csdn.net/weixin_42839808/article/details/118545085