centos 下 arm 交叉编译

1,安装arm-linux-gcc

从友善之臂的网站上面下载arm-linux-gcc,下载地址:

http://www.arm9.net/download-arm-linux-gcc-4.3.2.asp

我下载的是网页下面的4.4.3。

对新版本arm-linux-gcc-4.4.3进行解压(注意,对于正常的版本,如果我们在解压时指定目录为根目录,即加上了-C /,那么就会自动解压到/usr/local/arm/这个目录下),但是友善之臂的压缩包按照这种方式解压,不会解压到/usr/local/arm/目录下的,这是因为友善之臂把/usr/local/arm/目录修改成了 /opt/FriendlyARM/toolschain/,除非自己在把它修改过来。

root@focus:~# tar -xvf arm-linux-gcc-4.4.3-20100728.tar.gz -C /

修改环境变量,把交叉编译器的路径加入到PATH,我用的友善之臂的压缩包,注意路径的设置。

修改/etc/profile文件,增加路径设置,在末尾添加如下,保存/etc/profile文件:

 export PATH=$PATH:/opt/FriendlyARM/toolschain/4.4.3/bin

立即使新的环境变量生效,不用重启电脑  

root@focus:~# source /etc/profile

检查是否将路径加入到PATH:

root@focus:~# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/FriendlyARM/toolschain/4.4.3/bin

  显示的内容中有/usr/local/arm/4.4.3/bin,说明已经将交叉编译器的路径加入PATH。至此,交叉编译环境安装完成。

测试是否安装成功:

root@focus:~# arm-linux-gcc -v
Using built-in specs.
Target: arm-none-linux-gnueabi
Configured with: /opt/FriendlyARM/mini2440/build-toolschain/working/src/gcc-4.4.3/configure --build=i386-build_redhat-linux-gnu --host=i386-build_redhat-linux-gnu --target=arm-none-linux-gnueabi --prefix=/opt/FriendlyARM/toolschain/4.4.3 --with-sysroot=/opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi//sys-root --enable-languages=c,c++ --disable-multilib --with-arch=armv4t --with-cpu=arm920t --with-tune=arm920t --with-float=soft --with-pkgversion=ctng-1.6.1 --disable-sjlj-exceptions --enable-__cxa_atexit --with-gmp=/opt/FriendlyARM/toolschain/4.4.3 --with-mpfr=/opt/FriendlyARM/toolschain/4.4.3 --with-ppl=/opt/FriendlyARM/toolschain/4.4.3 --with-cloog=/opt/FriendlyARM/toolschain/4.4.3 --with-mpc=/opt/FriendlyARM/toolschain/4.4.3 --with-local-prefix=/opt/FriendlyARM/toolschain/4.4.3/arm-none-linux-gnueabi//sys-root --disable-nls --enable-threads=posix --enable-symvers=gnu --enable-c99 --enable-long-long --enable-target-optspace
Thread model: posix
gcc version 4.4.3 (ctng-1.6.1) 

上面的命令会显示arm-linux-gcc信息和版本

参看文档:

http://wenku.baidu.com/view/47640637b90d6c85ec3ac679.html

2,编译模块

参看文档:

http://www.cnblogs.com/hnrainll/archive/2011/07/07/2100183.html

http://hi.baidu.com/deep_pro/item/ad4f188785c61f5926ebd900

http://blog.chinaunix.net/uid-25906157-id-1754441.html

3,编译内核

把文中的一下两行

#ARCH  ?= $(SUBARCH)
#CROSS_COMPILE ?=
修改为
ARCH  ?= arm
CROSS_COMPILE ?= arm-none-linux-gnueabi-

使用默认的config文件:

cp ./arch/arm/configs/omap4_defconfig .config

or 自行配置:

make menuconfig

编译内核和模块

make uImage –j  4

 

参看文档:

http://www.cnblogs.com/foxhengxing/archive/2011/02/05/1949368.html

http://blog.csdn.net/lzuzhp06/article/details/7716452

 

原文地址:https://www.cnblogs.com/godjesse/p/2935785.html