在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/

猜你喜欢

转载自blog.csdn.net/mozart_cai/article/details/80090089
今日推荐