mkdir crosstool-ng-1.6.1_build #这次编译新交叉编译器的工作目录 mkdir crosstool-ng-1.6.1_install #crosstool-ng的安装目录 cd crosstool-ng-1.6.1 #进入解压后的crosstool-ng目录
patch -p1 < <补丁文件> # 给crosstool-ng打补丁(如果有)
./configure --prefix=${CROSSTOOLNG}/crosstool-ng-1.6.1_install
#配置crosstool-ng make #编译crosstool-ng make install #安装crosstool-ng
cd ${CROSSTOOLNG}/crosstool-ng-1.6.1_build/
#进入编译新交叉编译器的工作目录 cp ../crosstool-ng-1.6.1/samples/arm-unknown-Linux-gnueabi /* ./
#拷贝默认配置文件到工作目录
mv crosstool.config .config
#修改文件名
../crosstool-ng-1.6.1_install/bin/ct-ng menuconfig
进入menuconfig,开始修改配置。
下面我只说说针对 armv4t需要修改的地方,别的构架等有了板子测试再说: 1、已下载好的源码包路径和交叉编译器的安装路径。 Paths and misc options ---> (${HOME}/development/crosstool-ng/src) Local tarballs directory 保存源码包路径 (${HOME}/development/x-tools/${CT_TARGET}) Prefix directory 交叉编译器的安装路径 这两个请依据你的实际情况来修改。 2、修改交叉编译器针对的构架 Target options ---> *** Target optimisations *** ( armv4t) Architecture level ( arm9tdmi) Emit assembly for CPU ( arm920t) Tune for CPU 以上这几个参数是如何得出的可以参考gcc的man手册,你可以在你下载的gcc-4.3.2.tar.bz2解压后找到,她的位置是gcc-4.3.2/gcc/doc/gcc.1。打开方式:man ./gcc.1
你可以在其中找到:...... ARM Options ...... -mcpu=name (Emit assembly for CPU) This specifies the name of the target ARM processor. GCC uses this name to determine what kind of instructions it can emit when gener‐ ating assembly code. Permissible names are: arm2, arm250, arm3, arm6, arm60, arm600, arm610, arm620, arm7, arm7m, arm7d, arm7dm, arm7di, arm7dmi, arm70, arm700, arm700i, arm710, arm710c, arm7100, arm7500, arm7500fe, arm7tdmi, arm7tdmi-s, arm8, strongarm, stron‐ garm110, strongarm1100, arm8, arm810, arm9, 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 option is very similar to the -mcpu= option, except that instead of specifying the actual target processor type, and hence restricting which instructions can be used, it specifies that GCC should tune the performance of the code as if the target were of the type specified in this option, but still choosing the instruc‐ tions that it will generate based on the cpu specified by a -mcpu= option. For some ARM implementations better performance can be obtained by using this option. -march=name (Architecture level) This specifies the name of the target ARM architecture. GCC uses this name to determine what kind of instructions it can emit when generating assembly code. This option 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.
......
3、关闭JAVA编译器,避免错误。 我这里用ubuntu 9.10编译JAVA编译器的时候会出错,也许是host的gcj的问题,反正我不用JAVA,所以就直接关闭了。 如果有兄弟知道如何修正记得通知一声!! C compiler ---> *** Additional supported languages: *** [ N] Java error log: [INFO ] ================================================================= [INFO ] Installing final compiler [EXTRA] Configuring final compiler [EXTRA] Building final compiler [ERROR] jar: internal error: [ERROR] make[4]: *** [libgcj-4.3.2.jar] Error 1 [ERROR] make[3]: *** [all-recursive] Error 1 [ERROR] make[2]: *** [all-target-libjava] Error 2 [ERROR] make[1]: *** [all] Error 2 [ERROR] Build failed in step 'Installing final compiler' [ERROR] Error happened in '/home/tekkaman/development/research/crosstool-ng/crosstool-ng-1.6.1_install/lib/ct-ng-1.6.1/scripts/functions' in function 'CT_DoExecLog' (line unknown, sorry) [ERROR] called from '/home/tekkaman/development/research/crosstool-ng/crosstool-ng-1.6.1_install/lib/ct-ng-1.6.1/scripts/build/cc/gcc.sh' at line # 350 in function 'do_cc' [ERROR] called from '/home/tekkaman/development/research/crosstool-ng/crosstool-ng-1.6.1_install/lib/ct-ng-1.6.1/scripts/crosstool-NG.sh' at line # 562 in function 'main' [ERROR] Look at '/home/tekkaman/development/x-tools/arm-tekkaman-linux-gnueabi/build.log' for more info on this error. [ERROR] (elapsed: 67:10.67) [67:11] / make: *** [build] 错误 2 4、根据参考资料,禁止内核头文件检测( 只起到节约时间的作用(不到1S的时间),不推荐禁用) Operating System ---> [N] Check installed headers 5、增加编译时的并行进程数,以增加运行效率,加快编译。 Paths and misc options ---> *** Build behavior *** ( 4) Number of parallel jobs 这个数值不宜过大,应该为CPU数量的两倍。由于我的CPU是双核的,所以我填了4. 6、一些个性化的修改 (可以不修改) Toolchain options ---> *** Tuple completion and aliasing *** (tekkaman) Tuple's vendor string 这样产生的编译器前缀就是:arm-tekkaman-linux-gnueabi- C compiler ---> (crosstool-NG-${CT_VERSION}-tekkaman) gcc ID string 配置好以后保存。 最后, 内核源码的版本号修改,请直接修改 crosstool-ng-1.6.1_build目录下的.config文件,不止一处,有关的都要修改。 有: CT_KERNEL_VERSION= CT_KERNEL_V_2_6_??_?=y CT_LIBC_GLIBC_MIN_KERNEL= 如果再次 ../crosstool-ng-1.6.1_install/bin/ct-ng menuconfig,这个修改又会复原,必须再次手工修改。 你也可以选择修改crosstool-ng-X.Y.Z_build/config/kernel/linux.in等文件,只是比较麻烦,但这可以彻底解决,实现在界面中增加内核版本。../crosstool-ng-1.6.1_install/bin/ct-ng bluid
我的笔记本用了大概40多分钟编译完成。