Create an arm-linux cross-compiling environment step by step
Source: Internet
Author: User
Article Title: Create an arm-linux cross-compiling environment step by step. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
The following files are used as examples to create an arm-linux cross-compiling environment:
Compiling environment redhat 7.2 or 8.0
Binutils-2.14.tar.gz ftp://ftp.gnu.org/gnu/binutils/binutils-2.14.tar.gz
Gcc-core-2.95.3.tar.gz ftp://ftp.gnu.org/gnu/gcc/gcc-2.95.3/gcc-core-2.95.3.tar.gz
Gcc-g000000002.95.3.tar.gz ftp://ftp.gnu.org/gnu/gcc/gcc-2.95.3/gcc-g++-2.95.3.tar.gz
Glibc-2.2.4.tar.gz ftp://ftp.gnu.org/gnu/glibc/glibc-2.2.4.tar.gz
Glibc-linuxthreads-2.2.4.tar.gz ftp://ftp.gnu.org/gnu/glibc/glibc-linuxthreads-2.2.4.tar.gz
Linux-2.4.21.tar.gz ftp://ftp.kernle.org/pub/linux/kernel/v2.4/linux-2.4.21.tar.gz
Patch-2.4.21-rmk1.gz # linux kernel patch for arm ftp://ftp.arm.linux.org.uk/pub/linux/arm/kernel/v2.4/patch-2.4.21-rmk1.gz
When we work in bash, we first set some variables:
$ Export VBINUTILS = 2.14
$ Export VGCC = 2.95.3
$ Export VGLIBC = 2.2.4
$ Export VLINUX = 2.4.21
$ Export VLINUX_PATCH = rmk1
$
$ Export PREFIX =/armtools
$ Export TARGET = arm-linux
You can add them to. bashrc. If you do this, you need logout and then login to take effect.
Otherwise, enter them in the bash command line and take effect immediately, but it becomes invalid when you log out and then login.
Tars --------------- put the downloaded .tar.gz file here
SourceDir ------ put the temporary directory in the source file after decompression
BuildDir --------- compile
Armtools -------- install the arm-linux cross-compiling environment here
1. Install the linux header file
When you compile gcc for different types of arm, or compile different versions of kernel, or cross-compile gcc, you need a different set of linux header files.
1.1 decompress and patch
$ Cd ~ /Tars/SourceDir
$ Tar-zxf ../linux-20.vlinux.tar.gz
$ Cd linux
$ Zcat.../../patch-example vlinux-example vlinux_patch.gz | patch-p1
1.2 clear
$ Make mrproper
1.3 modify Makefile
In Makefile, set ARCH :=$ (shell uname-m | sed-e s/I .86/i386/-e s/sun4u/sparc64/-e s/arm. */arm/-e s/sa110/arm/) comment out the line and add a line of ARCH = arm. The modification is as follows:
ARCH = arm
# ARCH: = $ (shell uname-m | sed-e s/I .86/i386/-e s/sun4u/sparc64/-e s/arm. */arm/-e s/sa110/arm /)
If the sed program in your system supports '\' to continue (usually), you can use this script to modify the Makefile.
#! /Bin/sh
Mv Makefile. orig
Sed's/ARCH: = $ (shell uname-m/ARCH = arm # ARCH: = $ (shell uname-m/'<Makefile. orig> Makefile
# End of script
Note:
# ARCH: = in this script is the last line of continued rows, not a comment in shell, it also needs to be input.
If you copy the-paste script from your browser (IE, netscape, etc) to your bash console, it may not work;
However, you can manually enter it in the bash console.
Sometimes after the copy, it is 'arch = arm \ r \ n', But what works is 'arch = arm \ n '.
1.4 establish a connection
1.4.1 For An LART Board
$ Make lart_config
$ Yes "" | make oldconfig
$ Make include/linux/version. h
Or:
$ Make lart_config
$ Make menuconfig select
Some articles on the Internet use:
$ Make symlinks include/linux/version. h
That is incomplete. Make symlinks serves the following purposes:
$ Cd include/asm-arm
$ Rm-f arch proc
$ Ln-s arch-sa1100 arch
$ Ln-s proc-armv proc
$ Cd ../../
It does not generate an important file include/linux/autoconf. h.
And yes "" | make oldconfig is not only make symlinks,
Also, include/linux/autoconf. h is generated. But it does not produce
Include/linux/version. h.
1.4.2 if the CPU is clps711x
The connection should be:
$ Cd include/asm-arm
$ Rm-f arch proc
$ Ln-s arch-clps711x arch
$ Ln-s proc-armv proc
$ Cd ../../
Customized for your system:
$ Make menuconfig
Here you only need to select the CPU you are using or the board with the CPU you are using,
Of course, more detailed configuration is better.
Note:
Include/asm-arm/proc-armo is 26-bit arm
Include/asm-arm/proc-armv is a 32-bit arm
Note: Background Knowledge
26-bit address space is implemented in arm1, but it is not commercially available.
There are still 26 addresses in arm2 and 2a, which are now obsolete.
It is extended to 32-bit address space in arm3, but it is also backward compatible with 26-bit.
In arm4, there is a 32-bit address space, and the compatibility with the 26-bit address space is stopped. Add the Thumb command to the T series.
In arm5, It is a 32-bit address space and supports 16-bit Thumb commands in all series.
1.6 establish a linux kernel header file connection for gcc
When compiling gcc, it requires the linux kernel header file. You can use -- with-headers = $ PREFIX/$ TARGET/include to specify the position of the header file, gcc copies it to $ PREFIX/$ TARGET/sys-include. We can establish a sys-include connection, so we don't need -- with-headers.
$ Cd $ PREFIX/$ TARGET
$ Ln-s include sys-include
2. Compile and install binutils
The preceding linux header file is not used.
2.1 decompress
$ Cd ~ /Tars/SourceDir
$ Tar-zxf ../binutils-20.vbinutils.tar.gz
2.2 compile
$ Cd ~ /Tars/BuildDir
$ Mkdir binutils
$ Cd binutils
$.../SourceDir/binutils-$ VBINUTILS/configure -- target = $ TARGET -- prefix = $ PREFIX
$ Make all install
2.3 output the path of binutils to the Environment Variable
You can add it to. bashrc. If you do this, you need logout and then login to take effect.
Otherwise, input it on the bash command line and it takes effect immediately, but it becomes invalid when you log out and then login.
Export PATH = $ PREFIX/bin: $ PATH
3. Compile and install the c compiler of gcc
3.1 decompress
$ Cd ~ /Tars/SourceDir
$ Tar-zxf ../gcc-core-w.vgcc.tar.gz
Note: why not use all-in-one gcc-1_vgcc.tar.gz?
The gcc package of all-in-one contains compilers for languages such as chill, fortran, and java. Although-enable-compatible ages = c is specified in configure, however, we still need to compile all the files during compilation. This is not what we need, and there will always be errors. Therefore, we only compile the C language compiler. This problem is also the second compilation. We only compile the C and C ++ compilers.
3.2 modify the gcc t-linux File
Add _ gthr_posix_h and inhibit_libc to TARGET_LIBGCC2_CFLAGS in the t-linux File.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.