Crosstool-ng is a multi-purpose tool chain compilation tool with high configuration flexibility. Supports multiple architectures, multiple components (glibc/uclibc...), and versions. Crosstool-ng also provides the debugging entity (Duma, strace...) and generation tool (sstrip ...)
The cross tool chain compiled with crosstool-ng can be used to compile the latest U-boot, Linux kernel, and file system, which is very convenient.
1. download the latest crosstool-ng installation package:
Http://ymorin.is-a-geek.org/download/crosstool-ng/
And patch:
Http://ymorin.is-a-geek.org/download/crosstool-ng/01-fixes/
Decompress, create a working directory, and install the directory:
My decompression Directory :~ /Crosstool-ng-1.7.1/
Working directory :~ /Crosstool-ng_build/
Installation Directory :~ /Crosstool-ng_install/
2. Use the sudoapt-Get install command to install the following essential software packages
Libncurses5-dev
Bison
Flex
Texinfo
Automake
Libtool
Patch
Gcj
CVS
CVSD
Gawk (ubuntu10.04gawk is the latest)
3. patch:
CD crosstool-ng-1.7.1
Patch-P1 <patch file address>
For example:
Patch-P1 <000-scripts_finish_do_not_try_to_symlink_if_sed_expr_is_a_no-op.patch
Patch-P1 <001-libc_uclibc_fix_snapshots.patch
Patch-P1 <002-configure_fix _ -- Mandir. Patch
./Configure -- prefix =/home/Hu/crosstool-ng_install configuration installation directory
4. Installation
Make
Make install
Set environment variables:
Exportpath = "$ {path }:/ home/Hu/crosstool-ng_install/bin"
Now that the installation is complete, you need to configure the cross-compilation tool chain.
6. Configuration
Copy two files under the crosstool-ng-1.7.1/samples/ARM-unknown-Linux-gnueabi directory to the crosstool-ng_build
Rename:
CD crosstool-ng_build
CP./crosstool. config. config
Enter the configuration page
CT-ng menuconfig
Paths and MISC options --->
Local tarbils directory stores the path of the source code package. If the path does not exist, the source code package is not saved.
Prefix directory cross compiler installation path
Set these two items as needed
Target options --->
* ** Target optimisations ***
(Armv4t) architecture level
(ARM920T) emit Assembly forcpu
(Arm9tdmi) tune for CPU
To the above several examples is the result can refer to the gccman, download gcc-4.3.2.tar.bz2 after decompression, manual location is gcc-4.3.2/GCC/doc/gcc.1. Open Mode:
Man./gcc.1
You can find:
...... Armoptions ...... -Mcpu = Name (emit assembly for CPU) Thisspecifies the name of the target ARM processor. GCC uses this Nameto determine what kind of instructions it can emit whengener ‐ Ating assembly code. Permissible names are: arm2, arm250, arm3, Arm6, arm60, arm600, arm610, arm620, arm7m, arm7d, arm7dm, Arm7di, arm7dmi, arm70, arm700, arm700i, arm710, arm710c, arm7100, Arm7500, arm7500fe, ARM7TDMI, arm7tdmi-s, arm8, Strongarm, stron ‐ Garm110, strongarm1100, arm8, arm810, arm9e, arm920, ARM920T, Arm922t, arm946e-s, arm966e-s, arm968e-s, arm926ej-s, arm940t, Arm9tdmi, arm10tdmi, arm1020t, arm1026ej-s, arm10e, arm1020e, Arm1022e, arm1136j-s, arm1136jf-s, mpcore, mpcorenovfp, Arm1156t2-s, arm1176jz-s, arm1176jzf-s, cortex-a8, cortex-r4, cor ‐ Tex-m3, XScale, iwmmxt, ep9312. -Mtune = Name (tune for CPU) This optionis very similar to the-mcpu = option, doesn't that Instead ofspecifying the actual target processor type, and hence Restrictingwhich instructions can be used, it specifies that GCC Shouldtune the performance of the Code as if the target were Thetype specified in this option, but still choosing the specified UC ‐ Tions that it will generate Based on the CPU specified by a-mcpu = Option. For some arm implementations better extends cecan be Obtained by using this option. -March = Name (architecture level) This specifies the name of the targetarm architecture. GCC uses This name to determine what kind ofinstructions it can emit when Generating assembly code. thisoption can be used in conjunction With Or instead of the-mcpu = option. Permissible names are: Armv2, armv2a, armv3, armv3m, armv4, armv4t, armv5, armv5t, Armv5te, armv6, armv6j, armv6t2, armv6z, armv6zk, armv7, armv7-a, Armv7-r, armv7-m, iwmmxt, ep9312. ...... |
Pathsand MISC options ---> increase the number of parallel processes for compilation, increase the running efficiency, and speed up compilation
* ** Build behavior ***
(4) number ofparallel jobs
This number should be twice the number of CPUs, and the dual-core CPU should be 4
7. Start Compilation:
In the crosstool-ng_build directory:
CT-ngbuild
If an error occurs, write the absolute path. Mine is:
/Home/Hu/crosstool-ng_install/bin/CT-ngbuild
Start a long wait.
The entire build process consumes a lot of hard disk space. Reserve at least 5 GB space for smooth build.
At the beginning, the required source code packages will be downloaded and placed in the localtarballsdirectory set by menuconfig. On the one hand, in order to speed up, on the other hand, because the source code package downloaded by the compiler is often incomplete, there may be decompression errors, it is strongly recommended that you manually download the required source code package.
The source package I need for compilation is:
Binutils-2.19.1.tar.bz2
Glibc-2.9.tar.gz
Dmalloc-5.5.2.tgz
Glibc-ports-2.9.tar.bz2
Mpfr-2.4.2.tar.bz2
Duma_2_5_15.tar.gz
Gmp-4.3.1.tar.bz2
Ncurses-5.7.tar.gz
Ecj-latest.jar this automatic download error, only manual download
Libelf-0.8.12.tar.gz
Sstrip. c
Gcc-4.3.2.tar.bz2
Linux-2.6.33.2.tar.bz2
Strace-4.5.19.tar.bz2
Gdb-6.8.tar.bz2
Ltrace_0.5.3.orig.tar.gz
Decompress and compile the source code package after it is downloaded.
8. compilation errors and handling methods:
If a compilation error occurs, open the build. Log File to view the cause of the error.
I encountered the following errors:
An error occurred while extracting the file. In the build. log file, the system prompts filedeskupet. You need to manually download the source package and put it in the tarbils directory. This error is common in decompressing the automatically downloaded source code package. Therefore, we recommend that you manually download the package.
After downloading the source code package again, you must delete some decompressed files to re-compile the package. A prompt is displayed for the location of some extracted files.
Kernel header file creation error. You need to view the specific analysis of the build. log file, but you cannot change the kernel version.
The command Elif cannot be identified during the make process. In this case, you need to install the corresponding software package. Search for the solution.
If you encounter other errors, you can search for the error code to see how others solve the problem. Generally, you can find a solution.
It took me 90 minutes to build the cross compiler. The built compiler is located in the prefixdirectory set by menuconfig.
9. Use of the Cross tool chain:
First, create the environment variable in the directory where the cross tool chain is located.
Exportpath = "$ {path}:/home/Hu/X-tools/ARM-unknown-Linux-gnueabi/bin"
When using this method, if you have another terminal, you need to enter it again.
There is another solution, edit ~ /. Profile file, and finally add
Path = "/home/Hu/X-tools/ARM-unknown-Linux-gnueabi/bin: $ path"
Second, set the value of the environment variable cross_compile In The makefile of the software package to arm-unknown-Linux-gnueabi-before compiling-
10. Refer to the blog:
Http://www.cublog.cn/u1/34474/showart_2198589.html
Http://blog.csdn.net/HumorRat/archive/2010/05/21/5615298.aspx