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.
Share this:

Support CNX Software! Donate via cryptocurrencies, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress

ROCK Pi 4C Plus
Subscribe
Notify of
guest
The comment form collects your name, email and content to allow us keep track of the comments placed on the website. Please read and accept our website Terms and Privacy Policy to post a comment.
61 Comments
oldest
newest
ja
ja
12 years ago

You unpack the rootfs to file named “debian6_rootfs.ext2” and then use file “rootfs_debian6_rpi.ext4” as rootfs for qemu. Is it just different name or these are different files?

itsme
itsme
12 years ago

(note there is a little typo rootfs_debian_rpi.ext4 and rootfs_debian6_rpi.ext4) I follow the istructions but here the error i got: vlad@debian:~/Downloads/debian6-17-02-2012$ qemu-system-arm -M versatilepb -cpu arm1176 -m 256 -hda rootfs_debian_rpi.ext4 -kernel zImage_3.1.9 -append “root=/dev/sda” -serial stdio -redir tcp:2222::22 Uncompressing Linux… done, booting the kernel. qemu-system-arm: /build/qemu-dWylvc/qemu-1.0+dfsg/slirp/arp_table.c:41: arp_table_add: Assertion `(ip_addr & (__extension__ ({ register unsigned int __v, __x = (~(0xf <> 24) | (((__x) & 0x00ff0000) >> 8) | (((__x) & 0x0000ff00) << 8) | (((__x) & 0x000000ff) << 24)); else __asm__ ("bswap %0" : "=r" (__v) : "0" (__x)); __v; }))) != 0' failed. Aborted note i run debian testing on… Read more »

Dimon
Dimon
12 years ago

What qemu you are using? My qemu 1.0.1 crashed 🙁

flits
flits
12 years ago

This may be a dumb question, but isnt it possible to change the resolution? I have it running in qemu under windows and when i go to “start”–>preferences–>monitor settings i can only choose 640*480 while i would like some higher resolutions.

Dennis
Dennis
12 years ago

Anyone else wonder why theassword on a debian based system is suse?

ProDigit
ProDigit
12 years ago

Having a swap on an SD card is not a very good idea, for 3 reasons: 1- It significantly slows down the OS (since SD cards are extremely slow in simultaneously read/writing. 2- It increases the chance of errors (Almost any SD card, once it handles more than 2 or 3 transactions at a time, errs) 3- It decreases the lifetime of the SD card significantly (SD swap space will be written to frequently. This area might wear out a lot faster than the rest of the card , which mainly gets reads. 4- A 200MB flash space is not… Read more »

ProDigit
ProDigit
12 years ago

You could compress the archive using 7z, and if you want to use a swap space, format it with all zeroes if possible.
That will increase compression.

For now it’s only ran from PC’s anyway.
Smaller size means faster up/downloads and precious bandwidth saved

Bill Smith
Bill Smith
12 years ago

Thank you for posting the information.

My QEMU session hangs during startup with this error: VFS: Cannot open root device=”1f03″ or unknown-block(31,3)
Please append a correct “root=” boot option; here are the available partitions:
0b00 1048575 sr0 driver: sr
0800 1628160 sda driver: sd
Kernel panic – not syncing: VFS: Unable to mount root fs on unknown block(31,3)

I am running Ubuntu 11.10 with the kernel from http://dl.dropbox.com/u/45842273/zImage_3.1.9. My qemu-system-arm came from doing “apt-get install qemu-system”.

Any suggestions?

itsme
itsme
12 years ago

request to cnxsoft (and to all this article works)
Please post your OS/kernel/qemu version because for me and others people (see above) it does not work.
i run debian testing linux 3.2 qemu 1.0+dfsg-3, in post #3 you can see the error i got.

mpesce
12 years ago

Here’s the command line shell script that I’m using, which seems to work (reasonably) well on Ubuntu 11.10 x64

#!/bin/sh
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

I’m still getting a ” every time I type @ (and vice versa) Anyone know why this is? I explicitly set -k en-us in qemu-system, but that didn’t seem to help…

mpesce
12 years ago

@ cnxsoft
But it’s happening in the shell, not just in LXDE, so there must be something going on system-wide?

mpesce
12 years ago

mpesce :@ cnxsoft But it’s happening in the shell, not just in LXDE, so there must be something going on system-wide?

@ cnxsoft
And I’ve just learned what to do to fix the keyboard:

sudo dpkg-reconfigure keyboard-configuration

Select the correct options, reboot, and Bob’s Your Uncle!

itsme
itsme
12 years ago

@ cnxsoft sorry, it is not clear to me. Do you mean you was running Debian linux 3.0.4 inside a virtual box and the inside it you run qemu to run raspberry OS like in follow? 0. Real hadware with OS (win/lin) v 1. virtualbox v 2. debian linux 3.0.4 v 3. qemu-arm-system v 4. raspberry OS if it is, then you got problem as i report, you recompile kernel to have 3.1.9 for point #2 of for point #4? The OS that run qemu is relevant or not? i mean , no matter the OS that run qemu that… Read more »

itsme
itsme
12 years ago

@ cnxsoft
GOOD! I add “-net none” and it works! Of course there is not network so I cannot try some tests I had in mind. Better tan nothing, anyway! If someone know the trick to make network running, it is wellcome!
I suspect problem is in “host” system, tomorrow i will try to “downgrade” to debian stable (linux 2.6.32-5) and test again.

Bill Smith
Bill Smith
12 years ago

@ cnxsoft

I tried to updated qemu-system-arm command. After adding -net none, it worked. Thanks again. Here is the full command: 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 -net none

I seem to be running an older version of qemu:
$ qemu-system-arm -version
QEMU emulator version 0.15.50 (Debian 0.15.50-2011.08-0ubuntu4), Copyright (c) 2003-2008 Fabrice Bellard

itsme
itsme
12 years ago

i downgraded to 0.12.5+dfsg-3squeeze1 and it works also. note i must change -cpu arm1176 in -cpu arm1136 because qemu 0.12.5 does not suppot cpu arm1176.

NOTE: in emulation color red change in blue, so all color are falsed: i suppose because -cpu arm1136.

here the command line:

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

uebmaestro
uebmaestro
12 years ago

@ itsme
@ Bill Smith
I don’t think it’s a QEMU related issue. I’ve made this Debian/Raspi distro run on QEMU v1.0 on a Win7 host and had to disable network too otherwise QEMU crashes.
The same QEMU binaries run this without problem and network enabled:
http://people.debian.org/~aurel32/qemu/arm/

Seth
Seth
12 years ago

I was wondering, why will the kernel.img from the boot partition not work? I tried to use it instead of building my own but no dice. Maybe there is a nuance here that I’m missing.

For the record, I was able to get it working with a locally built kernel and “net -none”. Thanks for the tutorial!

Bill Smith
Bill Smith
12 years ago

@ uebmaestro
Sorry if my message was confusing. I only meant to convey that while others were successful QEMU 1.0, I was also successful with QEMU 0.15.50.

alanyih
alanyih
12 years ago

@ cnxsoft
modprobe : FATAL:
3.1.9 VS 3.1.9+

pi@raspberrypi:~$ modprobe -l
FATAL: Could not load /lib/modules/3.1.9/modules.dep: No such file or directory
pi@raspberrypi:~$ ls -l /lib/modules/
total 8
drwxr-xr-x 3 root root 4096 Jan 18 2012 3.1.4+
drwxr-xr-x 3 root root 4096 Feb 13 2012 3.1.9+
pi@raspberrypi:~$

http://3.bp.blogspot.com/-F8I50y1MiAI/T0PVbT6o26I/AAAAAAAAA74/Qx6Fkyv44Dk/s1600/2012022-raspi-modprobe.jpg

Rod
Rod
12 years ago

Silly question ..but what is the root password for the image

Rod

Rod
Rod
12 years ago

@ cnxsoft
Thats strange when it try GParted, Root terminal etc in LXDE the “Enter Admin password” window appears and “suse” or {Blank} is not accepted. I tried a sudo command at the command line as well.. not good.
Rod

Rod
Rod
12 years ago

@ cnxsoft
Yes that worked. I think the hour of the day was a contributing factor (2am) 🙂
With regards to the networking issue I rad a bit, googled a bit, tried a few suggestions but
ended up with “-redir tcp:2222::80”

I’d like to say thanks for all the good work and patience will all us noobs.

Regards
Rod

Rod
Rod
12 years ago

@ cnxsoft
Ah Ok
I had it round the wrong way, I though I was redirecting TCP 2222 on QEMU to TCP 80 on the host (Weird but now I can connect to the WEB and the local network).
Another silly question as I cant use admin in LXDE, how do I change the colour depth. Xorg -configure [fail], gdmconfig (I understand LXDE uses gnome).

Yes I’m showing that I lived in GUI land far too long.

Rod

Rod
Rod
12 years ago

@ cnxsoft Thanks mate Super steep learning curve, I’ll do a search on the xorg.conf in the forum. I’ve just tried completing your step by step instruction substituting newer version of any files i found had newer versions. (Cause newer is better) I’m up to the” make ARCH=arm menuconfig” and the later kernel or maybe the tool chain has more options than I can find on any howto. Anyway Its fun learning, besides its a change from the day job of SDH networks and unix network management system I have no control of. (On their next visit the grand-kids will… Read more »

Nicos from Kyrenia
Nicos from Kyrenia
12 years ago

The images from Windows XP SP2 Qemu working with this command only.

C:\Qemu>qemu-system-arm.exe -M versatilepb -cpu arm1136-r2 -kernel zImage_3.1.9
-hda debian6-17-02-2012.img -append “root=/dev/sda” -m 256

Nicos from Kyrenia
Nicos from Kyrenia
12 years ago

Windows XP SP2 qemu working , sorry for the prenious error.
C:\Qemu>qemu-system-arm.exe -M versatilepb -cpu arm1136-r2 -kernel zImage_3.1.9
-hda debian6-17-02-2012.img -append “root=/dev/sda2” -m 256

Andy Cater
Andy Cater
12 years ago

It worked well for me except that I had to make the -cpu arm1136-r2 or arm1136 rather than 1176 as in your initial instructions. [Looks like Nicos from Kyrenia found the same bug]

Colour depth on my laptop meant that it came out in funny colours – but that’s OK 🙂

Eric
Eric
11 years ago

For those having problems with being unable to use the network, I have a workaround (my system is Ubuntu 11.10 64-bit): Get the latest qemu from git: git clone git://git.savannah.nongnu.org/qemu.git cd qemu ./configure –target-list=arm-softmmu,arm-linux-user make sudo make install I ran into some problems with the make. I got a handful of warnings about variables being set but not used, but the warnings were set to be fatal for some reason. I tweaked the code (commenting out and whatnot) until it compiled. It probably would have been better to just set the compiler flags to ignore that warning. Anyway, once it… Read more »

Eric
Eric
11 years ago

@ Eric

EDIT: Actually, it is better to download qemu 1.0.1 on qemu.org. It also works and supports arm1176. The color palette is correct.

ralph
ralph
11 years ago

Hi,

anybody out there who has this running on MacOS? I currently have troubles to launch QEMU and don’t know where to start troubleshooting …

I followed the instructions from http://igor.gold.ac.uk/~mas01mjy/wp/?p=95 but when starting QEMU, a window opens but remains blank. CPU usage goes up but nothing happens. No log entries either …

Any hints welcome

Cheers,
Ralph

Raider
Raider
11 years ago

@ ralph

Ralf, I get exactly the same problem, have re-downloaded the files again, no luck. I am on 10.7.3.
Did you get any further?
Has anybody got it to work on mac?

Binary Emotions
11 years ago

Perfectly working with:
– VirtualBox 4.1.10
– Debian Squeeze 6.0.5
– Qemu 1.1 (compiled locally)
– The new Raspberry Pi Debian image (as of April 2012)

Thanks,
M

Chad
Chad
11 years ago

@ ralph Any luck on this one? I’m running into the same problems. No love for Mac, eh?

JerryLA
JerryLA
11 years ago

Managed to get qemu raspberry pi running on Ubuntu 12.10 Alpha, Midori onto internet. There’s some changes in qemu install for Ubuntu will try to reconstruct what I did to get going.

Khadas VIM4 SBC