Guy Sheffer edited this page Jan 17, 2018 · 21 revisions

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.

Installation

  • Ubuntu (generally, any OS based on Debian):
sudo apt-get install qemu
  • OS X:
brew install qemu

Emulating

Once QEMU is installed and you have necessary files for emulation as mentioned above, follow the following steps to emulate RPi.

  1. Run:
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.

  1. Edit /etc/ld.so.preload by commenting (with # symbol) the 1st line, e.g.:
# /usr/lib/arm-linux-gnueabihf/libcofi_rpi.so
#
# ... rest of the file
  1. Edit /etc/udev/rules.d/90-qemu.rules by adding the following lines:
KERNEL=="sda", SYMLINK+="mmcblk0"
KERNEL=="sda?", SYMLINK+="mmcblk0p%n"
KERNEL=="sda2", SYMLINK+="root"
  1. Run:
sudo poweroff
  1. 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"

Key notes

  1. 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.
  2. 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.

Clone this wiki locally
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.