Step-by-step Using qemu to Boot an Emulated Odroid
THIS IS A WORK IN PROGRESS -- PLEASE DON"T EDIT. You can comment using the discussion page
This tutorial is for Linux Developers using Linux hosts. It is really not for Windows hosts -- although you can certainly work through this tutorial on a virtual machine guest.
It was tested on a "clean" Debian 6 machine, a VMWare virtual machine. You can find your own copy here: Debian6t VM VMWare Player is free as well: VMWare Player
Contents
Introduction
If you don't know what qemu is for, look around on Wikipedia.
Is it good for everything? No. Is a hammer good for sawing? Not so much. Consider qemu as another tool for your toolchest.
If you need to develop code for a platform that is not yet available, qemu might help. Also, if you are doing certain kernel work, it can be handy.
Generally, your root file system doesn't care which kernel you use. This tutorial uses a kernel configured for a vexpress-a9 platform (TBD. check that exact name). You can boot root file systems meant for odroid without changes.
It is possible to allocate a large amount of RAM to the emulated machine, and it is possible, but not necessarily faster to emulate multiple cores.
Prerequisites
Overview
We are going to:
Host Setup
Make sure you have the neccessary programs installed
# update the list of available packages # as root: apt-get update sudo apt-get install libpixman-1-dev zlib1g-dev libglib2.0-dev shtool
Download Example Files
You can use your browser, or use web get to get the example files tarball.
#Create a working folder, and move into it. mkdir odroidu2 cd odroidu2/ # Get the example files wget http://odroid.us/odroid/users/osterluk/qemu-example.tgz
Here are the files we now have:
Check for any Existing Qemu
See if you already have qemu installed:
qemu-system-arm --version
QEMU PC emulator version 0.12.5 (Debian 0.12.5+dfsg-3squeeze1), Copyright (c) 2003-2008 Fabrice Bellard
See if the cortex-a9 is supported:
qemu-system-arm -cpu ? | grep cortex-a9
cortex-a9
OK, we at least have the required CPU. Now check the machine type:
qemu-system-arm -M ? | grep vexpress-a9
Did not find a match, we need a newer build of qemu -- and we need to build it from source. First, we need to install some dependant packages
sudo apt-get install libpixman-1-dev zlib1g-dev libglib2.0-dev shtool
Building Qemu
Go to http://wiki.qemu.org/Download and download qemu-1.4.0.tar.bz2
Download the source and expand it:
cd $HOME mkdir qemu-build cd qemu-build # copy the source from the directory you downloaded it to cp /tmp/qemu-1.4.0.tar.bz2 . bunzip2 qemu-1.4.0.tar.bz2 tar -xvf qemu-1.4.0.tar
Now configure qemu and build it
cd $HOME/qemu-build/qemu-1.4.0 ./configure make sudo make install
Check the version to see if we are properly installed:
qemu-1.4.0$ qemu-system-arm --version
QEMU emulator version 1.4.0, Copyright (c) 2003-2008 Fabrice Bellard
OK. Make sure our machine is included:
qemu-system-arm -M ? | grep vexpress
vexpress-a9 ARM Versatile Express for Cortex-A9 vexpress-a15 ARM Versatile Express for Cortex-A15
Nice. There <could> be a machine built for odroid, but so far I haven't heard of one. There is a project going on to build a machine for Rasperry Pi that can run unmodified kernels.
We are done with the build files. They can be deleted.
Create Root File System Partition Image
Yes, there is a distinction between a partition image and a tarball of the partition contents. The kernel will want to mount a filesystem. It doesn't know how to mount just a tarball.
All we need is a small amount of space to hold the buildroot/busybox root file system. 200M is OK. You can change this as needed, of course.
qemu-img create rootfs-buildroot.ext2 200M
Formating 'rootfs-buildroot.ext2', fmt=raw, size=204800 kB
mkfs.ext3 rootfs-buildroot.ext2
mke2fs 1.41.12 (17-May-2010) rootfs-buildroot.ext2 is not a block special device. Proceed anyway? (y,n) y Filesystem label= OS type: Linux Block size=1024 (log=0) Fragment size=1024 (log=0) Stride=0 blocks, Stripe width=0 blocks 51200 inodes, 204800 blocks 10240 blocks (5.00%) reserved for the super user First data block=1 Maximum filesystem blocks=67371008 25 block groups 8192 blocks per group, 8192 fragments per group 2048 inodes per group Superblock backups stored on blocks: 8193, 24577, 40961, 57345, 73729
Writing inode tables: done Writing superblocks and filesystem accounting information: done
Now loop mount the partition image file
mkdir mnt sudo mount -o loop rootfs-buildroot.ext2 mnt
And expand the root file system image tarball into it
cd mnt sudo tar -xvzf ../rootfs.tar.gz # take a look around, if you like ls cd ../ sudo umount ./mnt
launch-no-bridge
Now try the simplest thing. Launch without setting up a network bridge. Here is a simple script to make things easier:
#! /bin/sh # filename: launch-no-bridge # Set environment variables to make it easier to change export ROOTFS=rootfs-buildroot.ext2 export NETWORK="-net nic -net user" export KERNEL="-kernel zImage " qemu-system-arm -append "root=/dev/mmcblk0 rw physmap.enabled=0 console=ttyAMA0" -M vexpress-a9 $KERNEL -sd $ROOTFS $NETWORK -nographic
Launch it like this:
./launch-no-bridge