adambialas
Posts: 12
Joined: Mon Jul 16, 2012 2:42 pm

Qemu problem

Thu Jul 19, 2012 7:17 am

Hi ,
How can I run 2012-07-15-wheezy-raspbian on qemu ?? On old zImage a have information illegal instruction after boot :(

Thx for help.

bzdk
Posts: 1
Joined: Thu Jul 19, 2012 8:13 am

Re: Qemu problem

Thu Jul 19, 2012 8:23 am

same question.

plugwash
Forum Moderator
Forum Moderator
Posts: 3499
Joined: Wed Dec 28, 2011 11:45 pm

Re: Qemu problem

Thu Jul 19, 2012 12:22 pm

Running raspbian on qemu requires a somewhat weird kernel (built for a compbination of platform and processor that doesn't really exist).

Unfortunately the only way I know of to get such a kernel is to download our readymade qemu image from http://archive.raspbian.org/qemu/raspbi ... ge.tar.bz2 . This is on my long list of things to sort out.

connectthedots
Posts: 2
Joined: Thu Jul 26, 2012 7:41 am

Re: Qemu problem

Thu Jul 26, 2012 8:41 am

Found this link:
http://www.raspberrypi.org/phpBB3/viewt ... 53#p129453

I don't know if this answers your question, but I'm also replying to this post to ask some kind person to help me get this to work on Ubuntu 12.04 Precise Pangolin.

I already know it works on Windows 7, but it really isn't the ideal solution for me.

I've already tried copying the kernels (both kernel-qemu & zImage_3.1.9) and tried to get it to work using the following code from the run.bat file:

Code: Select all

qemu-system-arm -M versatilepb -cpu arm1176 -hda 2012-07-15-wheezy-raspbian.img -kernel kernel-qemu -m 192 -append "root=/dev/sda2"
I tried replacing "kernel-qemu" with "zImage_3.1.9" as well.

I also tried instructions from the following website:
http://www.cnx-software.com/2012/02/18/ ... -emulator/

I did not compile my own kernel though. I know it works on the previous Debian image (debian6-19-04-2012), so I somewhat know what I am doing.

Lastly, my qemu-system-arm version is 1.0.50. I think the one from the Windows method is using version 1.1.0.0.

Please somebody help me to get this to work in Ubuntu!

BlackEdder
Posts: 8
Joined: Fri Jul 27, 2012 7:18 am

Re: Qemu problem

Fri Jul 27, 2012 5:21 pm

I also still have problems with trying to get this image to boot using qemu under linux. I alos tried the link from plugwash, which did boot, but I couldn't get internet to work. DNS seemed to work fine, but I couldn't ping/download anything. This was not a problem before with the non raspbian image .

ejsolutions
Posts: 96
Joined: Fri Jun 29, 2012 2:27 pm
Location: In the sticks of Haggisland

Re: Qemu problem

Fri Jul 27, 2012 6:58 pm

Took me a while to figure it out and I only use the basic networking (no TUN), due to wireless connectivity. Here's the command line, that I save in a shell script, called rpi.sh

Code: Select all

qemu-system-arm -M versatilepb -cpu arm1136 -m 192 -kernel raspbian/vmlinuz-2.6.32-qemu-armv6 -initrd raspbian/initrd.img-2.6.32-qemu-armv6 -hda raspbian/raspbian.img -append "root=/dev/sda1"
I then call the script from a terminal, using sh ./rpi.sh

As stated someplace, ping doesn't work.
DNS must resolve, as it's changing the archive list to IP addresses. Turning off my Mint firewall (ufw) makes no difference. I don't have the same issue when running Virtualbox - it just works.

A "netstat -r" displays the default route as the expected 10.0.2.2

ejsolutions
Posts: 96
Joined: Fri Jun 29, 2012 2:27 pm
Location: In the sticks of Haggisland

Re: Qemu problem

Fri Jul 27, 2012 7:30 pm

ejsolutions wrote:...(no TUN)..
I meant TAP, of course. :?

ejsolutions
Posts: 96
Joined: Fri Jun 29, 2012 2:27 pm
Location: In the sticks of Haggisland

Re: Qemu problem

Sat Jul 28, 2012 12:45 am

Well, I'm sorted out, using "user mode" networking.
Set /etc/resolv.conf nameserver to 10.0.2.2 instead of 10.0.2.3
Change /etc/apt/sources.list to the mirrordirector.raspbian.org site and everything gets updated fine - or so it appears.

BlackEdder
Posts: 8
Joined: Fri Jul 27, 2012 7:18 am

Re: Qemu problem

Sun Jul 29, 2012 11:06 am

For me changing the resolv.conf just results in non working dns at all. Where did you get the 10.0.2.2 from? Is that the nameserver of your "wider" subnet?

ejsolutions
Posts: 96
Joined: Fri Jun 29, 2012 2:27 pm
Location: In the sticks of Haggisland

Re: Qemu problem

Sun Jul 29, 2012 12:24 pm

10.0.2.2 is the default gateway used in Qemu.
As your vm starts up, look out for the DHCP messages, or
"sudo /etc/init.d/networking restart" will display the DHCP assignments: I got a DHCPOFFER from 10.0.2.2, which gave me the clue to try that for the nameserver.

connectthedots
Posts: 2
Joined: Thu Jul 26, 2012 7:41 am

Re: Qemu problem

Fri Aug 03, 2012 3:57 am

Alright guys, the moment I've been waiting for...

I have successfully been able to get the image, '2012-07-15-wheezy-raspbian.img' to work under Ubuntu 12.04 64-bit. It also works on Puppy Linux 5.2.8-005 32-bit (my test system), in case anyone was wondering.

All 'code' enclosed are assumed to be run in some kind of Terminal program, or otherwise some form of command line interface (CLI).

First, I need to tell you that if you are able to run 'qemu-system-arm' already, if your version is not 1.1.0 or higher, you will probably need to uninstall it before trying my instructions, to avoid interference with the program, 'qemu-system-arm', that you will create in the -compiling from source- process.

Here's how to check your version:

Code: Select all

qemu-system-arm --version
If you already have version 1.1.0 or better, you can skip the compiling part, and go straight to loading the Raspbian image in qemu. That section is in bold and underlined for your convenience. If you don't have it installed, you are all set to compile qemu. Otherwise, you will need to find some way to uninstall it.

Here's how to uninstall in Ubuntu:

Code: Select all

sudo apt-get remove qemu-system qemu-user
I used the following website as a guide for the compiling process:
http://xecdesign.com/compiling-qemu/

There are a number of dependencies that will need to be resolved to compile qemu from source for an 'arm' host. I pretty much kept trying './configure blah blah' while reading 'config.log' to find out what went wrong.

For Ubuntu 12.04, you may run the following:

Code: Select all

sudo apt-get install zlib1g-dev libxen-dev libsdl1.2-dev
For Puppy Linux 5.2.8-005, you will need 'lupu_devx_528-4.sfs' (for compiling):
http://distro.ibiblio.org/pub/linux/dis ... ppy-5.2.8/
You will also need 'libsdl-1.2.14-w-20110530.pet' (for SDL, I have no clue exactly what it does):
http://puppylinux.org/wikka/libsdl

To compile qemu for an 'arm' host (which is what we need), you'll need to download it from here:
http://wiki.qemu.org/Download
I will be using 'qemu-1.1.1-1.tar.bz2' for my examples.

Extract the file and go to it in terminal. The folder you need to get to is called 'qemu-1.1.1'. Once you are there, you will need to run the following to compile for an 'arm' host:

Code: Select all

./configure --target-list="arm-softmmu arm-linux-user" --enable-sdl
make
sudo make install
Now to load the Raspbian image on qemu. You will need the '2012-07-15-wheezy-raspbian.img' file (sorry if it seems obvious). You'll need to download and extract the '2012-07-15-wheezy-raspbian.zip' file:
http://www.raspberrypi.org/downloads

You'll also need the kernel, 'kernel-qemu':

Code: Select all

wget http://xecdesign.com/downloads/linux-qemu/kernel-qemu
Make sure '2012-07-15-wheezy-raspbian.img' and 'kernel-qemu' are in the same folder. As an example, I put them in this folder: ~/raspbian-7-15-2012

Now that everything is ready, run the following in the folder:

Code: Select all

qemu-system-arm -M versatilepb -cpu arm1176 -hda 2012-07-15-wheezy-raspbian.img -kernel kernel-qemu -m 256 -append "root=/dev/sda2"
The above is based on the following forum entry:
http://www.raspberrypi.org/phpBB3/viewt ... 53#p129453
Specifically, I followed the provided link to download 'qemu_no image.zip', and read and edited the enclosed 'run.bat' file.

There you have it, the recent Raspbian should be running correctly. I even tested Midori, which is able to browse websites.

I hope this helps someone 8-)

BlackEdder
Posts: 8
Joined: Fri Jul 27, 2012 7:18 am

Re: Qemu problem

Sat Aug 04, 2012 3:04 pm

Thank you for the detailed post. My problem indeed seemed to be that my qemu version was too old. Furthermore, pinging still didn't work, but downloading/updating did work correctly and that was the main thing.

Dredia
Posts: 4
Joined: Tue Aug 07, 2012 7:52 am

Re: Qemu problem

Tue Aug 07, 2012 8:33 am

Hi all,

I have a question you ask, how can I boot from my sd card that it is in drive E:
I do not know what I need to change the run.bat

Code: Select all

qemu-system-arm.exe -M versatilepb -cpu arm1176 -hda 2012-07-15-wheezy-raspbian.img -kernel kernel-qemu -m 192 -append "root=/dev/sda2"
Thank you for your help.

Heater
Posts: 14260
Joined: Tue Jul 17, 2012 3:02 pm

Re: Qemu problem

Tue Aug 07, 2012 11:00 am

Sort of worked. raspi-config would not do anything but crash. ping does not work. apt-get update seems to.

Great stuff.
Memory in C++ is a leaky abstraction .

User avatar
PIstolero
Posts: 101
Joined: Mon Jul 23, 2012 6:28 am
Location: paradise city, where the grass is green and the girls are pretty

Re: Qemu problem

Tue Aug 07, 2012 11:11 am

the raspi-config script is unusable in qemu.
Ping is not working because qemu is emulating a NAT like you have at home (router and some PCs), internet is working but the box is not reachable from outside the LAN so you have to forward each ports (similar to port forwarding with a NAT) or use a TAP device.
See here:
http://wiki.qemu.org/Documentation/Netw ... 28SLIRP.29
You can modify you .bat or .sh with redirecting your ports, example:
qemu-system-arm.exe -k de -M versatilepb -cpu arm1176 -hda 2012-07-15-wheezy-raspbian.img -kernel kernel-qemu -m 192 -append "root=/dev/sda2" -redir tcp:2222::22 -redir tcp:8080::80
Now your raspbian RPI port 80 (http server) and port 22 (ssh daemon) is reachable on localhost (your windows box) at port 8080 and 2222 (take care that the ports are free on your box).

User avatar
PIstolero
Posts: 101
Joined: Mon Jul 23, 2012 6:28 am
Location: paradise city, where the grass is green and the girls are pretty

Re: Qemu problem

Tue Aug 07, 2012 12:08 pm

Sorry for double posting, I can't edit the post above :?
Don't use -k de if you haven't a german keyboard, choose your own country layout.

raspteam
Posts: 9
Joined: Wed Oct 10, 2012 8:54 pm

Re: Qemu problem

Wed Oct 10, 2012 9:31 pm

Hi,

I am a new raspberry addict! and I have probably solution about how to emulate on Qemu the rasbian image. These is processed in admin mode under debian6squeese virtualized under Virtualbox.
First create a repository in your home directory using:

Code: Select all

mkdir qemu&cd qemu
Then create a mount directory in the appropriate path:

Code: Select all

mkdir /mnt/Qemu
Then download Raspbian image in qemu directory and vmlinuz-2.6.32-5-versatile in installer directory. Then mount wheezy using:

Code: Select all

mount -o loop,offset=$((512*2048)) -t ext4 ./wheezy-rasbian.img /mnt/Qemu
Copy the boot repository using:

Code: Select all

cp /mnt/Qemu/init* ./boot
Don't forget to umount wheezy image using the next command:

Code: Select all

umount /mnt/Qemu
Then the last command to emulate image. Tape the line below:

Code: Select all

qemu-system-arm -M versatilepb -kernel ./installer/vmlinuz-2.6.32-5-versatile -initrd ./boot/initrd.img -hda ./wheezy-rasbian.img -append "root=/dev/sda1 panic=1" –cpu arm11mpcore -m 256
The use of the option
–cpu arm11mpcore
is an alternative to the arm1176jzf because qemu doesn't emulate the raspberry arm core. Arm11mpcore is arm multiprocessor core. In order to known which cpu is emulated on qemu use the command below:

Code: Select all

qemu-system-arm -cpu ?
A list of possible cpu appears.

The option
-m 256
specifies memory. The raspberry has 256Mo of ram
The option
-append "root=/dev/sda1 panic=1"
defines the used partition and start option for this partition.

After a QEMU application processes and the rasbian image is emulated. Therefore the login
pi
and the pwd
raspberry
do not work!

I don't know why!
Here below I place a picture of QEMU application.
Untitled.jpg
Untitled.jpg (24.76 KiB) Viewed 18381 times
If you have other question please contact me.
Good luck

User avatar
PIstolero
Posts: 101
Joined: Mon Jul 23, 2012 6:28 am
Location: paradise city, where the grass is green and the girls are pretty

Re: Qemu problem

Thu Oct 11, 2012 5:43 am

is an alternative to the arm1176jzf because qemu doesn't emulate the raspberry arm core.
You are probably using an old version of qemu (type qemu-system-arm -version), it is the same with opensuse, the qemu version from the repo is outdated (0.x, it should be 1.x), compile your own to be up to date then you can choose -cpu arm1176.
append "root=/dev/sda1 panic=1"
The root partition is /dev/sda2 not /dev/sda1 (this is the FAT partition with the firmware)
mount wheezy using...copy the boot repository...
You don´t need to do that, you can leave the raspbian image as it is, just start qemu with it own kernel (-kernel zImage).
Example: qemu-system-arm -M versatilepb -cpu arm1176 -hda 2012-09-18-wheezy-raspbian.img -kernel zImage -m 256 -append "root=/dev/sda2"

is processed in admin mode under debian6squeese virtualized under Virtualbox
Emulating a arm system is very slow so try to run the emulator on a real system not on a VM, you will loose performance. qemu-system-arm is using only one core so if you have a PC with turbo core or turbo boost (overclock one core if the others have nothing to do) enable it.

Compiling qemu: http://xecdesign.com/compiling-qemu/
Compiling a qemu kernel: http://xecdesign.com/compiling-a-kernel/
Using qemu: http://xecdesign.com/qemu-emulating-ras ... -easy-way/
Kernel 3.2.7 for qemu and raspbian: http://elinux.org/File:Qemu_kernel_3.2. ... FS_support
More infos: http://www.raspberrypi.org/phpBB3/viewt ... =63&t=3149
The easy way (for windows user): http://www.raspberrypi.org/phpBB3/viewt ... =26&t=5743

raspteam
Posts: 9
Joined: Wed Oct 10, 2012 8:54 pm

Re: Qemu problem

Thu Oct 11, 2012 9:26 pm

Right, I am using Qemu version 0.12.5 from Fabrice Bellar (2008)
I tried your command using SDA2 instead of SD1.

If I use your command without adding -initrd option, the system reboot each second. Normal because the loader does not find the loader after the boot.
if i use a mix using the option -initrd then system boots, loads then craches because loader searches sbin/init file saved on SDA1. consequently impossible to boot on other disk that SDA1.

I wish do a correction about password (pi/raspberry); I explain myself. The initrd image during first boot is not configured to use rasbian image, then the qemu application or emulated arm (I don't no) considers a new OS installation. So, follow the instructions of the installer (my hostname is qbian, my login and password are choosen during installation, unfortunately not pi/raspberry). Then at the end close qemu window application then retry to boot using this command line below:

Code: Select all

qemu-system-arm -M versatilepb -kernel ./installer/vmlinuz-2.6.32-5-versatile -initrd ./boot/initrd.img -hda ./wheezy-rasbian.img -append "root=/dev/sda1 panic=1" –cpu arm11mpcore -m 256
These booth methods have been used to emulate debian squeeze and wheezy except when you are mounting image, use mount type "ext3" to squeeze instead of "ext4" to wheezy.

PIstolero, the recent version of qemu probaly allows processing like you said. To be confirmed!

raspteam
Posts: 9
Joined: Wed Oct 10, 2012 8:54 pm

Re: Qemu problem

Thu Oct 11, 2012 10:23 pm

Sorry the picture is limited up to 64K
attachment=0]RaspbianQemu.jpg[/attachment]
Attachments
RaspbianQemu.jpg
RaspbianQemu.jpg (62.7 KiB) Viewed 18288 times

raspteam
Posts: 9
Joined: Wed Oct 10, 2012 8:54 pm

Re: Qemu problem

Fri Oct 12, 2012 9:17 pm

I tried to use Qemu 1.2.50 from Bellar using gnuit!
Processing from the following tutorial: http://xecdesign.com/qemu-emulating-ras ... -easy-way/
system craches during uncompressing kernel-qemu file
gitqemu1.2.50.jpg
gitqemu1.2.50.jpg (46.84 KiB) Viewed 18221 times
I tried also http://elinux.org/File:Qemu_kernel_3.2. ... FS_support but the file is not supported!

Somebody have this problem?

Return to “Raspbian”