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

Orange Pi Development Boards

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 become a Patron on Patreon

63
Leave a Reply

avatar
62 Comment threads
1 Thread replies
0 Followers
 
Most reacted comment
Hottest comment thread
21 Comment authors
JerryLAChadBinary EmotionsRaiderralph Recent comment authors
  Subscribe  
newest oldest most voted
Notify of
ja
Guest
ja

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?

trackback

[…] know, Raspberry Pi has released their first SD card image with Debian. This morning, I explained how to use that image in qemu.I’ve been waiting for samples to take advantage of the power Videocore GPU inside Broadcom […]

trackback

[…] (ρίξτε μια ματιά και σε καποιες οδηγίες που έχει εκεί. Για περισσοτερα). Ιστοσελίδα #dd_ajax_float{ background:none repeat scroll 0 0 #FFFFFF; border:1px solid […]

itsme
Guest
itsme

(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:

[email protected]:~/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 real hardware

Dimon
Guest
Dimon

What qemu you are using? My qemu 1.0.1 crashed 🙁

flits
Guest
flits

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
Guest
Dennis

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

ProDigit
Guest
ProDigit

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 very big anyways, but then again, the RAM isn’t very large neither. If the Rpi had 1GB of RAM, or even 512MB, we would not need a Swap space. The problem with the machine is, once you go browsing. Nowadays browsers by themselves use up at least 300MB, due to websites contents running flash and movies, and other multimedia.

Having no swap will improve system performance, for as long as you stay under the required swap space.
Once you hit the max swap size limit, the system usually shuts down or crashes.

ProDigit
Guest
ProDigit

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
Guest
Bill Smith

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
Guest
itsme

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
Guest

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
Guest

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

mpesce
Guest

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
Guest
itsme

@ 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 run raspberry OS?
Im getting crazy, i wish so bad to test the raspberry OS 🙁

itsme
Guest
itsme

@ 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.

trackback

[…] pas il suffit de désactiver le réseau en ajoutant -net none à la commande ci-dessus.Source : cnx-software.comVous pouvez lire aussi ::Tester VLC 2.0 sur Ubuntu 11.10Tester le lecteur musical de la CyanogenMod […]

Bill Smith
Guest
Bill Smith

@ 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
Guest
itsme

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
Guest
uebmaestro

@ 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
Guest
Seth

@cnxsoft

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
Guest
Bill Smith

@ 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
Guest
alanyih

@ cnxsoft
modprobe : FATAL:
3.1.9 VS 3.1.9+

[email protected]:~$ modprobe -l
FATAL: Could not load /lib/modules/3.1.9/modules.dep: No such file or directory
[email protected]:~$ 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+
[email protected]:~$

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

Rod
Guest
Rod

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

Rod

Rod
Guest
Rod

@ 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
Guest
Rod

@ 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
Guest
Rod

@ 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
Guest
Rod

@ 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 have to get used to linux as the two PC I have here for them have had a new OS “fall” on them)

Cheers Rod

trackback

[…] interface. This distribution may not be suitable for beginners and you’d better use the Debian SD Card image or even the upcoming Fedora 14 Rasbperry Pi Remix image.You can always install extra packages with […]

trackback

[…] how to run Raspberry Pi Fedora 14 Remix in QEMU using a simpler method than the one I used for Debian Squeeze and which also allows you to modify directly the image before copying it to your SD card once you […]

Nicos from Kyrenia
Guest
Nicos from Kyrenia

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