Raspberry Pi Releases 1st SD Card Image (Debian) – How-to use it in QEMU

The Raspberry Pi Foundation has just released the first SD Card Image that you will be able to use with your Raspberry Pi board. This image is based on Debian Squeeze (6.0) and comes with  LXDE user interface and Midori browser, development tools, and sample code for accessing the multimedia functionality on the device.

You can download it using BitTorrent: debian6-17-02-2012.zip.torrent (preferred method) or via one of the many http mirrors available on RPi Community page.

This image contains all necessary files including the binary blob and closed source libraries, the kernel and the root file systems.

If you want to to prepare an SD Card with this image simply use dd in Linux:

unzip debian6-17-02-2012.zip
sudo dd if=debian6-17-02-2012/debian6-17-02-2012.img of={sd_card_path}

where sd_card_path is the device pointing to you SD Card (e.g. /dev/sdc). Make sure you use the correct device (e.g. with fdisk -l) or you may wipeout your hard drive with this command.

Since most of us (including myself), don’t have a Raspberry Pi board just yet, we can still run the rootfs of this image in qemu.

First we need to extract the root file system from the SD card image.  We can analyse the SD Card image with the file utility to find the rootfs partition.

#file debian6-17-02-2012/debian6-17-02-2012.img

debian6-17-02-2012/debian6-17-02-2012.img: x86 boot sector; partition 1: ID=0xc, starthead 0, startsector 2048, 153600 sectors; partition 2: ID=0x83, starthead 3, startsector 157696, 3256320 sectors; partition 3: ID=0x82, starthead 3, startsector 3416064, 391168 sectors, code offset 0xb8

This tool shows the SD image image contains three partitions:

  • FAT 32 Partition – with the GPU binary blob and relevant libraries, the kernel image and some configuration files
  • EXT-4 Partition – with the Debian rootfs (that’s what we want)
  • Swap Partition – ~200 MB swap partition (Virtual memory)

We can now extract the Debian rootfs using dd and the offset (startsector) and size returned the the file utility.

dd if=debian6-17-02-2012/debian6-17-02-2012.img of=rootfs_debian6_rpi.ext4 skip=157696 count=3256320

Good! We’ve got our rootfs. It contains some modules compiled against linux kernel 3.1.9, so we need to compile an ARM11 kernel 3.1.9 for qemu by following the instructions given at http://www.cnx-software.com/2011/10/18/raspberry-pi-emulator-in-ubuntu-with-qemu/, replacing kernel 3.0.4 by 3.1.9 AND enabling ext-4 with make menuconfig.

Once the build is complete copy linux-3.1.9/arch/arm/boot/zImage to zImage_3.1.9.

If you don’t want to experience the joy of building the kernel yourself, you can download the binary: http://dl.dropbox.com/u/45842273/zImage_3.1.9

We can now start the virtual machine with R-Pi Debian rootfs and our updated kernel:

qemu-system-arm -M versatilepb -cpu arm1176 -m 256 -hda rootfs_debian6_rpi.ext4 -kernel zImage_3.1.9 -append "root=/dev/sda" -serial stdio -redir tcp:2222::22

During the system boot, there will be lots of error (like the GPU driver can’t find the GPU…) but you can still reach the login screen. The username/password: pi/suse.

[Update: An error (assertion in arp_table.c) with qemu occurs with many people. You may need to add “-net none” to make it work.  The problem seems somewhat random, some people also had success after downgrading or upgrading qemu).]

You’ll then have access to the command line. LXDE does not start automatically, you need to run:

startx

and after a short while you should see LXDE desktop

QEMU Runs Debian Squeeze LXDE Image
Raspberry Pi Debian LXDE in QEMU

Update: Since some of you have problems, here’s the detail of my setup: Debian Squeeze 6.0.4, Qemu 1.0 running in a Virtual Machine in Virtual Box 4.1.6

You may also wonder what’s inside the FAT partition. Let’s extract it, mount it and list the files:

dd if=./mnt2/debian6-17-02-2012.img of=rpi.fat skip=2048 count=153600
sudo mount -o loop rpi.fat mnt
$ ls -l mnt
total 28072
-rwxr-xr-x 1 root root  2001244 Feb 17 19:02 arm128_start.elf
-rwxr-xr-x 1 root root  2001244 Feb 17 19:02 arm192_start.elf
-rwxr-xr-x 1 root root  2001244 Feb 17 19:02 arm224_start.elf
-rwxr-xr-x 1 root root    16528 Feb 14 01:53 bootcode.bin
-rwxr-xr-x 1 root root      141 Feb 15 01:38 cmdline_testmode.txt
-rwxr-xr-x 1 root root      127 Feb 15 01:52 cmdline.txt
-rwxr-xr-x 1 root root 16412020 Feb 15 01:47 kernel_emergency.img
-rwxr-xr-x 1 root root  3990020 Feb 14 01:53 kernel.img
-rwxr-xr-x 1 root root   314691 Feb 14 01:53 loader.bin
-rwxr-xr-x 1 root root  2001244 Feb 17 19:02 start.elf
sudo umount mnt

start.elf is the GPU binary blob, bootcode.bin / loader.bin are the first files the GPU looks for when booting (I assume), kernel.img is the kernel image and cmdline.txt the configuration file.

There are 3 other binary blob files that can be used to replace start.elf:

  • arm128_start.elf – 128 MB for Linux and the rest (128 MB) for the GPU. To be used for application where the GPU requires a lot of memory (e.g. XBMC)
  • arm192_start.elf – 192 MB for Linux and the rest (64 MB) for the GPU. To be used for application where the GPU requires a moderate amount of memory.
  • arm224_start.elf – 224 MB for Linux and the rest (32 MB) for the GPU. To be used for application where the GPU is not used (for graphics tasks) such as a headless server. The GPU still needs some memory has it performs some other tasks internally.
Support CNX Software - Donate via PayPal or cryptocurrencies, become a Patron on Patreon, or buy review samples
Subscribe
Notify of
guest
61 Comments
oldest
newest most voted
Advertisements