在QEMU硬件环境中启动 kernel 2.6 + busybox as rootfs

## 环境和软件版本
ubuntu 14.04 x86_64
compiler: codesourcery 2009q1 arm-none-linux-gnueabi- i686 [1]
kernel: linux 2.6.33
rootfs: busybox-1.16.0

## compile kernel 2.6.33
```shell
# under source code directory
$ make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- O=path/for/compilation versatile_defconfig
$ make menuconfig ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- O=path/for/compilation
`Kernel Features` => (Y) Use the ARM EABI to compile kernel
```

```shell
# under path/for/compilation directory
$ make -j9 ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- uImage -s
```

## compile busybox 1.16.0
```shell
# under source code directory
$ make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- defconfig
$ make ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- menuconfig
`Busybox Settings` -> `Build Options` -> `Build Busybox as a static binary (no shared libs)`
```

```shell
# under source code directory
$ make -j9 ARCH=arm CROSS_COMPILE=arm-none-linux-gnueabi- install
```
Results stay under directory `_install`.

```shell
# under _install/
$ mkdir proc sys dev etc etc/init.d
```
Create _install/etc/init.d/rcS with the following content
```txt
#!/bin/sh
mount -t proc none /proc
mount -t sysfs none /sys
/sbin/mdev -s
```
Add exec permission to rcS.
```shell
# under _install/etc/init.d/
$ chmod +x rcS
```

Create rootfs
```shell
# under _install/
$ find . | cpio -o --format=newc > ../rootfs.img
$ cd ../
$ gzip -c rootfs.img > rootfs.img.gz
$ file rootfs.img
$ file rootfs.img.gz
```

## launch Image on versatilepb board
```shell
# under qemu directory
$ ./qemu-system-arm -M versatilepb -m 128M -initrd path/to/rootfs.img.gz  -kernel path/to/zImage -append "root=/dev/ram rdinit=/sbin/init  console=ttyAMA0"  -nographic
```

Press `Enter` to enter ramfs.

详细内容请见[2]。


[1]: https://sourcery.mentor.com/public/gnu_toolchain/arm-none-linux-gnueabi/arm-2009q1-203-arm-none-linux-gnueabi-i686-pc-linux-gnu.tar.bz2

[2]: https://balau82.wordpress.com/2010/03/27/busybox-for-arm-on-qemu/

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值