Tell me more ×
Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It's 100% free, no registration required.

How can I connect an SD card containing a Raspberry Pi OS to my Linux PC, and boot the OS in an emulator?

Why won't VMWare work?

What are the limitations of this method?

Related: Emulation on a Windows PC

share|improve this question
Isn't this a virtualization question instead of an emulation question? – Zoot Jul 19 '12 at 14:19
I don't like the emulation to virtualisation edit... can we chat about it? – Alex Chamberlain Jul 19 '12 at 20:23
The basic problem is that the Pi has an ARM cpu which is incompatible with x86 which is what VMWare knows how to run. You need an emulator. – Thorbjørn Ravn Andersen Jul 29 '12 at 21:19

2 Answers

up vote 27 down vote accepted

Yes this is completely possible. However, in reality it's a little bit different to how you are thinking.


Preamble

The SD card contains an image of the operating system. And works by inflating this image when the device is powered on.

As I expect you already know, you flash this image onto the SD card in order to create a working system. However, what you can do before you flash the image is have a play around with it using QEMU, which is a processor emulator, and allows us to emulate the ARM instruction set.

In this way, any changes you make to the image (installing, compiling etc) will still be there after you flash it to the SD card.

I'll now talk you through how to use QEMU to load the image. I will be demonstrating with the Arch Linux image, but the process should be the same regardless.


Using QEMU

Prerequesites

You will need to acquire QEMU for your system. QEMU should only have one requirement, in order in input devices to work you need to have the SDL development package installed, which should be available from your package manager.

I recommend downloading the package using your regular package manager:

Arch:

sudo pacman -S sdl qemu

Ubuntu:

sudo apt-get install libsdl-dev
sudo add-apt-repository ppa:linaro-maintainers/tools
sudo apt-get update
sudo apt-get install qemu-system

Building QEMU yourself

Alternatively, you can build QEMU yourself. This is great if you want to try a new version, but it can be slow and be prepared for lots of errors during compilation! Note that if building QEMU from their website it must be compiled for ARM support. So check your distro repositories first. This can be done like so;

mkdir rpi-emu && cd rpi-emu
wget http://wiki.qemu.org/download/qemu-1.1.0-1.tar.bz2
tar xvjf qemu-1.1.0-1.tar.bz2
cd qemu-1.1.0-1
./configure –target-list=arm-softmmu,arm-linux-user
make
sudo make install

Verify that you have ARM support with:

qemu-system-arm --version
QEMU emulator version 1.0,1, Copyright (c) 2003-2008 Fabrice Bellard

Obtaining the Image

We're working with Arch Linux, so will be using the Arch Arm image. But replace this with whatever you wish to work with, or perhaps you already have an image. In which case, skip this step.

wget http://anorien.csc.warwick.ac.uk/mirrors/raspberrypi.org/images/archlinuxarm/archlinuxarm-29-04-2012/archlinuxarm-29-04-2012.zip
unzip archlinuxarm-29-04-2012.zip 

For QEMU to work we also need the kernel image (which would be inside the .img file).

Note: I don't think this step is necessary for Debian. Someone please confirm.

Luckily there are precompiled images available, and you can use the one from here (direct download).

TODO: Demonstrate how to compile a kernel image here?

Starting the VM

You should now have:

  • An img file which you can verify using the supplied sha1 (recommended).
  • A kernel image (zImage).
  • QEMU for ARM.

The Virtual Machine can now be started using the following long-winded command:

qemu-system-arm -kernel zImage -cpu arm1176 -M versatilepb -serial stdio -append "root=/dev/sda2" -hda archlinuxarm-29-04-2012.img -clock dynticks

Note that you will only have several hundred megabytes of storage using this method (whatever is spare on the image). A virtual hard disk can be created by following the QEMU user guide.

share|improve this answer
This is more what I was after - thanks! This is a great reference answer – Alex L Jun 14 '12 at 13:41
@Alex No problem, let me know if you need me to elaborate. Also, tell me if you get a debian image working and we can add it to the instructions if different. – Jivings Jun 14 '12 at 13:45
There's a reasonably thorough walkthrough here – Alex L Jun 14 '12 at 14:33
@Alex That's a good one, I'd not seen that. – Jivings Jun 14 '12 at 14:35
2  
The other is closed, so all I can do is vote to reopen – Jivings Jun 14 '12 at 17:44
show 9 more comments

You cannot do what you're suggesting, because Raspberry Pi has a different processor architecture than most PCs. While most PCs are x86-based, RPi is an ARM-based computer.

This is the same reason as why you cannot run, for example, Microsoft Windows on RPi.

VmWare won't work, because it can only virtualize x86-based operating systems (32-bit and 64-bit). There are other emulators that can virtualize ARM, such as QEMU, but those are running full software emulation without native CPU virtualizaton support, so you can expect them to be quite slow.

share|improve this answer
2  
Could you include some more information about how to emulate RasPi on x86 (ie with QEMU)? That's what I really wanted to focus this question on, although the explanation is appreciated. – Alex L Jun 13 '12 at 7:38
2  
Sorry to down vote , but this doesn't explain how to achieve what the asker needs. – G-. Jun 16 '12 at 9:21
On the other hand, it does address other points of the question which the other answer doesn't. I think your downvotes are unmerited (it's not like this question is leading either) – Tibor Jun 18 '12 at 17:42

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.