一、过程和感想
* 花了很长时间在qemu虚拟的ubuntu上交叉编译编译ARM版的Linux
* 参考这篇文章
http://balau82.wordpress.com/2010/03/22/compiling-linux-kernel-for-qemu-arm-emulator/
在Windows上用CodeSourcery的免费的ARM GNU/Linux工具链(不是ARM EABI)编译静态链接的test程序
* 在Cygwin上用mkcramfs创建initrd(初始化RAM盘),发现怎么都运行不了。
花了很长时间才发现原因。
原来Cygwin的mkcramfs不能更改文件模式,因为Cygwin本身就无法执行chmod +x来增加执行权限。
用Linux则不会有这种问题(不知道可不可以改内核代码让操作系统无视可执行文件的模式?)
20110406:补注
如果要在Windows生成initrd文件,可以使用Linux源码树usr目录下的gen_init_cpio工具,附有源代码,可以在Cygwin下用gcc编译。gen_init_cpio根据一个列表文件生成cpio文件系统镜像(在Windows下用7zip可以打开),允许插入文件、目录,也允许指定文件和目录模式(不同于Cygwin下的mkcramfs)。但cpio不同于cramfs,它没有压缩数据。
* 发现很多东西在我的意料之外:
1) 编译Linux内核很慢。
2) 很多奇特的设置。
3) 原来文件系统可以用工具生成的。
4) 模拟器很诡异(可以用-append传参数给操作系统内核?)
5) Linux下静态链接libc原来是可以的!
6) CodeSourcery发布的几个工具链是不同的(我一直以为是一样)
7) 内核和控制台外壳原来是分开的?
二、串口输出(qemu把串口内容重定向到文件,所以没有截取到hello world字样)
命令行:
"D:\java\qemu-0.9.0-arm\qemu-system-arm" -L "D:\java\qemu-0.9.0-arm" -M versatilepb -m 128M -kernel zImage -initrd root5.img -append "root=/dev/ram rdinit=/test init=/test console=ttyAMA0" -serial file:test.txt
输出:
Linux version 2.6.35 (wmt@wmt-desktop) (gcc version 4.5.1 (Sourcery G++ Lite 2010.09-51) ) #1 Wed Mar 30 21:26:15 CST 2011
CPU: ARM926EJ-S [41069265] revision 5 (ARMv5TEJ), cr=00003137
CPU: VIVT data cache, VIVT instruction cache
Machine: ARM-Versatile PB
Memory policy: ECC disabled, Data cache writeback
Built 1 zonelists in Zone order, mobility grouping on. Total pages: 32512
Kernel command line: root=/dev/ram rdinit=/test init=/test console=ttyAMA0
PID hash table entries: 512 (order: -1, 2048 bytes)
Dentry cache hash table entries: 16384 (order: 4, 65536 bytes)
Inode-cache hash table entries: 8192 (order: 3, 32768 bytes)
Memory: 128MB = 128MB total
Memory: 126404k/126404k available, 4668k reserved, 0K highmem
Virtual kernel memory layout:
vector : 0xffff0000 - 0xffff1000 ( 4 kB)
fixmap : 0xfff00000 - 0xfffe0000 ( 896 kB)
DMA : 0xffc00000 - 0xffe00000 ( 2 MB)
vmalloc : 0xc8800000 - 0xd8000000 ( 248 MB)
lowmem : 0xc0000000 - 0xc8000000 ( 128 MB)
modules : 0xbf000000 - 0xc0000000 ( 16 MB)
.init : 0xc0008000 - 0xc0022000 ( 104 kB)
.text : 0xc0022000 - 0xc02cd000 (2732 kB)
.data : 0xc02e6000 - 0xc03017c0 ( 110 kB)
Hierarchical RCU implementation.
Verbose stalled-CPUs detection is disabled.
NR_IRQS:192
VIC @f1140000: id 0x00041190, vendor 0x41
Console: colour dummy device 80x30
Calibrating delay loop... 838.86 BogoMIPS (lpj=4194304)
pid_max: default: 32768 minimum: 301
Mount-cache hash table entries: 512
CPU: Testing write buffer coherency: ok
NET: Registered protocol family 16
Serial: AMBA PL011 UART driver
dev:f1: ttyAMA0 at MMIO 0x101f1000 (irq = 12) is a AMBA/PL011
console [ttyAMA0] enabled
dev:f2: ttyAMA1 at MMIO 0x101f2000 (irq = 13) is a AMBA/PL011
dev:f3: ttyAMA2 at MMIO 0x101f3000 (irq = 14) is a AMBA/PL011
fpga:09: ttyAMA3 at MMIO 0x10009000 (irq = 38) is a AMBA/PL011
bio: create slab <bio-0> at 0
Advanced Linux Sound Architecture Driver Version 1.0.23.
Switching to clocksource timer3
NET: Registered protocol family 2
IP route cache hash table entries: 1024 (order: 0, 4096 bytes)
TCP established hash table entries: 4096 (order: 3, 32768 bytes)
TCP bind hash table entries: 4096 (order: 2, 16384 bytes)
TCP: Hash tables configured (established 4096 bind 4096)
TCP reno registered
UDP hash table entries: 256 (order: 0, 4096 bytes)
UDP-Lite hash table entries: 256 (order: 0, 4096 bytes)
NET: Registered protocol family 1
RPC: Registered udp transport module.
RPC: Registered tcp transport module.
RPC: Registered tcp NFSv4.1 backchannel transport module.
Trying to unpack rootfs image as initramfs...
rootfs image is not initramfs (junk in compressed archive); looks like an initrd
Freeing initrd memory: 340K
NetWinder Floating Point Emulator V0.97 (double precision)
Installing knfsd (copyright (C) 1996 [email protected]).
JFFS2 version 2.2. (NAND) ? 2001-2006 Red Hat, Inc.
ROMFS MTD (C) 2007 Red Hat, Inc.
msgmni has been set to 247
Block layer SCSI generic (bsg) driver version 0.4 loaded (major 254)
io scheduler noop registered
io scheduler deadline registered
io scheduler cfq registered (default)
CLCD: unknown LCD panel ID 0x00001000, using VGA
CLCD: Versatile hardware, VGA display
Console: switching to colour frame buffer device 80x60
Serial: 8250/16550 driver, 4 ports, IRQ sharing enabled
brd: module loaded
smc91x.c: v1.1, sep 22 2004 by Nicolas Pitre <[email protected]>
eth0: SMC91C11xFD (rev 1) at c8800000 IRQ 25 [nowait]
eth0: Ethernet addr: 52:54:00:12:34:56
mice: PS/2 mouse device common for all mice
atkbd serio0: keyboard reset failed on fpga:06
atkbd serio1: keyboard reset failed on fpga:07
atkbd serio0: keyboard reset failed on fpga:06
atkbd serio1: keyboard reset failed on fpga:07
i2c /dev entries driver
ALSA device list:
No soundcards found.
TCP cubic registered
NET: Registered protocol family 17
VFP support v0.3: implementor 41 architecture 1 part 10 variant 9 rev 0
三、图形界面输出的效果图(qemu无法截取文字)
命令行:
"D:\java\qemu-0.9.0-arm\qemu-system-arm" -L "D:\java\qemu-0.9.0-arm" -M versatilepb -m 128M -kernel zImage -initrd root5.img -append "root=/dev/ram rdinit=/test init=/test"
输出: