Emulation is a necessary aspect of embedded system development and Qemu is the right open source tool to do so for linux based SBCs.
To emulate RPi on Qemu, you will need two necessary files.
1) Rpi kernel (`git clone https://github.com/dhruvvyas90/qemu-rpi-kernel.git` or dowload this zip file)
2) Rpi rootfs (That would be second portion of official .img file) You can have a look at https://www.raspberrypi.org/downloads/
You will also need to have latest Qemu for your OS. Go to official (http://wiki.qemu.org/Download).
You can probably download Qemu by using package manager as well.
1) For ubuntu (and any debian based OSes):
`sudo apt-get install qemu`
2) For Mac OS X :
`brew install qemu`
3) For windows users :
You will have to download Qemu installer.
Once, Qemu installed and you have necessary files for emulation as mentioned above, Follow these particular steps for emulating RPi.
This particular guide shows you how to prepare image for emulating Raspbian-wheezy image. If you’re trying to emulate Jessie images, you should follow the other guide on this blog.
`qemu-system-arm -kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -no-reboot -serial stdio -append "root=/dev/sda2 panic=1 rootfstype=ext4 rw init=/bin/bash" -hda image-file-name.img`
- You should get
# prompt (bash) at the end of processing.
- Comment the 1st line saying
/usr/lib/arm-linux-gnueabihf/libcofi_rpi.so by putting
# in front of it.
- Now, `
- Add these lines.
- Re-emulate by this command, `
qemu-system-arm -kernel kernel-qemu -cpu arm1176 -m 256 -M versatilepb -serial stdio -append "root=/dev/sda2 panic=1 rootfstype=ext4 rw" -hda image-file-name.img`
Key notes :
You can have maximum ram upto 256 only as there’s a bug in versatilepb which doesn’t allow to emulate more than 256 MB.
You might want to set up ssh by adding this extra flag while using
Hope it helps.