2007年11月14日星期三

用skyeye模拟运行uclinux


1,安装uclinux和其工具链arm-elf-tools,编译uclinux
安装uclinux和其工具链,编译uclinux的过程完全按照Getting Familiar with uClinux/ARM 2.6(http://opensrc.sec.samsung.com/document/Getting_Familiar_with_uClinuxARM2_6.html)(http://www.21ic.com/news/n6708c79.aspx 中文),版本等都是用的一样的。需要注意的是安装arm-elf-tools-20040427.sh时,会出现错误,用如下方法:
用vi 打开arm-elf-tools-20040427.sh
这是由于脚本中的tail没写对,必须加一个 -n 参数。
将第39行的代码:
tail +${SKIP} ${SCRIPT} | gunzip | tar xvf -
改成如下:
tail -n +${SKIP} ${SCRIPT} | gunzip | tar xvf -
再有就是注意,解压文件等时不要用root账户,只有在安装的时候su到root账户,否则在普通账户下编译会出现很多错误,因为使用root账户解压的是属于root的文件,普通账户没有权限。


2,安装skyeye最新版本skyeye_1_2_3_Rel.tar.bz2(www.skyeye.org)
按照安装说明,编译在binary下生成二进制文件skyeye,此文件便是可执行文件,把该文件的目录地址加入到环境变量PATH里,方法是用户在家目录下的.bashrc 中加入一行
export PATH=$PATH:DIR
或者直接添加链接
ln -s DIR/skyeye /usr/local/bin/skyeye
而/usr/local/bin路径必须存在于PATH环境变量里。
DIR为skyeye的目录路径。


3,模拟运行uclinux


创建skyeye的配置文件:
cpu: arm7tdmi
mach: at91
mem_bank: map=M, type=RW, addr=0x00000000, size=0x00004000
mem_bank: map=M, type=RW, addr=0x01000000, size=0x00300000
mem_bank: map=M, type=RW, addr=0x01300000, size=0x00100000, file=./romfs.img
mem_bank: map=M, type=R, addr=0x01400000, size=0x00400000
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


注意因为在编译uclinux时,传递给内核的命令参数为"root=/dev/ram0 initrd=0x01300000,800K keepinitrd "
表示initrd的位置在0x01300000处,所以file=./romfs.img要放到0x01300000地址处,而且root=/dev/ram0,因为如果使用initrd,
默认的initrd就是/dev/ram0,所以意思就是initrd就挂载为最终的根文件系统。
注:initrd详细的解释见uclinux-dist/document/initrd.txt


这样就可以了:


[yu@yu-MagicLinux skyeye]$ ./run
big_endian is false.
arch: arm
cpu info: armv3, arm7tdmi, 41007700, fff8ff00, 0
mach info: name at91, mach_init addr 0x8063a70
uart_mod:0, desc_in:, desc_out:, converter:
SKYEYE: use arm7100 mmu ops
Loaded RAM ./boot.rom
exec file "../uClinux-dist/linux-2.6.x/linux"'s format is elf32-little.
load section .init: addr = 0x01000000 size = 0x0000b000.
load section .text: addr = 0x0100b000 size = 0x000a17b8.
load section __ex_table: addr = 0x010ac7c0 size = 0x000006f8.
not load section __ksymtab: addr = 0x010aceb8 size = 0x00000000 .
not load section __ksymtab_gpl: addr = 0x010aceb8 size = 0x00000000 .
not load section __kcrctab: addr = 0x010aceb8 size = 0x00000000 .
not load section __kcrctab_gpl: addr = 0x010aceb8 size = 0x00000000 .
load section .data: addr = 0x010ae000 size = 0x00008ef8.
not load section .bss: addr = 0x010b6f00 size = 0x0000beb8 .
not load section .debug_abbrev: addr = 0x00000000 size = 0x0002dd8a .
not load section .debug_info: addr = 0x00000000 size = 0x00c904b6 .
not load section .debug_line: addr = 0x00000000 size = 0x0012a62f .
not load section .debug_pubnames: addr = 0x00000000 size = 0x0000a05a .
not load section .debug_aranges: addr = 0x00000000 size = 0x00001f08 .
start addr is set to 0x01000000 by exec file.
Linux version 2.6.5-hsc1 (yu@yu-MagicLinux) (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/)) #4 Fri Nov 9 12:17:37 CST 2007
CPU: Atmel-AT91M40xxx [14000040] revision 0 (ARMvundefined/unknown)
Machine: ATMEL EB01
On node 0 totalpages: 1024
DMA zone: 0 pages, LIFO batch:1
Normal zone: 1024 pages, LIFO batch:1
HighMem zone: 0 pages, LIFO batch:1
Built 1 zonelists
Kernel command line: root=/dev/ram0 initrd=0x01300000,800K keepinitrd
PID hash table entries: 32 (order 5: 256 bytes)
Memory: 4MB = 4MB total
Memory: 2448KB available (645K code, 89K data, 44K init)
Calibrating delay loop... 15.87 BogoMIPS
Dentry cache hash table entries: 1024 (order: 0, 4096 bytes)
Inode-cache hash table entries: 1024 (order: 0, 4096 bytes)
Mount-cache hash table entries: 512 (order: 0, 4096 bytes)
checking if image is initramfs...it isn't (ungzip failed); looks like an initrd
POSIX conformance testing by UNIFIX
Linux NoNET1.0 for Linux 2.6
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
RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize
loop: loaded (max 8 devices)
RAMDISK: romfs filesystem found at block 0
RAMDISK: Loading 771 blocks [1 disk] into ram disk... done.
VFS: Mounted root (romfs filesystem) readonly.
Freeing init memory: 44K
Shell invoked to run file: /etc/rc
Command: hostname GDB-ARMulator
Command: /bin/expand /etc/ramfs.img /dev/ram1
Command: mount -t proc proc /proc
Command: mount -t ext2 /dev/ram1 /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 <davidm@snapgear.com>
For further information check:
http://www.uclinux.org/


Execution Finished, Exiting


Sash command shell (version 1.1.1)
/>
Sash command shell (version 1.1.1)
/>





Technorati :

没有评论: