Establish an ARM-Linux cross-compilation environment

xiaoxiao2021-03-18  205

We use the following version of the file as an example to establish an ARM-Linux cross-compilation environment:

Compilation 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 .... E-2.95.3.Tar.gz GCC-G 2.95.3.tar.gz ftp://ftp.gnu.org/gnu/gcc /GCC-2.95.... -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-lz Linux-2.4.21.tar.gz ftp: //ftp.kernle.org/pub/linux/kern...x-2.4.21.tar.gz patch-2.4.21-rmk1.gz # Linux kernel patch for arm ftp: //ftp.arm.linux. Org.uk/pub/linu...-2.4.21-rmk1.gz

We work in Bash, first set some variables: $ export vbinutils = 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 to login to take effect. Otherwise, enter them on the Bash command line and take effect immediately, but it is invalid when you logOut.

Our work path is:

..... ----- ~ - Tars -------- SourceDir ............................... ... | ---- builddir ............. | --- armtools

$ cd ~ $ mkdir -p tars / source $ mkdir tars / builddir $ mkdir arm_tools $ su # mv arm_tools $ prefix # exit $

TARS --------------- Let's download our download .tar.gz file SOURDIR ------ This temporary directory puts our unzipped source file builddir - ------- We compile armtools here -------- install the ARM-Linux cross-compilation environment

1. Install Linux header file

When you compile GCC for different types of ARM, or compile different versions of Kernel, or you need a different set of Linux header files when cross-compiling GCCs.

1.1 Unzip, patch $ CD ~ / TARS / SOURCEDIR $ TAR -ZXF ../Linux- $ TAR-ZX.TAR.GZ $ CD Linux $ zcat ../../patch- $ VLINUX- $ VLINUX_PATCH.GZ | Patch -p1

1.2 Clean $ MAKE MRPROPER

1.3 Modify Makefile ARCH: = $ (Shell Uname -M | Sed -ES / I.86 ​​/ I386 / -ES / ARM. * / ARM / -ES / SA110 / ARM /) This line comes out and adds ARCH = ARM. After modifying the like this: Arch = ARM # Arch: = $ (shell uname -m | sed -es / i.86 / i386 / -es / sun4u / sparc64 / -es / arm. * / Arm / -es / sa110 / ARM /) If the SED program in your system supports' / 'continuation (usually support), you can use this script to modify the makefile #! / bin / sh mv makefile makefile.orig sed' s / arch: = $ (Shell Uname -M / Arch = ARM / # Arch: = $ (Shell Uname -M / ' makefile #end of script

Note: # arch in this script: = is the last line of continuation, not comments in the shell, it is also to enter. If you click on the browser (IE, Netscape, etc), you can get your Bash Console from your browser (IE, Netscape, etc), it is very likely not to work; but you can work in Bash Console. Because sometimes COPY is coming, it is 'Arch = ARM / R / N', and the 'Arch = ARM / N' can be operated.

1.4 Establishing connection 1.4.1 If it is LART board $ make Lart_config $ yes "| Make Oldconfig $ make Include / Linux / Version.h or: $ make Lart_config $ make menuconfig selection

The online article is used: $ make symlinks include / linux / version.h is incomplete. Make Symlinks is equivalent to: $ CD INCLUDE / ASM-ARM $ RM -F Arch Proc $ ln -s arch-sa1100 arch $ ln -s proc-armv proc $ cd ../../ it did not produce a very Important file include / linux / autoconf.h. YES "" | make OldConfig is not only Make Symlinks, but also incrude / Linux / AutoConf.h. But it did not produce include / Linux / Version.h.

1.4.2 If the CPU connection of CLPS711x should be: $ cd include / asm-arm $ RM -F Arch Proc $ ln -s arch-clps711x arch $ ln -s proc-armv proc $ cd ../../../

Customization for your own system: $ make MenuConfig Here you only need to choose the CPU you use or the board you use, you can use the board of the CPU, of course, more detailed configuration is better.

Note: Include / asm-arm / proc-armo is 26 ARM

INCLUDE / ASM-ARM / PROC-ARMV is 32-bit ARM

Note: Background knowledge implements 26-bit address space in ARM1, but is not commercially available. There is also 26-bit address space in ARM2, 2A, and now has been discarded. Extended to 32-bit address space in ARM3, but it is back to 26 bits. In ARM4 is 32-bit address space, stop compatible with 26-bit address space. Add the thumb instruction in the T series. In ARM5 is 32-bit address space, 16-bit Thumb instructions are supported in all series. 1.5 Copy Head File $ MKDIR -P $ Prefix / $ TARGET / INCLUD $ PREFIX / $ TARGET / INCLUDE $ CP -DR Include / ASM-ARM $ Prefix / $ TARGET / INCLUDE / ASM

1.6 When establishing a Linux kernel header file for GCC, it requires Linux Kernel's header file, you can use --with-headers = prefix / $ target / include to specify the location of the header file, GCC copy it To $ Prefix / $ TARGET / SYS-INCLUDE. We can build a sys-incrude connection, no need to --with-headers. $ CD $ PREFIX / $ TARGET $ ln -s include sys-incdude

2 compilation and installation binutils

LINUX header files not prepared in front

2. Unzip $ CD ~ / TARS / SOURCEDIR $ TAR-ZXF ../binutils- $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 Binutils path to the environment variable you can add it to .bashrc. If you do this, you need logout to login to take effect. Otherwise, enter it on the Bash command line and take effect immediately, but it is invalid when you logOn. Export path = $ prefix / bin: $ PATH

3. Compilation and installation of GCC C compiler 3.1 Unzip $ CD ~ / TARS / SOURCEDIR $ TAR -ZXF ../gcc-core- $vgcc.tar.gz

Note: Why don't you have all-in-one GCC- VGCC.TAR.GZ? All-in-one GCC package has Chill, Fortran, Java and other languages ​​compilers, although specified at the following configure- Languages ​​= C, but compiles all the compiles, this is not what we need, and it will always have errors. So we only compile the C language compiler. This problem is also the next time the next time, we only compile C and C compilers.

3.2 Modify the T-Linux file of GCC in TARGET_LIBGCC2_CFLAGS in the T-Linux file __gthr_posix_h and inhibit_libc

$ Cd gcc- $ VGCC / gcc / config / arm $ mv t-linux t-linux-orig $ sed 's / TARGET_LIBGCC2_CFLAGS = / TARGET_LIBGCC2_CFLAGS = -D__gthr_posix_h -Dinhibit_libc /' t-linux-core $ cp ./t-linux-core ./t-linux3.4 compiled $ cd ~ / tars / builddir $ mkdir gcc-core $ cd gcc-core $ ../../sourcedir/gcc- $vgcc/configure / --Target = $ target / --prefix = $ prefix / --enable-languages ​​= c / --disable-shared / --disable-trrads $ make all install

4. Compilation and installation GLIBC 4.1 Unzip $ CD ~ / TARS / SOURCEDIR $ TAR -ZXF ../glibc- $ VGLIBC.TAR.GZ $ CD GLIBC- $ VGLIBC $ TAR -ZXF ../../glibc-linuxthreads- $ VGLIBC.TAR.GZ

4.2 Compile $ CD ~ / TARS / BuildDir $ MKDIR GLIBC $ CD GLIBC $ CC = $ target-gcc ar = $ target-ar ranlib = $ target-ranlib / ../../sourcedir/glibc- $ VGLIBC/CONFIGURE / $ Target / --prefix = $ prefix / $ target / --enable-add-ons $ make all install

5. Compilation and installation GCC C, C compiler 5.1 Recovery T-Linux file $ CD ~ / TARS / SOURCEDIR / GCC- $ VGCC / GCC / CONFIG / ARM / $ CP T-Linux-Orig T-Linux

5.2 Decompression C Compiler $ CD ~ / TARS / SOURCEDIR / $ TAR -ZXF ../gcc-g - all - tars / builddir $ mkdir gcc $ CD GCC

5.3 Compile $ ../../sourcedir/gcc- $vgcc/configure / --target = $ target / --prefix = $ prefix / --enable-languages ​​= C, C / --with-incruded-getText $ Make All $ make Install

Note: If you download FileName.Tar.bz2, you can use one of the following commands to decompress, and the third way is good in any system.

$ tar -jxf filename.tar.bz2 $ tar -ixf filename.tar.bz2 $ bzip2 -dc filename.tar.bz2 | TAR XF -

If you are the first time ARM-Linux cross-compilation environment, you strongly recommend that you use this version of the programs used herein. If other versions, according to this document may be problematic when compiling, because I don't have time to test the combination of each version. Here is the source program: Crossarm.sh, it is: Linux-2.4.21.tar.bz2 patch-2.4.21.bz2 binutils-2.14.tar.gz gcc-core-2.95.3.tar.gz GCC- G - 2.95.3.tar.gz glibc-2.2.4.tar.gz generated Toolchain is more than 150 trillion, compressed as follows: $ CD ~ $ tar -cf arMTools.tar / arMTools $ bzip2 -z armtools.tar compression The post-generated arMtools.tar.bz2 has about 30 megabytes.

转载请注明原文地址:https://www.9cbs.com/read-129874.html

New Post(0)