在QEMU硬體環境中啟動 kernel 2.6 + busybox as rootfs

來源:互聯網
上載者:User
## 環境和軟體版本
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/

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.