Official image and QEMU?


107 posts   Page 1 of 5   1, 2, 3, 4, 5
by abishur » Fri Feb 17, 2012 11:48 pm
Has anyone got the official image to play nicely with QEMU yet?  I know it's only been out for a handful of hours, but still... :-)
Dear forum: Play nice ;-)
User avatar
Forum Moderator
Forum Moderator
Posts: 4225
Joined: Thu Jul 28, 2011 4:10 am
Location: USA
by teh_orph » Sat Feb 18, 2012 12:16 am
I've been getting the rpi kernel working in qemu for the last few weeks and I'm gonna say in general, 'no' :)

The addresses of the hardware devices are unique to the rpi, so although some things do come up you'll need to modify qemu to put the virtual hardware in the places that the kernel expects it. You can boot with say -cpu arm11mpcore (there are bugs with other qemu MMU implementations and. I use a modified 'versatilepb' configuration, which you can select with -M versatilepb.

One thing to consider is that the default UART that console output comes out on an address which is unknown to qemu, so you won't get any console output.

...unless I've simply been "doing it wrong" with qemu for the last few weeks!

What you can do instead is reconfigure and recompile the rpi linux git repo kernel to select the "ARM versatile" system type. You'll then be able to use the system image and a hand-compiled kernel.
User avatar
Posts: 315
Joined: Mon Jan 30, 2012 2:09 pm
Location: London
by jojopi » Sat Feb 18, 2012 2:47 am
You need an ARM kernel (with optional initramfs) that supports qemu"s PC-style hardware — Cirrus VGA, SCSI or ATA hard disks, PS/2 keyboard — instead of (or as well as) the real Pi hardware.

I used the stock kernel from debian 6.0.3 armv5 [1] that I had previously installed into qemu.  Then my command is:

qemu-system-arm -M versatilepb -hda debian6-17-02-2012.img -kernel vmlinuz-2.6.32-5-versatile -initrd initrd.img-2.6.32-5-versatile -m 192 -append "root=/dev/sda2" -serial pty &

I had to add ext4.ko to the initrd for obvious reasons. Plus psmouse.ko and evdev.ko to get keyboard and mouse to work in X11.  Plus smc91x.ko and mii.ko for networking.

LXDE starts up with one terminal in less than 60MiB.  So that looks quite promising.

[1] http://http.us.debian.org/debi.....e/netboot/
User avatar
Posts: 1873
Joined: Tue Oct 11, 2011 8:38 pm
by cnxsoft » Sat Feb 18, 2012 5:54 am
I have it working as well – http://www.cnx-software.com/20.....-emulator/

But jojopi method seems easier…

It does work, but I get a lot of error during boot as the system expects a R-Pi board.
User avatar
Posts: 190
Joined: Sat Oct 15, 2011 2:33 pm
Location: Chiang Mai, Thailand
by mpthompson » Sat Feb 18, 2012 7:27 am
jojopi said:


qemu-system-arm -M versatilepb -hda debian6-17-02-2012.img -kernel vmlinuz-2.6.32-5-versatile -initrd initrd.img-2.6.32-5-versatile -m 192 -append "root=/dev/sda2" -serial pty &
I had to add ext4.ko to the initrd for obvious reasons. Plus psmouse.ko and evdev.ko to get keyboard and mouse to work in X11.  Plus smc91x.ko and mii.ko for networking.


Thanks for the hints on getting this going.  I had some head scratching to figure out how to add the .ko files to an initrd file, but eventually stumbled across "update-initramfs" and was able to build the new file on the working emulated Debian ARM system.

By the way, to get an 800x600 X11 display under QEMU, create the file '/etc/X11/xorg.conf' with the following content:

Section "Screen"
Identifier "Default Screen"
DefaultDepth 16
SubSection "Display"
# Viewport 0 0
Depth 16
Modes "800x600"
EndSubsection
EndSection

And then restart X11.
User avatar
Forum Moderator
Forum Moderator
Posts: 620
Joined: Fri Feb 03, 2012 7:18 pm
Location: San Carlos, CA
by jojopi » Sat Feb 18, 2012 8:34 am
For anyone without a working debian ARM installation, cnxsoft's cross-compiled kernel will save a lot of time.  It has all the necessary drivers and does not need an initrd:

qemu-system-arm -M versatilepb -cpu arm1136-r2 -hda debian6-17-02-2012.img -kernel zImage_3.1.9 -m 192 -append "root=/dev/sda2"
User avatar
Posts: 1873
Joined: Tue Oct 11, 2011 8:38 pm
by mpthompson » Sat Feb 18, 2012 8:35 am
Another hint for those working with the disk image under QEMU and using a US mapped keyboard, you'll want to perform the following command:

sudo dpkg-reconfigure locales

and uncheck the locale en_GB.UTF-8 and check en_US.UTF-8 so that the keyboard is properly mapped.  I found this out when I went to edit a file using vi and had a fun time guessing where some keys were mapped on my keyboard.
User avatar
Forum Moderator
Forum Moderator
Posts: 620
Joined: Fri Feb 03, 2012 7:18 pm
Location: San Carlos, CA
by grumpyoldgit » Sat Feb 18, 2012 9:11 am
Reading through these posts there is an assumption that the reader has a familiarity with Qemu and has gone through various processes first. Is it possible to have a real idiot guide, starting from the point where Qemu has just been installed fresh?
User avatar
Posts: 1458
Joined: Thu Jan 05, 2012 12:20 pm
by Bakul Shah » Sat Feb 18, 2012 11:10 am
Asusming you have downloaded & unpacked the zip file & have qemu, it is very simple (on a linux or freebsd host -- don't know about windows):


  1. fetch cnxsoft's zImage_3.1.9 from http://dl.dropbox.com/u/458422.....mage_3.1.9

  2. qemu-system-arm -M versatilepb -cpu arm1136-r2 -hda debian6-17-02-2012.img -kernel zImage_3.1.9 -m 192 -append "root=/dev/sda2" -- see Jojopi's post above


Within seconds qemu's window will pop up. Wait till it gives you a login prompt. You can login as `pi', passwd `suse' and you are in; back to Jan 1, 1970! To shutdown: "sudo shutdown -h now".

On FreeBSD there is no prebuilt qemu-devel package that you can just pkg_add -r. You have to make install in /usr/ports/emulation/qemu-devel. Make sure it is recent: you want qemu-devel-1.0_1 or later -- "qemu-system-arm -cpu \?" should show you arm1176 and arm1136-r2.

Thanks guys for making this so easy! A short shell script can make the whole process automatic and even simpler.
Posts: 291
Joined: Sun Sep 25, 2011 1:25 am
by landru » Sat Feb 18, 2012 11:22 am
Hi,

I'm a little bit lost. I've downloaded the image file "debian6-17-02-2012.zip". When I launch qemu, with a versatile kernel, debian installation is starting.

Does this mean that  debian6-17-02-2012.img does not have a kernel installed ?

And my secon question, how do I prepare my micro sd card to Raspberry hardware ?

Thanks
Posts: 5
Joined: Fri Feb 03, 2012 8:14 am
by teh_orph » Sat Feb 18, 2012 11:51 am
Grumpyoldgit said:


Reading through these posts there is an assumption that the reader has a familiarity with Qemu and has gone through various processes first. Is it possible to have a real idiot guide, starting from the point where Qemu has just been installed fresh?



I can't help with an idiot guide :) but if you do find one online (eg "installing and running qemu") be aware that certain qemus version have major bugs in them. I spent last week battling with my Ubuntu's v0.12.x and a kernel debugger, only to find it was qemu that was broken (no timer interrupt). Upgrading to v0.15.1 fixed that (but broke other things!). Watch out.
User avatar
Posts: 315
Joined: Mon Jan 30, 2012 2:09 pm
Location: London
by grumpyoldgit » Sat Feb 18, 2012 11:51 am
Bakul said:


Asusming you have downloaded & unpacked the zip file & have qemu, it is very simple (on a linux or freebsd host -- don't know about windows):


  1. fetch cnxsoft's zImage_3.1.9 from http://dl.dropbox.com/u/458422.....mage_3.1.9

  2. qemu-system-arm -M versatilepb -cpu arm1136-r2 -hda debian6-17-02-2012.img -kernel zImage_3.1.9 -m 192 -append "root=/dev/sda2" -- see Jojopi's post above


Within seconds qemu's window will pop up. Wait till it gives you a login prompt. You can login as `pi', passwd `suse' and you are in; back to Jan 1, 1970! To shutdown: "sudo shutdown -h now".

On FreeBSD there is no prebuilt qemu-devel package that you can just pkg_add -r. You have to make install in /usr/ports/emulation/qemu-devel. Make sure it is recent: you want qemu-devel-1.0_1 or later -- "qemu-system-arm -cpu \?" should show you arm1176 and arm1136-r2.

Thanks guys for making this so easy! A short shell script can make the whole process automatic and even simpler.


I'm still being a bit thick here. I have put zImage_3.1.9 and debian6-17-02-2012.img in the same directory. I have then opened Terminal in that directory.

I had installed Qemu but the instructions call for qemu-system-arm 
The program 'qemu-system-arm' is currently not installed.  You can install it by typing:
sudo apt-get install qemu-system
so I did that as well.
 
I then ran instructions as above
 
qemu-system-arm -M versatilepb -cpu arm1136-r2 -hda debian6-17-02-2012.img -kernel zImage_3.1.9 -m 192 -append "root=/dev/sda2"
 

The loading takes quite a while but then I get thrown out, back to the terminal window. The last few lines are:-

Setting up libvde0 (2.2.3-3build1) ...
Setting up libvdeplug2 (2.2.3-3build1) ...
Setting up qemu-keymaps (0.15.50-2011.08-0ubuntu4) ...
Setting up libbrlapi0.5 (4.2-8ubuntu5.1) ...
Setting up qemu-system (0.15.50-2011.08-0ubuntu4) ...
Setting up vde2 (2.2.3-3build1) ...
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place
bob@Obi:/media/Western Digital$ qemu-system-arm -M versatilepb -cpu arm1136-r2 -hda debian6-17-02-2012.img -kernel zImage_3.1.9 -m 192 -append "root=/dev/sda2"
qemu-system-arm: /build/buildd/qemu-linaro-0.15.50-2011.08/slirp/arp_table.c:41: arp_table_add: Assertion `(ip_addr & (__extension__ ({ register unsigned int __v, __x = (~(0xf << 28)); if (__builtin_constant_p (__x)) __v = ((((__x) & 0xff000000) >> 24) | (((__x) & 0x00ff0000) >> 8) | (((__x) & 0x0000ff00) << 8) | (((__x) & 0x000000ff) << 24)); else __asm__ ("bswap %0" : "=r" (__v) : "0" (__x)); __v; }))) != 0' failed.
Aborted
 
 
Any ideas?
User avatar
Posts: 1458
Joined: Thu Jan 05, 2012 12:20 pm
by drgeoff » Sat Feb 18, 2012 11:52 am
landru said:

 how do I prepare my micro sd card to Raspberry hardware ?


The RP has a socket for an SD card.  You will need an adapter to take your micro-SD card.
Posts: 2045
Joined: Wed Jan 25, 2012 6:39 pm
by cnxsoft » Sat Feb 18, 2012 12:01 pm
Grumpyoldgit said:

I then ran instructions as above
 
qemu-system-arm -M versatilepb -cpu arm1136-r2 -hda debian6-17-02-2012.img -kernel zImage_3.1.9 -m 192 -append "root=/dev/sda2"
 

The loading takes quite a while but then I get thrown out, back to the terminal window. The last few lines are:-

Setting up libvde0 (2.2.3-3build1) ...
Setting up libvdeplug2 (2.2.3-3build1) ...
Setting up qemu-keymaps (0.15.50-2011.08-0ubuntu4) ...
Setting up libbrlapi0.5 (4.2-8ubuntu5.1) ...
Setting up qemu-system (0.15.50-2011.08-0ubuntu4) ...
Setting up vde2 (2.2.3-3build1) ...
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place
bob@Obi:/media/Western Digital$ qemu-system-arm -M versatilepb -cpu arm1136-r2 -hda debian6-17-02-2012.img -kernel zImage_3.1.9 -m 192 -append "root=/dev/sda2"
qemu-system-arm: /build/buildd/qemu-linaro-0.15.50-2011.08/slirp/arp_table.c:41: arp_table_add: Assertion `(ip_addr & (__extension__ ({ register unsigned int __v, __x = (~(0xf << 28)); if (__builtin_constant_p (__x)) __v = ((((__x) & 0xff000000) >> 24) | (((__x) & 0x00ff0000) >>

8)
 | (((__x) & 0x0000ff00) << 

8)
 | (((__x) & 0x000000ff) << 24)); else __asm__ ("bswap %0" : "=r" (__v) : "0" (__x)); __v; }))) != 0' failed.
Aborted

Any ideas?




I'm using -cpu arm1176 instead of -cpu arm1136-r2 on my command line, but I doubt this is your problem.

You are using Linaro Qemu 0.15.50 08-2011. If you update your qemu it may fix your issue.
User avatar
Posts: 190
Joined: Sat Oct 15, 2011 2:33 pm
Location: Chiang Mai, Thailand
by landru » Sat Feb 18, 2012 12:11 pm
@Grumpyoldgit

I tried this solution (zImage_3.1.9) on QEMU  version 1.0.50, and it crashed.

To get the lattest version of qemu on ubuntu :
1 - Install git
$ sudo apt-get install git

2 - Retrieves the sources :
$ git clone git://git.qemu.org/qemu.git

3 - Compile :
$ ./configure
    $ ./make

4 - Install checkinstall (to package your installation)
$ sudo apt-get install checkinstall

5- Package and install
$ sudo checkinstall

(precise a version when asked (item 3 of the menu) otherwise it fails)
Posts: 5
Joined: Fri Feb 03, 2012 8:14 am
by landru » Sat Feb 18, 2012 12:15 pm
drgeoff said:


landru said:


how do I prepare my micro sd card to Raspberry hardware ?


The RP has a socket for an SD card.  You will need an adapter to take your micro-SD card.



Oups ! I thought it was a socket for micro sd card. Thanks for this remind (I would have bought a micro sd instead of sd)
Posts: 5
Joined: Fri Feb 03, 2012 8:14 am
by teh_orph » Sat Feb 18, 2012 12:15 pm
With qemu 0.12.x the ARM 1176 and 1136 models had faulty MMU implementations and would not boot the system properly. I had much better success with the arm11mpcore option. Those bugs might have been fixed in the latest version though.

(also if you're using the versatilepb machine type there's also a bug where you must supply the amount of RAM the system has, and it's got to be <=256MB else qemu will crash - this bug is still present in v15)
User avatar
Posts: 315
Joined: Mon Jan 30, 2012 2:09 pm
Location: London
by landru » Sat Feb 18, 2012 12:40 pm
I have the .deb package for the very last version of qemu, if you are interested :

http://dl.free.fr/kFmtapeYj

this is the unstable version. It will be available during 30 days
Posts: 5
Joined: Fri Feb 03, 2012 8:14 am
by grumpyoldgit » Sat Feb 18, 2012 12:49 pm
There was a comment above that I might not have the latest version of Qemu. I am on Lubuntu 11.10 and had installed Qemu yesterday through the Synaptic Package Manager. I've now installed it from the Terminal

sudo apt-get install qemu

which installed more stuff.

I am now able to get to the Pi prompt and log in, so that hurdle is now over. I just need to figure out what I can do with it now! Thanks for your help.
User avatar
Posts: 1458
Joined: Thu Jan 05, 2012 12:20 pm
by slacker » Sat Feb 18, 2012 1:01 pm
cnxsoft said:


I have it working as well – http://www.cnx-software.com/20.....-emulator/


Thanks for these instructions, I've got it up and running following them. I've just got a quick question, you call the rootfs "debian6_rootfs.ext2" when you extract it, but in the script to run qemu you call it "rootfs_debian6_rpi.ext4" is that a mistake, or is there some other step we should be doing after we've extracted the rootfs. I just called it "debian6_rootfs.ext2" when starting qemu and it works fine.

I also had to upgrade my qemu from version 1.0.0 to 1.0.1 to get it to work otherwise I got the same errors as Grumpyoldgit.
Posts: 33
Joined: Wed Dec 07, 2011 9:12 pm
by grumpyoldgit » Sat Feb 18, 2012 1:15 pm
I'm probably easily pleased but I thought it was really neat that the web browser works without any further fiddling about. I also noticed that the date and time was automatically picked up. Is that due to the emulation or will the Pi pick that up as well?

I'm trying to add drives as they are not automatically picked up. It wanted authentication to see the 79Mb file system but the suse password failed. Any ideas?
User avatar
Posts: 1458
Joined: Thu Jan 05, 2012 12:20 pm
by slacker » Sat Feb 18, 2012 1:24 pm
It gets the time using NTP, so as long as it has an interent connection or access to an NTP time server on it's local network it can set the right time. The real Pi will be able to do the same thing.

Can't help with the drives sorry.
Posts: 33
Joined: Wed Dec 07, 2011 9:12 pm
by Aldasa » Sat Feb 18, 2012 1:30 pm
Grumpyoldgit said:


Bakul said:


Asusming you have downloaded & unpacked the zip file & have qemu, it is very simple (on a linux or freebsd host -- don't know about windows):


  1. fetch cnxsoft's zImage_3.1.9 from http://dl.dropbox.com/u/458422.....mage_3.1.9

  2. qemu-system-arm -M versatilepb -cpu arm1136-r2 -hda debian6-17-02-2012.img -kernel zImage_3.1.9 -m 192 -append "root=/dev/sda2" -- see Jojopi's post above


Within seconds qemu's window will pop up. Wait till it gives you a login prompt. You can login as `pi', passwd `suse' and you are in; back to Jan 1, 1970! To shutdown: "sudo shutdown -h now".

On FreeBSD there is no prebuilt qemu-devel package that you can just pkg_add -r. You have to make install in /usr/ports/emulation/qemu-devel. Make sure it is recent: you want qemu-devel-1.0_1 or later -- "qemu-system-arm -cpu \?" should show you arm1176 and arm1136-r2.

Thanks guys for making this so easy! A short shell script can make the whole process automatic and even simpler.


I'm still being a bit thick here. I have put zImage_3.1.9 and debian6-17-02-2012.img in the same directory. I have then opened Terminal in that directory.

I had installed Qemu but the instructions call for qemu-system-arm 
The program 'qemu-system-arm' is currently not installed.  You can install it by typing:
sudo apt-get install qemu-system
so I did that as well.
 
I then ran instructions as above
 
qemu-system-arm -M versatilepb -cpu arm1136-r2 -hda debian6-17-02-2012.img -kernel zImage_3.1.9 -m 192 -append "root=/dev/sda2"
 

The loading takes quite a while but then I get thrown out, back to the terminal window. The last few lines are:-

Setting up libvde0 (2.2.3-3build1) ...
Setting up libvdeplug2 (2.2.3-3build1) ...
Setting up qemu-keymaps (0.15.50-2011.08-0ubuntu4) ...
Setting up libbrlapi0.5 (4.2-8ubuntu5.1) ...
Setting up qemu-system (0.15.50-2011.08-0ubuntu4) ...
Setting up vde2 (2.2.3-3build1) ...
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place
bob@Obi:/media/Western Digital$ qemu-system-arm -M versatilepb -cpu arm1136-r2 -hda debian6-17-02-2012.img -kernel zImage_3.1.9 -m 192 -append "root=/dev/sda2"
qemu-system-arm: /build/buildd/qemu-linaro-0.15.50-2011.08/slirp/arp_table.c:41: arp_table_add: Assertion `(ip_addr & (__extension__ ({ register unsigned int __v, __x = (~(0xf << 28)); if (__builtin_constant_p (__x)) __v = ((((__x) & 0xff000000) >> 24) | (((__x) & 0x00ff0000) >>

8)
 | (((__x) & 0x0000ff00) << 

8)
 | (((__x) & 0x000000ff) << 24)); else __asm__ ("bswap %0" : "=r" (__v) : "0" (__x)); __v; }))) != 0' failed.
Aborted
 
 
Any ideas?


Didnt work for me either using the latest version on ubuntu. This worked for me:

qemu-system-arm -M versatilepb -cpu arm11mpcore -m 256 -hda debian6-17-02-2012/debian6-17-02-2012.img -kernel zImage_3.1.9 -append "root=/dev/sda2"
Posts: 4
Joined: Sat Feb 18, 2012 1:25 pm
by cnxsoft » Sat Feb 18, 2012 2:16 pm
slacker said:


cnxsoft said:


I have it working as well – http://www.cnx-software.com/20.....-emulator/


Thanks for these instructions, I"ve got it up and running following them. I"ve just got a quick question, you call the rootfs "debian6_rootfs.ext2" when you extract it, but in the script to run qemu you call it "rootfs_debian6_rpi.ext4" is that a mistake, or is there some other step we should be doing after we"ve extracted the rootfs. I just called it "debian6_rootfs.ext2" when starting qemu and it works fine.


Yes, that was a mistake. I corrected it.
User avatar
Posts: 190
Joined: Sat Oct 15, 2011 2:33 pm
Location: Chiang Mai, Thailand
by bob_binz » Sat Feb 18, 2012 2:23 pm
Well thanks to cnxsoft and jojopi, I've got qemu going with the debian release.  For info,  I managed to get network support via TUN/TAP using the following (in Ubuntu, dunno about windows)

sudo tunctl -u <put username here>
sudo echo 1 > /proc/sys/net/ipv4/ip_forward
sudo echo 1 > /proc/sys/net/ipv4/conf/wlan0/proxy_arp
sudo echo 1 > /proc/sys/net/ipv4/conf/tap0/proxy_arp
sudo ip link set tap0 up
sudo route add -host 192.168.2.200 dev tap0

then I launch qemu with:

qemu-system-arm -M versatilepb -cpu arm1176 -m 256 -hda debian6_rootfs.ext4 -kernel zImage_3.1.9 -append "root=/dev/sda" -net nic -net tap,ifname=tap0,script=no

then in your booted image, you can use ifconfig or edit /etc/network/interfaces to configure a static IP of 192.168.2.200. And hopefully your booted RPi image has tinty access.

BTW, I've just hacked this together from bits and pieces found on the internet so if you can't get it working, I'm probably not much help.

If there's a better way of giving internet access to the booted image, please post back.

BBz
User avatar
Posts: 367
Joined: Thu Feb 02, 2012 7:58 pm
Location: Stockport, UK