Use crosstool-ng to create an arm-Linux cross-compiling environment under fedora12

Source: Internet
Author: User
Tags gmp posix
Use crosstool-ng to create an arm-Linux cross-compiling environment under fedora12
It took a few days to build the crosstool-ng-based ARM-Linux cross-compiling environment. During this process, it was a great deal of effort and it was a great pleasure to complete the process successfully. Make a summary record in time based on the remaining temperature.
Crosstool-ng is used because crosstool-ng is a new tool used to establish a cross tool chain. It is the replacement of crosstool. The GCC version of crosstool can only be 4.1.1, and Linux kernel Versions later than 2.6.29 cannot be compiled. Crosstool-ng remains updated, and now the latest GCC 4.3.2 version can be used to compile the latest kernel.
System Environment: fedora12 Linux BRL. 32.21-166

1. Download crosstool-ng

Crosstool-ng is: http://ymorin.is-a-geek.org/download/crosstool-ng
It is worth noting that after downloading the latest crosstool-ng, remember to go to the http://ymorin.is-a-geek.org/download/crosstool-ng/01-fixes/ to see if there is any corresponding patch, and download it together.

The downloaded version is 1.8.1 without a patch.

2. Prepare the installation environment for crosstool-ng

To use crosstool-ng, you must install some development and application tools:

Bison
Flex
Texinfo
Automake
Libtool
Patch
Gcj
CVS
CVSD
Gawk

In fedora, run the $ sudo Yum install XXX command to install it in sequence.
Note: you cannot install gcj in fedora simply by using sudo Yum install gcj. Use the sudo Yum install * gcj command, and then install by Y all, as long as the libgcj-x.x.x-x and Java -- x. x. x-gcj-x.x.x in the installation list are installed.
Then, manually install termcap.

Tar zxvf termcap-1.3.1.tar.gz
CD termcap-1.3.1
./Configure -- prefix =/usr
Make
Make install

Iii. Installing crosstool-ng

$ Mkdir ~ /Croosstool-ng # create the croosstool-ng directory in the current user directory
$ Cd ~ /Croosstool-ng
$ MV/tmp/crosstool-ng-1.8.1.tar.bz2./# Put the downloaded crosstool-ng package in the crosstool-ng directory
$ Tar-jxvf crosstool-ng-1.8.1.tar.bz2 # unpack
$ CD crosstool-ng-1.8.1 # enter the extract directory
$Patch-P1 <patch File>#Patch crosstool-ng (if any)
$./Configure -- prefix =/opt/crosstool-ng #Configure crosstool-ng
$ Make #Compile crosstool-ng
$ Sudo make install #Install crosstool-ng
$ Echo "Path = $ path:/opt/crosstool-ng/bin" >> ~ /. Bashrc # Add the environment variable for the subsequent call of the CT-ng command
$ Source ~ /. Bashrc
$ CT-ng help
This is crosstool-ng version 1.8.1

Copyright (c) 2008 Yann E. Morin <yann.morin.1998@anciens.enib.fr>
This is free software; see the source for copying conditions.
There is no warranty; not even for merchantability or fitness for
Particle purpose.

At this point, we have successfully taken a big step, and the drama is still coming soon. Come on ~!

Iv. Configure the cross-compilation tool chain

$ Cd ~ /Croosstool-ng
$ Mkdir crosstool-ng-1.8.1_build # create an output directory for a cross toolchain
$ Mkdir SRC # create and save the source code package directory
$ Mkdir X-tools # Build the installation path of the Cross Compiler
$ CD crosstool-ng-1.8.1_build/
$ CP/opt/crosstool-ng/lib/ct-ng-1.8.1/samples/ARM-unknown-Linux-gnueabi/crosstool. config. config
$ CT-ng menuconfig

The crosstool-ng Configuration window appears. For the armv4t architecture, modify the configuration:
1. The downloaded source code package path and cross-compiler installation path.
Paths and MISC options --->
($ {Home}/crosstool-ng/src) Local tarbils directory saves the source package path
($ {Home}/crosstool-ng/X-tools/$ {ct_target}) installation path of prefix directory Cross Compiler

2. Modify the cross-compiler framework
Target options --->
* ** Target optimisations ***
(Armv4t) architecture level
(Arm9tdmi) emit assembly for CPU
(ARM920T) tune for CPU
By searching for information, this should be the architecture of the instruction set. For S3C2410/S3C2440, it is the core of ARM920T, And the architecture instruction is armv4t. Therefore, if you want to compile 2410/2440, select armv4t. And so on the core of the ARM1176JZF-S using the armv6 architecture, choose armv6, then what architecture is supported? You can use man GCC to query, search for arm, and search-March = to find the list of CPU cores supported by GCC.

3. Increase the number of parallel processes during compilation to increase the running efficiency and speed up compilation.
Paths and MISC options --->
* ** Build behavior ***
(4) number of parallel jobs
This value should not be too large. It should be twice the number of CPUs. Because my CPU is dual-core, I entered 4.

4. Some personalized modifications (which can be left unchanged)
Toolchain options --->
* ** Tuple completion and aliasing ***
(Embedi) tuple's vendor string
The prefix of the compiler is: Arm-embedi-Linux-gnueabi-

5. C compiler --->
(Crosstool-ng-$ {ct_version}-embedi) gcc id string
The above red font is the modification.

V. compilation tool chain

After the configuration is complete, run the command: $ CT-ng build.4 in the crosstool-ng-1.8.1_build directory.

The next step is a long wait. Crosstool-ng automatically downloads the corresponding package and Kernel File, decompress, configure, compile, and link.

Note: Although crosstool-ng automatically downloads the corresponding software package, the speed is slow. We recommend that you download the corresponding software package before executing the CT-ng build command. View the ". config" file under the crosstool-ng-1.8.1_build directory to know which packages and their versions are needed, the software packages required by the local machine are as follows:

Linux-2.6.33.2.tar.bz2
Binutils-2.19.1.tar.bz2
Gcc-4.3.2.tar.bz2
Glibc-2.9.tar.gz
Dmalloc-5.5.2.tgz
Duma_2_5_15.tar.gz
Gdb-6.8.tar.bz2
Ltrace_0.5.3.orig.tar.gz
Strace-4.5.19.tar.bz2
Gmp-4.3.2.tar.bz2
Mpfr-2.4.2.tar.bz2
Libelf-0.8.13.tar.gz

I have not found the following files in the. config file, but it is also necessary (you can just let it download automatically ):
Ncurses-5.7.tar.gz
Ecj-latest.jar
Glibc-ports-2.9.tar.bz2
Sstrip. c

 

Right. Where should these downloaded software packages be stored? Put it in the targets/tarbils folder under the crosstool-ng-1.8.1_build directory.
The compilation tool needs to wait patiently Based on the chain, as stated on the official website: Have a coffee, have lanuth, and take a sleep. My computer is thinktad sl410, dual-core processor, 2 GB memory, and has been compiled for nearly 2 hours.

6. Add Environment Variables
If there is no error in the above process, congratulations on your success. Should you open the champagne to celebrate? Sorry, I don't have it. It will definitely be available in the future. Ah, but don't worry. The last step is to add the environment variable. input:
$ Echo "Path = $ path: $ home/crosstool-ng/X-tools/ARM-embedi-Linux-gnueabi/bin"> ~ /. Bashrc.
OK. This is caused by major achievements. Should I test it? Simple:
$ Arm-embedi-Linux-gnueabi-gcc-V
Using built-in specs.
Target: Arm-embedi-Linux-gnueabi
Configured: /home/iamxzg/crosstool-ng/crosstool-ng-1.8.1_build/targets/src/gcc-4.3.2/configure -- Build = i686-build_pc-linux-gnu -- Host = i686-build_pc-linux-gnu -- target = arm-embedi-Linux-gnueabi -- prefix =/ home/iamxzg/crosstool-ng/X-tools/ARM-embedi-Linux-gnueabi -- With-sysroot =/home/iamxzg/crosstool-ng/X-tools/ARM-embedi -Linux-gnueabi/ARM-embedi-Linux-gnueabi // sys-root -- enable-compatible ages = C, c ++, Fortran, java -- disable-multilib -- With-arch = armv4t -- With-CPU = arm9tdmi -- With-tune = ARM920T -- With-float = soft -- With-pkgversion = crosstool-NG-1.8.1-embedi -- disable-sjlj- exceptions -- enable-_ cxa_atexit -- disable-libmudflap -- With-GMP =/home/iamxzg/crosstool-ng/crosstool-ng-1.8.1_build/targets/ARM-embedi-Linux-gnueabi/build/static -- With-mpfr =/home/iamxzg/crosstool-ng/crosstool-ng-1.8.1_build/targets/ARM-embedi-Linux-gnueabi/build/static -- enable-threads = POSIX -- enable-target- optspace -- With-local-Prefix =/home/iamxzg/crosstool-ng/X-tools/ARM-embedi-Linux-gnueabi/sys- root -- disable-NLS -- enable-symvers = GNU -- enable-c99 -- enable-Long-long
Thread model: POSIX
GCC version 4.3.2 (crosstool-NG-1.8.1-embedi)

Errors and Solutions
1.
[Error] Missing: 'i686-PC-Linux-GNU-gcj 'or 'i686-PC-Linux-GNU-gcj' or 'gcj ': either needed!Solution: sudo Yum install * gcj

2.

[Info] installing native GDB
[Info] installing native GDB
[Extra] building static target ncurses
[Error] Make [2]: *** [tic] Error 1
[Error] Build failed in step 'installing native GDB'
[Error] error happened in '/opt/crosstool-ng/lib/ct-ng-1.8.1/scripts/Functions' in function 'ct _ doexeclog' (line unknown, sorry)
[Error] called from '/opt/crosstool-ng/lib/ct-ng-1.8.1/scripts/build/debug/300-gdb.sh' at line #162 in function 'do _ debug_gdb_build'
[Error] called from '/opt/crosstool-ng/lib/ct-ng-1.8.1/scripts/build/debug. Sh' at line #35 in function 'do _ debug'
[Error] called from '/opt/crosstool-ng/lib/ct-ng-1.8.1/scripts/crosstool-NG.sh' at line #586 in function 'main'
[Error] Look at '/home/iamxzg/crosstool-ngg/X-tools/ARM-embedi-Linux-gnueabi/build. log' for more info on this error.
[Error] (elapsed: 73: 59.36)
[73: 59]/make [1]: *** [Build] Error 2
Make: *** [build.4] Error 2
Solution: sudo Yum installGlibc-static
Because you do not know how to installGlibc-static. I got stuck for several days on this issue.. There is a final conclusion, so in fedora, you should install it first.

3. Others
There are still some errors that I did not record in time. If you encounter them, please refer to the following:
Use crosstool-ng to establish an arm-Linux cross tool chain

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.