CentOS 7: Build Yocto and run QEMU

This article will describe building Yocto and running QEMU.

 

1 System environment

This article uses virtual machine as below.

 

CPU core number 1
RAM 1GB
スワップ 1GB
ストレージ 80GB

 

2 Install package for building Yocto

Install package according to Yocto QuickStart.

$ sudo yum install gawk make wget tar bzip2 gzip python unzip perl patch \
iffutils diffstat git cpp gcc gcc-c++ glibc-devel texinfochrpath socat \
perl-Data-Dumper perl-Text-ParseWords perl-Thread-Queue SDL-devel xterm

3 Download poky

Download poky which is build tools for Yocto.

$ git clone http://git.yoctoproject.org/git/poky

4 Run oe-init-build-env

Run oe-init-build-env which will set PATH to build tools and create build directory.

$ cd poky
$ . oe-init-build-env

5 conf/local.conf

A conf/local.conf defines CPU architecture, build thread number and make -j option number. This article use default local.conf which defines qemux86 as CPU architecture.

$ emacs conf/local.conf

 

BB_NUMBER_THREADS Build thread number
PARALLEL_MAKE make -j option number
MACHINE CPU architecture

 

6 Build Yocto with core-image-minimal

A core-image-minimal is recipe for building minimal rootfs without X-window package.

$ bitbake core-image-minimal
WARNING: Host distribution "Ubuntu-16.04" has not been validated with
this version of the build system; you may possibly experience
unexpected failures. It is recommended that you use a tested distribution.

It takes 3 hours to build core-image-minimal on this system environment.

A size of build directory is about 20GB. If you use core-image-sato for building rootfs with X-window application, a size of build directory will be about 30G.

7 Run QEMU

After running oe-init-build-env, runqemu command can be used.

This article adds noapic to kernel parameter for error of initialization APIC on this system.

$ runqemu qemux86 nographic bootparams="noapic"

Continuing with the following parameters:
KERNEL: [/home/hiroom2/poky/build/tmp/deploy/images/qemux86/bzImage-qemux86.bin]
ROOTFS: [/home/hiroom2/poky/build/tmp/deploy/images/qemux86/core-image-minimal-qemux86-20160527160149.rootfs.ext4]
FSTYPE: [ext4]
Acquiring lockfile for tap0...
Setting up tap interface under sudo
Acquiring lockfile for tap1...
-net nic,model=virtio -net tap,vlan=0,ifname=tap1,script=no,downscript=no -cpu qemu32 -drive file=/home/hiroom2/poky/build/tmp/deploy/images/qemux86/core-image-minimal-qemux86-20160527160149.rootfs.ext4,if=virtio,format=raw -show-cursor -usb -usbdevice tablet -vga vmware   -nographic  -m 256
Running qemu-system-i386...
/home/hiroom2/poky/build/tmp/sysroots/x86_64-linux/usr/bin/qemu-system-i386 -kernel /home/hiroom2/poky/build/tmp/deploy/images/qemux86/bzImage-qemux86.bin -net nic,model=virtio -net tap,vlan=0,ifname=tap1,script=no,downscript=no -cpu qemu32 -drive file=/home/hiroom2/poky/build/tmp/deploy/images/qemux86/core-image-minimal-qemux86-20160527160149.rootfs.ext4,if=virtio,format=raw -show-cursor -usb -usbdevice tablet -vga vmware -no-reboot -nographic -m 256 -serial mon:stdio -serial null -append "vga=0 uvesafb.mode_option=640x480-32 root=/dev/vda rw mem=256M ip=192.168.7.4::192.168.7.3:255.255.255.0 oprofile.timer=1 rootfstype=ext4 console=ttyS0 noapic"
Initializing cgroup subsys cpuset
Initializing cgroup subsys cpu
Initializing cgroup subsys cpuacct
Linux version 4.4.11-yocto-standard (hiroom2@centos-7) (gcc version 5.3.0 (GCC) ) #1 SMP PREEMPT Sat May 28 04:26:09 JST 2016
<snip>
Poky (Yocto Project Reference Distro) 2.1+snapshot-20160527 qemux86 /dev/ttyS0

qemux86 login: root
root@qemux86:~#