Raspberry Pi Emulator in Ubuntu with Qemu

The Raspberry Pi board is a low cost board based on Broadcom BCM2835 media processor SoC with an ARM1176JZF-S core clocked at 700MHz. This board is currently under development and should be ready by end of November, beginning of December and will be sold for 25 USD (128MB RAM – no Ethernet) and 35 USD (256MB RAM – Ethernet).

While we are waiting for the board, we can still test software using qemu to emulate a board based on an ARM1176 core with 128MB or 256 MB memory.

I’ve tried to create a rootfs based on Ubuntu with rootstock but this only support processors with ARM cortex A8 and greater, so it would not work with ARM11. I’ll be using Debian Squeeze instead.

Prerequisites

My host computer is running Ubuntu 10.04.3 LTS, but any recent Ubuntu or Debian installation should work with these instructions. [Update: You won’t be able to install qemu-linaro in Debian.  [Update in update: Apparently in the latest version of Debian Squeeze, you can just install the default qemu image: apt-get install qemu-system. The build instructions below are for reference in case you use a distro with an older qemu]

You need to cross-compile qemu as follows:


This also seems much faster than Linaro Qemu.]

I’m using qemu-linaro, here’s how to install it:


Here’s the version I use for reference:

Building the kernel for ARM11

I will basically follow the very clear instructions given at http://raspi.springnote.com/pages/8234994 with some slight modifications. I’ll skip some explanations so refer to the link above to understand exactly what you are doing.

First create a working direcory:


Download the latest  Sourcery G++ Lite IA32 GNU/Linux TAR package for EABI to your working directory and extract it:


Download, extract and patch the kernel for ARMv6 support:


Configure the kernel:


Specify the cross-compiler:


In my case I entered “/home/jaufranc/edev/raspberry-pi/arm-2011.03/bin/arm-none-eabi-“.

Select the right CPU options:


Enable ARM EABI:


Enable qemu’s disk support:


Enable devtmpfs:


Enable tmpfs:


Enable the event interface:


Exit and save the configuration.

Now compile the kernel:

Generating ARMEL Debian Squeeze Rootfs

The kernel build will take a while, so in the meantine you can open another terminal window and prepare the rootfs.

Create an empty rootfs directory and retrieve an armel rootfs for Debian Squeeze:


Once the kernel above is built and debootsrap has completed install the kernel modules in the rootfs:


The first stage of the rootfs is complete. You’ll notice some important script (e.g. inittab) are missing at this point, but this is normal.

Now let’s create an empty ext2 rootfs (3GB) and copy the rootfs we’ve just created to it:


To complete the rootfs, we’ll need to copy the kernel image the working directory and run qemu as follows:


Once you have access to the command line, mount the proc filesystem and complete the bootstrapping process:


The final steps are to enable the network, give a hostname and create a temporary root password:


That’s it your system is now ready.

You can stop qemu and restart it as follows:


Login as root with your temporary password and you should be asked to change it. After you have access to the command line and can check the CPU details with cat /proc/cpuinfo

Raspberry Pi Emulator Window

You can compile your own program using the cross-toolchain installed above

For those who want to skip the steps to build the kernel and generate the rootfs and just want to run qemu, I’ve uploaded the binary files:

After you download rootfs.ext2.gz you’ll need to unzip it first:


The root password is raspberry for the rootfs above.

If you want to install armel binaries using apt-get like you would do on a PC distribution, edit /etc/apt/sources.list as follows:


and run:


Sources:

Support CNX Software - Donate via PayPal or cryptocurrencies, become a Patron on Patreon, or buy review samples
Advertisements
Subscribe
Notify of
guest
52 Comments
oldest
newest most voted
Advertisements