linux 2.6.24.4及根文件系统在S3C2410上的移植(使用4.3.2编译器支持eabi)(基于GEC2410)

之前移植了linux-2.6.24.4和根文件系统(使用busybox-1.10.1创建)在GEC2410平台上运行。可参考之前的笔记:
内核配置: http://blog.csdn.net/shevsten/archive/2010/05/17/5599790.aspx
根文件系统: http://blog.csdn.net/shevsten/archive/2010/05/26/5625133.aspx

在测试一个用4.3(支持EABI)编译的应用程序时开始出现找不到库,将4.3.2编译器目录/usr/local/arm/compiler/arm-none-linux-gnueabi/libc/armv4t/lib中所有的库复制到根文件系统的lib目录,运行结果出现Illegal instruction。结果发现是编译器及EABI的问题,内核和根文件系统有必要使用新的编译器编译了。

那时候用的是crosstool编译出来的3.4.5的支持softfloat的编译器,如今的编译器早已升级到4.*, 浮点处理采用eabi方式.
EABI(Embedded Application Binary Interface)有许多革新之处,其中最突出的改进就是Float Point Performance,它使用Vector Float Point(矢量浮点),因此可以极大提高涉及到浮点运算的程序。

在原来移植好的linux-2.6.24.4基础上进行修改(详见上一篇文章):
一.内核移植
1.修改makefile中的CROSS_COMPILE,即设置编译器路径
ARCH  ?= arm
CROSS_COMPILE ?= /usr/local/arm/4.3.2/bin/arm-none-linux-gnueabi-
2.配置内核,增加eabi支持
[localhost linux-2.6.24.4]$ make gec2410_defconfig
[localhost linux-2.6.24.4]$ make menuconfig
在Kernel Features里勾选上EABI的支持.
[*] Use the ARM EABI to compile the kernel
[*] Allow old ABI binaries to run with this kernel (EXPERIMENTAL) (NEW)
3.重新编译
$ make
编译过程中会出现undefined reference to `__udivdi3'的错误.
网上搜索了一下,解决办法为:
在makefile中查找到:
KBUILD_CFLAGS   := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs /
     -fno-strict-aliasing -fno-common /
     -Werror-implicit-function-declaration 改为:

改为                 
KBUILD_CFLAGS   := -Wall -Wundef -Wstrict-prototypes -Wno-trigraphs /
     -fno-strict-aliasing -fno-common /
     -fno-tree-scev-cprop /
     -Werror-implicit-function-declaration
然后重新编译就OK了
4.生成uImage并烧写到板子中
5.重启班子,就可以看到linux的启动信息了(红色为编译器信息)
## Booting image at 30008000 ...
   Image Name:   linux-2.6.24
   Created:      2010-12-24   7:43:06 UTC
   Image Type:   ARM Linux Kernel Image (uncompressed)
   Data Size:    1541736 Bytes =  1.5 MB
   Load Address: 30008000
   Entry Point:  30008040
   Verifying Checksum ... OK
   XIP Kernel Image ... OK

Starting kernel ...

Uncompressing Linux.............................................................
....................................... done, booting the kernel.
Linux version 2.6.24.4 (matt@localhost) (gcc version 4.3.2 (Sourcery G++ Lite 20
08q3-72)
) #1 Fri Dec 24 15:40:53 CST 2010
CPU: ARM920T [41129200] revision 0 (ARMv4T), cr=00007177
......

二.根文件系统移植
1.修改makefile为新的编译器路径
CROSS_COMPILE ?= /usr/local/arm/4.3.2/bin/arm-none-linux-gnueabi-

2.重新编译
[localhost busybox-1.10.1]$ make
[localhost busybox-1.10.1]$ make install
3.将_install新的文件生成新的根文件系统(cramfs,ramdisk...)
具体方法可参考:http://blog.csdn.net/shevsten/archive/2010/05/26/5625133.aspx

尝试了使用新的busybox,如1.14.3, 1.15.2,但是做出来的根文件系统都会在Freeing init memory: 132K处挂起,网上说是和eabi有关系,尝试了很多次也没有找到解决办法,可能要使用更新版的linux内核吧。

三.测试程序
1. 写一个很简单的hello程序:
[localhost GEC2410]$ vi hello.c

#include <stdio.h>

int main(void)

{

        printf("Hello, World!/n");

        return 0;

}
保存退出
:x

2.编译
首先设置编译器路径环境变量,这样就可以直接使用arm-linux-gcc的命令了。这里使用修改.bashrc文件的方法。增加PATH路径
[localhost GEC2410]$ cd ~
[localhost ~] $ vi .bashrc

# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

# User specific aliases and functions
export CROSS_COMPILE=arm-linux-
export PATH=/usr/local/arm/4.3.2/bin:$PATH

保存退出
:x

[localhost ~] $ source .bashrc
可以使用export命令来看看新的环境变量生效了没有,如果没有需要注销重启
[localhost ~] $ export
declare -x PATH="/usr/local/arm/4.3.2/bin:/usr/local/arm/4.3.2/bin:/usr/lib/qt-3.3/bin:/usr/kerberos/bin:/usr/lib/ccache:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/matt/bin"
可以看到路径已经被添加了

接着就来编译上面的hello.c
[localhost GEC2410] $ arm-linux-gcc –o hello hello.c
这样编译出来的是动态链接的hello
运行的话需要有动态库的支持,这时就需要将/usr/local/arm/compiler/arm-none-linux-gnueabi/libc/armv4t/lib的库复制到根文件系统的lib目录中,否则运行会报找不到库的错误。(有些应用程序还需要/usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/usr/lib中的库文件)

[localhost GEC2410] $ arm-linux-gcc -static–o hello hello.c
加上-static的标签就将hello静态链接了,这样就可以直接运行了,但是文件体积会大了不少

将新的根文件系统烧写到目标机的flash上运行:
$ ./hello
Hello, World!

为了确保软件的EABI匹配性,不出现Illegal instruction的错误,应该保证

1.  编译kernel的时候在Kernel Features选项中选上EABI
2.  所有的软件都是用支持EABI的编译器(例如arm-linux-4.3.2)来编译

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值