Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Welcome to the qemu-rpi-kernel wiki!
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 these two files.
- RPi kernel,
- RPi rootfs (which would be a second portion of official .img file).
If you want to emulate newer jessie images with 4.x.xx kernel from this repo, you should prepare your image as per given on this Emulating-Jessie-image-with-4.x.xx-kernel.
- Ubuntu (generally, any OS based on Debian):
sudo apt-get install qemu
- OS X:
brew install qemu
Grab the latest QEMU from official Download page.
Once QEMU is installed and you have necessary files for emulation as mentioned above, follow the following steps to emulate RPi.
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.
/etc/ld.so.preloadby commenting (with # symbol) the 1st line, e.g.:
# /usr/lib/arm-linux-gnueabihf/libcofi_rpi.so # # ... rest of the file
/etc/udev/rules.d/90-qemu.rulesby adding the following lines:
KERNEL=="sda", SYMLINK+="mmcblk0" KERNEL=="sda?", SYMLINK+="mmcblk0p%n" KERNEL=="sda2", SYMLINK+="root"
- Re-emulate by running:
qemu-system-arm -kernel kernel-qemu \ -cpu arm1176 \ -m 256 \ -M versatilepb \ -serial stdio \ -append "root=/dev/sda2 panic=1 rootfstype=ext4 rw" \ -drive "file=image-file-name.img,index=0,media=disk,format=raw"
- 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 QEMU:
-net nic -net user,hostfwd=tcp::2222-:22
Hope it helps.