Ubuntu 16.04: Build buildroot and run QEMU

This article will describe building buildroot and running it on QEMU.


1 Download buildroot

Download buildroot 2016.02 released version.

$ wget https://buildroot.org/downloads/buildroot-2016.02.tar.bz2

You can download also git repository's one.

$ git clone https://git.busybox.net/buildroot/

2 Build buildroot

Use qemu_x86_defconfig for qemu-system-i386. Change tty1 to ttyS0 for using QEMU nographic option.

$ tar jxf buildroot-2016.02.tar.bz2
$ cd buildroot-2016.02/
$ make qemu_x86_defconfig
$ sed -i -e 's/BR2_TARGET_GENERIC_GETTY_PORT="tty1"/BR2_TARGET_GENERIC_GETTY_PORT="ttyS0"/g' .config
$ make

3 Run QEMU

Install qemu-system-i386 with apt.

$ sudo apt-get install -y qemu-system-i386

Run QEMU with kernel output/images/bzImage and rootfs output/images/rootfs.ext2.

$ qemu-system-i386 --kernel output/images/bzImage \
--hda output/images/rootfs.ext2 --nographic \
--append "console=tty1 root=/dev/sda"
WARNING: Image format was not specified for
'output/images/rootfs.ext2' and probing guessed raw.
         Automatically detecting the format is dangerous for raw
images, write operations on block 0 will be restricted.
         Specify the 'raw' format explicitly to remove the
Linux version 4.4.1 (hiroom2@ubuntu-16) (gcc version 4.9.3 (Buildroot
2016.02) ) #1 SMP Tue May 10 08:23:43 JST 2016
x86/fpu: Legacy x87 FPU detected.
x86/fpu: Using 'lazy' FPU context switches.
e820: BIOS-provided physical RAM map:
BIOS-e820: [mem 0x0000000000000000-0x000000000009fbff] usable
BIOS-e820: [mem 0x000000000009fc00-0x000000000009ffff] reserved
Welcome to Buildroot
buildroot login: root