【实验环境】
Ubuntu10.10发行版
FS2410平台
【实验步骤】
1、源码下载
Crosstools-ng下载地址
http://ymorin.is-a-geek.org/download/crosstool-ng/
同时对每一个版本都有相应的补丁我们尽量把这些补丁打上,这些补丁的下载地址是
http://ymorin.is-a-geek.org/download/crosstool-ng/01-fixes/
这里选用的是crosstool-ng-1.8.1.tar.bz2
并下载补丁
000-scripts_log_do_not_interpret_log_string_as_printf_format.patch
001-binutils_binutils_remove_faulty_patch.patch
002-kconfig_resync_curses_check_with_Linux_kernel.patch
2、工具的安装
在使用之前必须安装一些软件
$ sudoapt-get install gawk autotools-dev automake texinfo libtool cvs patchbison flex libncurses5-dev
必要目录的创建
$ mkdirtoolchain_build
$ mkdirtoolchain_install
解压源码并打补丁
$ tar xvfcrosstool-ng-1.8.1.tar.bz2
$ cdcrosstool-ng-1.8.1
$ patch –p1< 000-scripts_log_do_not_interpret_log_string_as_printf_format.patch
$ patch –p1< 001-binutils_binutils_remove_faulty_patch.patch
$ patch–p1< 002-kconfig_resync_curses_check_with_Linux_kernel.patch
配置并编译crosstool-ng-1.8.1
$./configure--prefix=/home/linux/s3c2410-2.6.35/toolchain/toolchain-install
$ make
$ makeinstall
配置工具链选项
$ cd ../toolchain-build
$ cp../crosstool-ng-1.8.1/samples/arm-unknown-linux-gnueabi/* ./
$ mvcrosstool.config .config
$../toolchain-install/bin/ct-ng menuconfig
Paths andmisc options --->
(${HOME}/src)Local tarballs directory
(${HOME}/x-tools/${CT_TARGET})Prefix directory
修改为
Paths andmisc options --->
(/home/linux/Downloads)Local tarballs directory //源码包存放路径
(/home/linux/toolchain)Prefix directory //工具生成后的安装路径
Targetoptions --->
(armv4t)Architecture level
(arm9tdmi)Emit assembly for CPU
(arm920t)Tune for CPU
C compiler --->
[ ] Java
OperatingSystem --->
[ ] Check installed headers
Paths andmisc options --->
(1) Numberof parallel jobs
Toolchainoptions --->
(none)Tuple's vendor string
C compiler --->
(crosstool-NG-${CT_VERSION}-farsight)gcc ID string
修改.config文件,将文件中的2.6.33.2全部改为2.6.35
目标代码准备
拷贝下面文件到/home/linux/Downloads目录下:
binutils-2.19.1.tar.bz2
gcc-4.3.2.tar.bz2
glibc-ports-2.9.tar.bz2
linux-2.6.35.tar.bz2
ncurses-5.7.tar.gz
dmalloc-5.5.2.tgz
gdb-6.8.tar.bz2
gmp-4.3.2.tar.bz2
ltrace_0.5.3.orig.tar.gz
strace-4.5.19.tar.bz2
duma_2_5_15.tar.gz
glibc-2.9.tar.bz2
libelf-0.8.13.tar.gz
mpfr-2.4.2.tar.bz2
Sstrip.c
工具链编译
$../toolchain-install/bin/ct-ng build
这个过程比较时间比较长
环境变量的添加
修改文件/etc/bash.bashrc添加如下内容
exportPATH=$PATH:/home/linux/toolchain/bin
重启配置文件
$ sourcebash.bashrc
工具链的测试
$arm-none-linux-gnueabi-gcc –v
Usingbuilt-in specs.
Target:arm-none-linux-gnueabi
Configuredwith:/home/linux/s3c2410-2.6.35/toolchain/toolchain-build/targets/src/gcc-4.3.2/configure--build=i686-build_pc-linux-gnu --host=i686-build_pc-linux-gnu--target=arm-none-linux-gnueabi --prefix=/home/linux/toolchain--with-sysroot=/home/linux/toolchain/arm-none-linux-gnueabi//sys-root--enable-languages=c,c++,fortran --disable-multilib--with-arch=armv4t --with-cpu=arm9tdmi --with-tune=arm920t--with-float=soft --with-pkgversion=crosstool-NG-1.8.1-none--disable-sjlj-exceptions --enable-__cxa_atexit --disable-libmudflap--with-gmp=/home/linux/s3c2410-2.6.35/toolchain/toolchain-build/targets/arm-none-linux-gnueabi/build/static--with-mpfr=/home/linux/s3c2410-2.6.35/toolchain/toolchain-build/targets/arm-none-linux-gnueabi/build/static--enable-threads=posix --enable-target-optspace--with-local-prefix=/home/linux/toolchain/arm-none-linux-gnueabi//sys-root--disable-nls --enable-symvers=gnu --enable-c99 --enable-long-long
Threadmodel: posix
gcc version4.3.2 (crosstool-NG-1.8.1-none)
这个时候我们的工具链就生成了