Tuesday, July 21, 2015

QEMU image for developing and testing applications

The aim of this post is to create a QEMU toolchain and image for developing and testing applications and complex network architectures.

This image will be used as a starting point in the next tutorials.



The configuration and the environment will  be the same we used to create a Raspberry PI image, as described here: http://mytechpg.blogspot.it/2013/06/raspberrypi-and-yocto.html

Preparing the environment

You have to repeat "Configuring the host" and "Preparing the environemnt" from the Raspberry PI tutorial.

Configuring and building Yocto

Then  you have to create your build directory and configure the system to build a Yocto image for a QEMU emulator with the command:

source oe-init-build-env qemu
source oe-init-build-env qemuarm


The development system will be created into the qemu directory. If you want, you can chose another name for this directory. You have to repeat this command every time you use a new shell (e.g. after a reboot), to reconfigure the build environment.

At the end of the execution, oe-init-build-env leaves you inside the qemu directory.

As configuration files, local.conf and bblayers.conf (located in the conf directory) you can use the one prepared for Raspberry PI.
You have only to edit local.conf your architecture; for x86:
  • MACHINE ?= "qemux86" 
And for ARM:
  • MACHINE ?= "qemuarm" 
You can download my config files from GtiHub (the default configuration is for qemuarm).

Now you can build the image with the command

bitbake core-image-full-cmdline

Testing the QEMU image

You can launch you image with the command:

runqemu qemux86

or 


runqemu qemuarm

QEMU x86 testing

In the shell you can read the kernel and the rootfs used by the emulator:

Continuing with the following parameters:
KERNEL: [/area/devel/yocto/poky/qemu/tmp/deploy/images/qemux86/bzImage-qemux86.bin]
ROOTFS: [/area/devel/yocto/poky/qemu/tmp/deploy/images/qemux86/core-image-full-cmdline-qemux86-20150629181504.rootfs.ext4]
FSTYPE: [ext4]

Then, you have to put your password to configure the tap interface (it requires root privilges). The tap interface is used to simulated an Ethernet connection between your host and the emulator.

By default a new shell will be opened with your Yocto. You can login with user root, without password.
If you can't open a new windows with qemu emulator, you can use nographic option:

runqemu nographic qemux86


to exit from qemu you can simply use halt command.

The local IP address (assigned to the tap interface) is 192.168.7.1/24. You can check it with the command ip a.
The IP assigned to the qemu image is 192.168.7.2/24.

You can use ssh client to connect to the qemi image with the command:

ssh root@192.168.7.2


No comments:

Post a Comment