现在的位置: 首页 > 综合 > 正文

AT91RM9200Linux移植笔记(一)-交叉编译环境的建立

2013年10月14日 ⁄ 综合 ⁄ 共 2646字 ⁄ 字号 评论关闭

公司有块复旭AT91RM9200的板子,自带的是u-boot-0.40和2.4.19的kernel,决定把u-boot-1.1.6和2.6的内核移植上去,以此开始进入嵌入式Linux的世界。我的开发环境是Vmvare 5.5.1和Redhat 9, 参考了网上不少网友的移植文档,在此向他们表示感谢!
发现原有的arm-linux-2.95.3交叉编译工具只能编译u-boot-1.1.4一下的版本,更新的需要更新的交叉编译工具,但用arm-linux-gcc-3.4.1编译u-boot-1.1.6会出现软浮点-softfloat问题:
/lib_arm/_udivsi3.S:67: relocation truncated to fit: R_ARM_PLT32 __div0
lib_arm/_umodsi3.S:79: relocation truncated to fit: R_ARM_PLT32 __div0
查看了不少资料,发现需要重新制作cross tools,如果Binutils,GCC,GLIBC源代码包安装的话,步骤非常繁琐,也很容易出错,幸好有Dan Kegel写的crosstool脚本,可以方便的制作自己的交叉编译工具,下载地址为:
http://kegel.com/crosstool/,步骤如下:
1、以root身份登录,创建新用户username,因为crosstool不能在root下编译
2、创建目录/opt/crosstool/,并修改并修改其所有者
3、以username登录,创建目录/home/username/downloads,这个目录将来用于自动从网上下载gcc, binutilty,glibc等。如果自己已经下载了这些软件包,也放在这个目录下,这样就不用程序自动从网上下载了。
4、将下载的crosstool-0.43.tar.gz到解压到目录/opt/crosstool
$ tar -zxvf crosstool-0.43.tar.gz
5、进入crosstool-0.43目录,执行sh demo-arm-softfloat.sh
打开demo-arm-softfloat.sh
#!/bin/sh
# This script has one line for each known working toolchain
# for this architecture.  Uncomment the one you want.
# Generated by generate-demo.pl from buildlogs/all.dats.txt

set -ex
TARBALLS_DIR=$HOME/downloads
RESULT_TOP=/opt/crosstool
export TARBALLS_DIR RESULT_TOP
GCC_LANGUAGES="c,c++"
export GCC_LANGUAGES

# Really, you should do the mkdir before running this,
# and chown /opt/crosstool to yourself so you don't need to run as root.
mkdir -p $RESULT_TOP

#eval `cat arm-softfloat.dat gcc-2.95.3-glibc-2.1.3.dat` sh all.sh --notest
#eval `cat arm-softfloat.dat gcc-2.95.3-glibc-2.2.2.dat` sh all.sh --notest
#eval `cat arm-softfloat.dat gcc-2.95.3-glibc-2.2.5.dat` sh all.sh --notest
#eval `cat arm-softfloat.dat gcc-3.2.3-glibc-2.2.5.dat` sh all.sh --notest
#eval `cat arm-softfloat.dat gcc-3.2.3-glibc-2.3.2.dat` sh all.sh --notest
#eval `cat arm-softfloat.dat gcc-3.2.3-glibc-2.3.2-tls.dat` sh all.sh --notest
#eval `cat arm-softfloat.dat gcc-3.3.6-glibc-2.2.2.dat` sh all.sh --notest
#eval `cat arm-softfloat.dat gcc-3.3.6-glibc-2.2.5.dat` sh all.sh --notest
#eval `cat arm-softfloat.dat gcc-3.3.6-glibc-2.3.2.dat` sh all.sh --notest
#eval `cat arm-softfloat.dat gcc-3.3.6-glibc-2.3.2-tls.dat` sh all.sh --notest
#eval `cat arm-softfloat.dat gcc-3.4.5-glibc-2.2.5.dat` sh all.sh --notest
#eval `cat arm-softfloat.dat gcc-3.4.5-glibc-2.3.5.dat` sh all.sh --notest
eval `cat arm-softfloat.dat gcc-3.4.5-glibc-2.3.6.dat` sh all.sh --notest

echo Done.

eval `cat arm-softfloat.dat gcc-3.4.5-glibc-2.3.6.dat` sh all.sh --notest说明我们使用的是gcc-3.4.5和glibc-2.3.6

经过漫长的等待,在/opt/crosstool/目录下生成gcc-3.4.5-glibc-2.3.6的文件夹,里面就是我们将来使用的工具链arm-soft-linux-gnu,将该路径添加到PATH环境变量:
$ export PATH=$PATH: /opt/crosstool/gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux-gnu/bin/

或者指定u-boot和Linux kernel的Makefile中的CROSS_COMPILE宏:
ARCH  ?= arm
CROSS_COMPILE ?= /opt/crosstool/gcc-3.4.5-glibc-2.3.6/arm-softfloat-linux-gnu/bin/arm-softfloat-linux-gnu-

抱歉!评论已关闭.