文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>第二部分、uClinux的移植和运行

第二部分、uClinux的移植和运行

时间:2007-04-11  来源:yeguo

作者:yeshi
QQ:251059619
Blog:http://blog.chinaunix.net/u1/33990/

一、交叉编译工具的安装
从www.uClinux.org下载arm-elf-tools,里面包含arm-elf-gcc, arm-elf-ld等工具。
$ su
口令:
#./arm-elf-tools-20040427.sh
tail: 无法打开 “+43” 读取数据: 没有那个文件或目录

gunzip: stdin: not in gzip format

baidu.com........然后

#tail -n+43 arm-elf-tools-20040427.sh >> arm.tar.gz
#tar zxvf arm.tar.gz
在当前目录得到一个usr的文件夹
#cp -R usr  /
这样在/usr/local目录下就安装了相应的文件夹

二、uClinux的编译安装
在www.uclinux.org网站上下载内核包文件
$tar -xvzf uClinux-dist-20041215.tar.gz
$cd uClinux-dist
$make xconfig

出现
make: wish:命令未找到

baidu.com......找到

在http://www.tcl.tk/software/tcltk/downloadnow85.html下载tk8.5a5   tcl8.5a5
按照提示编译安装就可以了,先编译安装tcl8.5a5,后安装tk8.5a5

#cd tk8.5a5
#cd unix
#./configure --prefix=/usr/
#make install
# ln /usr/bin/wish8.5 /usr/bin/wish
上面步骤是参考下面一篇文章的http://hi.baidu.com/zkheartboy/blog/item/b4fdff241e7d16014d088dd7.html

$make xconfig

选择
Vendor/Product: GDB/ARMulator
Kernel Version: linux-2.4.x
Libc Version: uC-libc
保存退出

$make dep
$make //我的乖乖,N长时间

make的时候可能出错,说找不到arm-linux-gcc,我在/usr/local/bin/下建立一个连接
#ln -s arm-elf-gcc arm-linux-gcc
这样就不用改动Makefile文件了

然后在image目录下生成linux和boot.rom两个文件,一个是内核文件,一个是文件系统

三、在SkyEye下运行

在uClinux-dist下建立skyeye.conf文件
内容如下:
  cpu: arm7tdmi
    mach: at91
    mem_bank: map=M, type=RW, addr=0x00000000, size=0x00004000
    mem_bank: map=M, type=RW, addr=0x01000000, size=0x00400000
    mem_bank: map=M, type=R, addr=0x01400000, size=0x00400000, file=images/romfs.img
    mem_bank: map=M, type=RW, addr=0x02000000, size=0x00400000
    mem_bank: map=M, type=RW, addr=0x02400000, size=0x00008000
    mem_bank: map=M, type=RW, addr=0x04000000, size=0x00400000
    mem_bank: map=I, type=RW, addr=0xf0000000, size=0x10000000
    lcd: state=on
保存,并在当前目录下执行
$../skyeye_1_2_2_Rel/binary/skyeye -e linux-2.4.x/linux

出现

arch: arm
cpu info: armv3, arm7tdmi, 41007700, fff8ff00, 0
mach info: name at91, mach_init addr 0x8056d50
uart_mod:0, desc_in:, desc_out:
SKYEYE: use arm7100 mmu ops
Loaded ROM   images/boot.rom
start addr is set to 0x01000000 by exec file.
Linux version 2.4.32-uc0 (root@localhost) (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/)) #1 2007年 04月 10日 星期二 15:02:15 CST
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... 15.82 BogoMIPS
Memory: 4MB = 4MB total
Memory: 2936KB available (884K code, 178K 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-1509BFF [VIRTUAL 1400000-1509BFF] (RO) <ROMFS>
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
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.
VFS: Mounted root (romfs filesystem) readonly.
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
Command: mount -t ext2 /dev/ram0 /var
Command: mkdir /var/tmp
Command: mkdir /var/log
Command: mkdir /var/run
Command: mkdir /var/lock
Command: mkdir /var/empty
Command: cat /etc/motd
Welcome to
          ____ _  _
         /  __| ||_|                
    _   _| |  | | _ ____  _   _  _  _
   | | | | |  | || |  _ \| | | |\ \/ /
   | |_| | |__| || | | | | |_| |/    \
   |  ___\____|_||_|_| |_|\____|\_/\_/
   | |
   |_|

GDB/ARMulator support by <[email protected]>
For further information check:
http://www.uclinux.org/

Execution Finished, Exiting

Sash command shell (version 1.1.1)
/>

成功,哈哈!!!

四、在SkyEye+uClinux下弄个应用程序先(helloworld)
添加应用程序的方法:
参照了
1)、按照正常的方式添加,需要进行以下几个方面的工作:
A、在user目录下建立个文件夹hello,并且把user目录下其他目录下的Makefile文件拷贝到hello目录下,修改红色字体部分,比如我选择的是lcd目录下的文件,如下:
EXEC = lcd -> hello
OBJS = lcd.o -> hello.o

CFLAGS += -I.

all: $(EXEC)

$(EXEC): $(OBJS)
    $(CC) $(LDFLAGS) -o $@ $(OBJS) $(LDLIBS)

romfs:
    $(ROMFSINST) /bin/$(EXEC)

clean:
    -rm -f $(EXEC) *.elf *.gdb *.o

新建一个hello.c文件
内容如下
#include <stdio.h>
int main(int argc, char *argv[])
{
    printf("Hello, World\n");
   return 0;
}

B、修改配置文件config/config.in
在最后面增加菜单: ######################################################################## mainmenu_option next_comment
comment 'User Application'
bool 'hello' CONFIG_USER_HELLO_HELLO
comment "User Application"
endmenu
########################################################################

或者在合适的菜单块中增加一行:
bool 'hello' CONFIG_USER_HELLO_HELLO
 

修改 ./config/Configure.help

在文件中增加:
CONFIG_USER_HELLO_HELLO This program print "hello,world" on screen.
注意描述文本必须缩进两空格,不能包括空行且必须少于70各字符

这个不是必须的,只要自己知道就可以了

C、修改用户程序工程管理文件
 在 ../user/Makefile 中,增加行

dir_$(CONFIG_USER_HELLO_HELLO)              += hello

增加了用户工程目录到待编译工程目录列表,一般按字母顺序插入。

D、编译并执行
 make xconfig
 make dep
 make lib_only
 make user_only
 make romfs
 make image
 make
 其中在make xconfig命令中必须选择定制应用程序,选中hello。

执行命令:

$ ../skyeye_1_2_2_Rel/binary/skyeye -e linux-2.4.x/linux

。。。

GDB/ARMulator support by <[email protected]>
For further information check:
http://www.uclinux.org/

Execution Finished, Exiting

Sash command shell (version 1.1.1)
/> cd bin
/bin> ./hello
Hello, World


2)、快速添加应用程序

单独编译,加到romfs目录下,在genromfs...

如下,这个我没有做,方法是参考网上资料的。

编译:

  arm-elf-gcc -Wall -O2 -Wl,-elf2flt -o hello hello.c
  生成的led是flat格式文件,可以在uClinux下直接运行。

复制到romfs 的bin目录,执行:

 genromfs -v -V "ROMdisk" -f romfs.img -d  。。。/romfs
 这里的文件系统映像romfs.img包含了新增的应用程序hello。

或者,make romfs也行。

我下次实验一下,晕,今天搞的头晕,开始用的是2007的版本,可是说binutils版本过低,重新下载了一个2.10.1版本的,虽然这个编译成功,但是到make的时候老是出错,只有重新下了2003版的,我的bras阿,学校只有2G的流量,这个月得精打细算了,嘿嘿:)

相关阅读 更多 +
排行榜 更多 +
奇境小镇MOD作弊菜单

奇境小镇MOD作弊菜单

角色扮演 下载
黑暗荒野2无限金币版

黑暗荒野2无限金币版

角色扮演 下载
骑战烈火之剑作弊菜单版

骑战烈火之剑作弊菜单版

角色扮演 下载