I’ve decided that having a “virtual Pi” would be handy so that I can mess about with the OS without worrying too much! Plus, it means I don’t have to carry my Pi around with me all the time if I just want to try some Python etc out.
For Windows users, it seems that the recommended solution for emulating the Pi is to use qEmu on Windows. Take a look at this Sourceforge project: Raspberry Pi Emulation in Windows.
Emulating the Pi
I should say before we begin that I’ve tried both the ‘Lenny’ and ‘Sarge’ Debian installs available from virtualboxes.org and neither of them worked (Lenny stopped at “Select and install software”, Sarge gave a rather horrid “Kernel panic”) hence I now use the official Debian site download instead!
- Download VirtualBox for your platform.
- Download a net install ISO image from debian.org itself.I’ve chosen the i386 small CD in the top-left area. 191MB to download…
- Create a new machine on VirtualBox, take the defaults, choose to create a new disk for it.
- Start the machine up.
- You get the first-time start-up dialogue.
- Choose to boot from the ISO image you downloaded.
- Choose your language/country etc. Let it run for a bit.
- Now, this installer looks very similar to the one that stopped on the Select and Install Software dialog, so hopefully it’ll work better than that one!
- Take the defaults all the way through, no need to be picky unless you want to. Set the root password, create a new account, set that password…
- Use the guided partitioning mode at the top.
- Choose to put all the files on one partition and write the changes to the disks.
- Off it goes, partitioning away, installing the ‘base system’. This is where it starts extracting the downloaded packages and going off to download and install the rest of the OS.
- This is going to take a while, I can tell!
- Now we’re onto ‘Select and Install Software’… Holding my breath…Ooooh. It’s gone to 12% and still running… This could be good. Yep, “Retrieving file” counter still running… Goooood.
- Choose the options you like. I just left it as a ‘GUI’ and the recommended/default options.
- Some time later…
Yes, I think I will install the GRUB boot loader. If only because I saw that the absence of this affected installation attempt number 2.
- Yay! Installation is complete. I’ll believe it when I see it 😉
- Now it’s running clean-up… Oh, I hope it moves on from 65% soon, otherwise… Ah. There we go.
- Rebooting automatically.
- Hmmm. Get the boot choice again… does that mean it’s going to start the install again? God, I hope not!
- I have a black screen… some kind of progress swirly…. Ah! Desktop!
- Go ahead and login. Don’t use root, use the ‘other’ account you created.
- Love the retro rocket-and-planet motif. Taking a while for anything to happen… Probably just a first-login thing.
- Hmmm. Okay… That’s a crappy GUI… no start bar or icon dock or anything… I can soon install something new of course. Oh, I see… there’s a menu bar at the top. Kind of merges into the VirtualBox menu. Some kind of message about Guest Additions came up but I missed it.
- Right, let’s see what we’ve got and if we can carry on with the emulation stuff…
- From the Applications->Accessories menu, start up a terminal.
- You should get a shell prompt with your ‘other’ username attached to it.
- Right, install the qEmu stuff.
- su root (use the password you specified during install)I’m doing this because I can’t sudo… because I’m not in that group of users, which is unhelpful.
- apt-get update(i.e. update the package database).
- apt-get install qemu
(Go and get and install the qemu package)
- Now, qemu is installed. That page I am referencing as a guide (the Southend one) makes it a lot more complicated than it needs to be!
- Now, you need to cd ~<other username> to go into the home folder of your ‘other’ user. We need to create a folder to mess around in and store kernels and disk images.
- mkdir pi_emu
- cd pi_emu
- wget xecdesign.com/downloads/linux-qemu/kernel-qemu
- This will get the qEmu kernel, which makes everything run. I hope.
- You now need to get the current Linux image for the Pi that is recommended by the RPi foundation. The one I am using is the first release of Raspbian Wheezy. But, always check for the latest one at their downloads page. Get the URL of the release and do:
- wget <url>
- This is NOT a small file – it’s about 440M, so go and get a cup of coffee.
- Unzip the file your downloaded (you will have to change this filename to whatever is now in your folder.
- To get a list of files, the Linux command is ‘ls’.
- unzip yyyy-mm-dd-whatever.zip
(to unzip it)
- This takes a while as well as it needs to expand the 440M file to a roughly 2GB file. Gawd bless file compression.
- Now, if you are logged in as root (and I was, so you should be!), you will need to make sure that the files in that folder are ‘owned’ by your other user, which will shall call ‘otheruser’. If you don’t do this, the .img file (and therefore the Virtual Raspberry Pi) will be ‘readonly’ when you run it using your otheruser account.
- chown otheruser *
- chown otheruser *.*
- You should now be back at a prompt that looks like
- Now, going to use a modified version of the command from the Southend site to start it up. Here goes:
- qemu-system-arm -kernel kernel-qemu -cpu arm1136-r2 -M versatilepb -no-reboot -append “root=/dev/sda2 panic=1” -hda 2012-07-15-wheezy-raspbian.img
- The last argument there is the .img file that you decompressed just now.
- Apparently, you can give it more memory by adding the “-m 512” argument to the end, but I just want it started up for now.
- I’m getting a few ‘readonly file system errors’, so it’s possible I might have to change permissions on the .img file before it works, but let’s just see…
- Not bad so far. Oooh! The usual Raspberry Pi first start-up screen! Yay!
- Choose the ‘update raspi-config’ option at the bottom just so you are up-to-date.
- Now re-run that utility:
- Choose the SSH server option and enable it. This will let you open a remote terminal to the Pi if you need to. Choose OK afterwards. Then choose ‘Finish’.
- Now we do ‘startx’
For Windows users, it seems that the recommended solution is now: Raspberry Pi Emulation in Windows.