1. 首先,编译 qemu代码:
git clone git://git.qemu.org/qemu.git
cd qemu/
./configure --target-list=arm-softmmu,mipsel-softmmu --enable-debug --enable-sdl
make
sudo make install
2. 编译 linux kernel:
wget http://www.kernel.org/pub/linux/kernel/v3.0/linux-3.2.tar.bz2
tar xjf linux-3.2.tar.bz2
export ARCH=arm
export CROSS_COMPILE=arm-linux-gnueabi-
cd linux-3.2
make vexpress_defconfig
make all
3. 创建 ramdisk
先创建一个目录 init, 在init下编写一个小程序init.c,打印 hello, world.
#include <stdio.h>
void main() {
printf("Hello World!\n");
while(1);
}
然后,生成 ramdisk:
cd init
arm-linux-gnueabi-gcc -static <strong><span style="color:#ff0000;">init.c -o init</span></strong>
e<strong>cho init|cpio -o --format=newc > initramfs</strong>
5. 测试:
qemu-system-arm -M vexpress-a9 -kernel ./linux-3.2/arch/arm/boot/zImage -initrd ./init/initramfs -serial stdio -append “console=ttyAMA0″
参考:
http://balau82.wordpress.com/2012/03/31/compile-linux-kernel-3-2-for-arm-and-emulate-with-qemu/