arm-elf交叉编译器安装与测试
一.下载交叉编译器 ftp://166.111.8.229/OS/Embedded/uclinux/pub/uClinux/arm-elf-tools/ 下载些目录下的“arm-elf-tools-20030314.sh”文件。二.安装交叉编译器 1.修改“arm-elf-tools-20030314.sh”文件的权限 chmod a+x ar
一.下载交叉编译器
ftp://166.111.8.229/OS/Embedded/uclinux/pub/uClinux/arm-elf-tools/
下载些目录下的“arm-elf-tools-20030314.sh”文件。
二.安装交叉编译器
1.修改“arm-elf-tools-20030314.sh”文件的权限
chmod a+x arm-elf-tools-20030314.sh
2.执行安装
./arm-elf-tools-20030314.sh
安装完成后,利用命令 ls /usr/local/bin/ 可以查看到以“arm-elf”开头的相关执行程序,这些文件用于编译在目标平台上运行的程序。
例如:arm-elf-gcc,arm-elf-addr2line,arm-elf-gdb,arm-elf-ld arm-elf-as,arm-elf-c++,
arm-elf-g++,genromfs,arm-elf-run 等等。
三.测试交叉编译器
下面利用一个实例C程序测试arm-elf-gcc编译器
1.源码:
/*
hello.c
*/
#include <stdio.h>
int main(void)
{
printf("Hello world!");
return 0
}
2.编译:
arm-elf-gcc -Wl, -elf2flt -o hello hello.c
-elf2flt参数是将elf文件格式转为flat文件格式,其它还有很多选项,可以到网上查找相关的介绍文档。
3.查看执行文件格式:
file hello
输出内容:hello:data
4.安装测试内核
首先需要安装skyeye程序,这个程序在以后会介绍到,然后就是下载一个testutils包,这个包里面有几嵌入式内核,
下面慢慢介绍。
1.下载testutils-1.0.4包,网址: http://download.gro.clinux.org/skyeye/skyeye-binary-testutils-1.0.4.tar.bz2
2.解压:tar jxvf skyeye-binary-testutils-1.0.4.tar.bz2,并进入解压出来的目录中:cd testsuits/at91/uclinux2
3.建立一个目录:mkdir romfs(后面将用到,这个主要用于装入hello程序)
4.新建挂载目录,并挂载:mkdir /mnt/uclinux ; mount -o loop boot.rom /mnt/uclinux
5.将内核文件复制到romfs目录:cp -r /mnt/uclinux/* ./romfs
6.将我们生成的hello文件复制到/romfs/bin目录
7.利用romfs目录生成新的内核系统:genromfs -f boot.rom -d romfs/
现在hello程序已经放到内核系统的bin/中了,接下来利用skyeye加载内核,并运行。
8.利用skyeey加载运行内核:/home/skyeye-1.2.5/skyeye -e ./linux (说明:运行skyeye根据自己安装的目录而定,参数“-e” 一定要加,否则会出现错误“... no bank found ...”,当前目录为/testutils/at91/uclinux2,这个目录下面有内核文件“linux”)。
这样就进入我们在linux下面熟悉的命令行模式了,接下来得用cd bin进入bin目录,用ls -l 就可以查看到我们自己的hello程序了,运行程序./hello ,就可以看到我们再熟悉不过的结果了“Hello world!”
至此,交叉编译器的安装与测试就算圆满成功了。当前在这里只是初略的介绍了一下,交叉编译器的安装与测试,其实里面还有很需要我去学习的东西,比如:arm-elf-gcc 参数,genromfs 等等,其中skyeye(中文名:“天目”)也是比较重要的,它可以模拟很多内核系统以及相关的硬件,比如:软件系统有uclinux,ucos!!,等,硬件有ARM,MIPS等。
我的机器上出现了以下信息:
root@lizhoujian uclinux2]# /home/zjli/skyeye-1.2.5/skyeye -e ./linux
Your elf file is little endian.
arch: arm
cpu info: armv3, arm7tdmi, 41007700, fff8ff00, 0
mach info: name at91, mach_init addr 0x805bd28
ethmod num=1, mac addr=0:4:3:2:1:f, hostip=192.168.1.166
can't find device module: (name:net, type:(null))
log_info: log is off.
log_info:log file is /tmp/test.log, fd is 0x814cd20
log_info: log start clock 3200000
log_info: log end clock 3330000
uart_mod:0, desc_in:, desc_out:, converter:
SKYEYE: use arm7100 mmu ops
Loaded ROM ./boot.rom
exec file "./linux"'s format is elf32-little.
load section .init: addr = 0x01000000 size = 0x0000a000.
load section .text: addr = 0x0100a000 size = 0x000d0480.
load section .data: addr = 0x010dc000 size = 0x00009154.
not load section .bss: addr = 0x010e5160 size = 0x00022954 .
call ARMul_InitSymTable,kernel filename is ./linux.
start addr is set to 0x01000000 by exec file.
Linux version 2.4.20-uc0 ( chy@localhost.localdomain ) (gcc version 2.95.3 20010315 (release)(ColdFire patches - 20010318 from http://fiddes.net/coldfire/)(uClinux XIP and shared lib patches from http://www.snapgear.com/ )) #7 五 8月 1 19:43:07 CST 2003
Processor: Atmel AT91M40xxx revision 0
Architecture: EB01
On node 0 totalpages: 1024
zone(0): 0 pages.
zone(1): 1024 pages.
zone(2): 0 pages.
Kernel command line: root=/dev/rom0
Calibrating delay loop... 12.97 BogoMIPS
Memory: 4MB = 4MB total
Memory: 2984KB available (833K code, 181K data, 40K init)
Dentry cache hash table entries: 512 (order: 0, 4096 bytes)
Inode cache hash table entries: 512 (order: 0, 4096 bytes)
Mount-cache hash table entries: 512 (order: 0, 4096 bytes)
Buffer-cache hash table entries: 1024 (order: 0, 4096 bytes)
Page-cache hash table entries: 1024 (order: 0, 4096 bytes)
POSIX conformance testing by UNIFIX
Linux NET4.0 for Linux 2.4
Based upon Swansea University Computer Society NET3.039
Initializing RT netlink socket
Starting kswapd
Atmel USART driver version 0.99
ttyS0 at 0xfffd0000 (irq = 2) is a builtin Atmel APB USART
ttyS1 at 0xfffcc000 (irq = 3) is a builtin Atmel APB USART
Blkmem copyright 1998,1999 D. Jeff Dionne
Blkmem copyright 1998 Kenneth Albanowski
Blkmem 1 disk images:
0: 1400000-15853FF [VIRTUAL 1400000-15853FF] (RO)
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
SkyEye NE2k Ethernet driver version 0.2 (2003-04-27)
sene2k dev name: eth0: <6>NET4: Linux TCP/IP 1.0 for NET4.0
IP Protocols: ICMP, UDP, TCP
IP: routing cache hash table of 512 buckets, 4Kbytes
TCP: Hash tables configured (established 512 bind 512)
NET4: Unix domain sockets 1.0/SMP for Linux NET4.0.
sys_mount:dev_name /dev/root,dir_name /root, type ext2, flag 0x8001, data 0
sys_mount:1 data_page 1122000, type_page 113bf74, dev_page 0, dir_page 8001
sys_mount:2 data_page 0, type_page 117f000, dev_page 117d000, dir_page 117e000
sys_mount:3 data_page 0, type_page 117f000, dev_page 117d000, dir_page 117e000
sys_mount:4 data_page 0, type_page 117f000, dev_page 117d000, dir_page 117e000
sys_mount:dev_name /dev/root,dir_name /root, type romfs, flag 0x8001, data 0
sys_mount:1 data_page 0, type_page 117f000, dev_page 117d000, dir_page 8001
sys_mount:2 data_page 0, type_page 117f000, dev_page 117d000, dir_page 117e000
sys_mount:3 data_page 0, type_page 117f000, dev_page 117d000, dir_page 117e000
sys_mount:4 data_page 0, type_page 117f000, dev_page 117d000, dir_page 117e000
VFS: Mounted root (romfs filesystem) readonly.
sys_mount:dev_name .,dir_name /, type <NULL>, flag 0x2000, data 0
sys_mount:1 data_page 111c120, type_page 0, dev_page 10e5d00, dir_page 10e5174
sys_mount:2 data_page 0, type_page 0, dev_page 117f000, dir_page 1122000
sys_mount:3 data_page 0, type_page 0, dev_page 117f000, dir_page 1122000
sys_mount:4 data_page 0, type_page 0, dev_page 117f000, dir_page 1122000
Shell invoked to run file: /etc/rc
Command: hostname GDB-ARMulator
Command: /bin/expand /etc/ramfs.img /dev/ram0
Command: mount -t proc proc /proc
sys_mount:dev_name /proc,dir_name /proc, type proc, flag 0xc0ed0000, data 11d1008
sys_mount:1 data_page 1000, type_page 1002, dev_page 118c008, dir_page c0ed0000
sys_mount:2 data_page 118a000, type_page 11a2000, dev_page 118b000, dir_page 1122000
sys_mount:3 data_page 118a000, type_page 11a2000, dev_page 118b000, dir_page 1122000
sys_mount:4 data_page 118a000, type_page 11a2000, dev_page 118b000, dir_page 1122000
mount: /etc/mtab: Read-only file system
Command: mount -t ext2 /dev/ram0 /var
sys_mount:dev_name /dev/ram0,dir_name /var, type ext2, flag 0xc0ed0000, data 11d1008
sys_mount:1 data_page 111c260, type_page 119fe40, dev_page 0, dir_page c0ed0000
sys_mount:2 data_page 1188000, type_page 118a000, dev_page 1189000, dir_page 1122000
sys_mount:3 data_page 1188000, type_page 118a000, dev_page 1189000, dir_page 1122000
sys_mount:4 data_page 1188000, type_page 118a000, dev_page 1189000, dir_page 1122000
mount: /etc/mtab: Read-only file system
Command: mkdir /var/tmp
Command: mkdir /var/log
Command: mkdir /var/run
Command: mkdir /var/lock
Command: cat /etc/motd
Welcome to
____ _ _
/ __| ||_|
_ _| | | | _ ____ _ _ _ _
| | | | | | || | _ /| | | |/ // /
| |_| | |__| || | | | | |_| |/ /
| ___/____|_||_|_| |_|/____|/_//_/
| |
|_|
GDB/ARMulator support by < davidm@snapgear.com >
For further information check:
http://www.uclinux.org/
Command: /bin/ifconfig eth0 up 10.0.0.2
IO error in at91_io_write_byte,addr=0xfffff108
Execution Finished, Exiting
Sash command shell (version 1.1.1)
/>cd bin (进行hello所存放的目录)
/bin>./hello (这里就运行我们的hello程序了)
Hello world!
/bin>
更多推荐
所有评论(0)