Qemu

From GumstixWiki

Contents

Compile Qemu

To run the build image in a Qemu virtual machine you will first need to download and compile (or otherwise install) a copy of Qemu. See the gumstix wiki page on Qemu for instructions.

Create the VM Image

We used the following script to create a working image for the VM. This is known to work before revision 1326, for a workaround and (possibly) updated instrcutions, see this mailing list post.

IMAGE=flash
BUILDROOT_DIR=.
dd of=$IMAGE bs=1k count=16k if=/dev/zero
dd of=$IMAGE bs=1k conv=notrunc if="$BUILDROOT_DIR"/u-boot.bin;
dd of=$IMAGE bs=1k conv=notrunc seek=256 if="$BUILDROOT_DIR"/rootfs.arm_nofpu.jffs2;

The dd command first creates a file full zeroes, 16000 blocks of 1k size long. Then it places u-boot at the top of the image, and moves 256 blocks before copying in the filesystem image.

Start the VM

The following will start Qemu and run the image created. In recent versions of Qemu it will run the VM behind a virtual NAT, so the VM will have access to outside, but due to the nature of NAT, incoming connections do not connect. File transfer via outgoing SCP functions correctly as expected.

qemu-system-arm -M gumstix -hda flash -nographic

If you need to debug web applications or other services requiring incoming connections, you can create a virtual network with the tap package (which you will need to install on your host machine). Note that unless you run DHCP on this tap network from your host pc, you will need to set the IP of your guest machine (the VM) manually before attempting incoming connections from the host machine. Also, using tap will require root privileges on the host machine.

qemu-system-arm -M gumstix -hda flash -nographic -net nic,vlan=0 -net tap,vlan=0,ifname=tap0

Exit the VM

  • Control-a then h

Prints some magic keys you can use from inside the emulator.

  • Control-a then x

Exits the VM.