Disclaimer/spoiler:
Building for a Raspberry Pi in an emulator is just as slow as on the actual Pi. There is a slightly faster method involving chroot. But if you really want speed you’ll have to set up a cross compiler environment or try this other cross compiler setup.
Also: Links in the article below seem to be broken and it might not work anymore.
Original (outdated) article:
Today a colleague and I wanted to install gnuradio on a Raspberry Pi. This can than be combined with the amazing RTL-SDR dongle. This dongle this is a DVB-T USB stick, but can be turned into full software defined radio.
More information on that can be found here: http://www.rtl-sdr.com/about-rtl-sdr/.
Compiling gnuradio
When trying to compile gnuradio on the RPi (Raspberry Pi) we followed this description. But we quickly ran into a problem, compiling would take 20+ hours!
After running ‘make’ and grabbing a cup of coffee we set ourself a new goal, is it possible to emulate the RPi on our fast Macbook instead?
qemu
After following a couple of guides that didn’t work we finally managed to get Qemu up and running, this is what we did:
- Install and upgrade Xcode to 4.3 or above
- Install the latest version of Homebrew
Now we need to modify the Homebrew formula (which downloads and install qemu) to the correct version:
I’m using the osx$ prefix for commands that are executed on your OS X machine, pi$ for commands on the virtual Raspberry Pi.
Use the following file to get the working version 1.7.1 (other versions had SCSI problems): qemu.rb
After setting qemu.rb to the correct version you can install qemu:
Now check if qemu is installed correctly:
Now we need to download two thing:
- Linux kernel
- Raspbian image
To download the linux kernel:
Now we’ve downloaded the latest version of the raspbian image.
In our case: 2014-01-07-wheezy-raspbian.img
First boot
Now it is time to start the image in the emulator:
This first boot is a bit special because we only initialize /bin/bash. This is because we need to make two changes to the system:
We need to add a comment to this file:
Comment this line by placing a # in front of the line:
Now create the following file:
And put in the following content: 90-qemu.rules
Now we can stop the emulator and make one final change, the image file is a bit small and we need to increase the size before we continue:
From now on we can do a normal boot (save this command) by removing the “init=/bin/bash” part:
The last thing we need to do to get our virtual Raspberry Pi up and running is:
In this menu, you can “Expand filesystem” to make use of the increased image size (need to reboot afterwards).
Now you are ready to explore the raspberry pi without actually needing one.
(Broken) sources:
https://github.com/psema4/pine/wiki/Installing-QEMU-on-OS-X
http://xecdesign.com/qemu-emulating-raspberry-pi-the-easy-way/
Some problems we’ve encountered:
- qemu raspberry pi boot getting stuck in ‘scsi’ loop (fixed by using version 1.7.1)
- Disk size problems, resize didn’t work, expand filesystem didn’t work (fixed expanding and using ln -snf)