Tag Archives: qemu

Raspberry Pi Emulator on Ubuntu 12.04 LTS

You have two options:

  1. Use a Ubuntu Desktop version with Gnome environment already preinstalled (do you really need all that crap?!)
  2. Install a brand new Ubuntu server 12.04 x64 LTS, basic, without Gnome or any super fancy packages… just a basic installation with SSH (suggested but not required). And after, just follow the post here to install a “Minimal X server”.If you want to change a bit the look of the login screen, you can have a look to this post.
    This is what I’ve done 🙂

Please note that a graphic environment is REQUIRED for this emulator to work.

Compile and install QEMU

Packages:

Working directory:

It will take a while

Once done:

Read the output carefully (options of interest highlighted):

NOTE: The object files are built at the place where configure is launched

Easiest way:

Then, compile and install:

Check that all is fine:

The output should contain ‘arm1176‘. If all is good, go to the next steps. 😉

 

Create the emulation environment

Get the linux kernel:

Download a raw image of Raspberry Pi from here and save in the same folder

If you want to play a bit with it, you might need to pre-expand the file size, in order to have some extra space (by default you have only 200 Mb free on the current image).
For this, you can use the following commands, to add 2GB to the image:

Then, launch your qemu, and inside the console, try to useraspi-config script to automatically expand the filesystem.
Otherwise, try the following to do it manually (not tested):

Then reboot and launch resize2fs /dev/root
Now, you’re ready for the first boot.
Create a script called first_boot.sh with the following:

Remember to setchmod +xto this file and do not try to use more than 256 MB of RAM, the value is hard-coded in and QEMU will not work correctly.

After you can easily use this syntax to start your image:

Comment the line/usr/lib/arm-linux-gnueabihf/libcofi_rpi.soin the file/etc/ld.so.preloadand reboot.
Alternatively create a file/etc/udev/rules.d/90-qemu.ruleswith the following content:

The kernel sees the disk as /dev/sda, while a real pi sees /dev/mmcblk0. This will create symlinks to be more consistent with the real pi.

Once done, you can create a new script called start.sh with the following content:

And now, finally, we can run our image of Raspberry Pi running:

NOTE: use first_boot.sh script ONLY with a brand new image. If you’re using a copy of your Pi, maybe made using dd command, just use start.sh script.

Sources:

http://xecdesign.com/compiling-qemu/
http://xecdesign.com/qemu-emulating-raspberry-pi-the-easy-way/