Why ?

Installing into memory card is slow, testing in VM is much faster and portable.

Download and unpack raspbian

wget http://downloads.raspberrypi.org/raspbian/images/raspbian-2016-05-31/2016-05-27-raspbian-jessie.zip

unzip 2016-05-27-raspbian-jessie.zip

Mount as loop device and extract kernel

sudo losetup -f --show -P 2016-05-27-raspbian-jessie.img
/dev/loop32
sudo mkdir /mnt/rpi
sudo mount /dev/loop32p1 /mnt/rpi
cp /mnt/rpi/kernel7.img  .
cp /mnt/rpi/bcm2709-rpi-2-b.dtb .
sudo umount /mnt/rpi
sudo losetup -d /dev/loop32

Run

sudo qemu-system-arm \
    -M raspi2 \
    -append "rw earlyprintk loglevel=8 console=ttyAMA0,115200 dwc_otg.lpm_enable=0 root=/dev/mmcblk0p2" \
    -cpu cortex-a7 \
    -dtb bcm2709-rpi-2-b.dtb \
    -sd 2016-05-27-raspbian-jessie.img \
    -kernel kernel7.img \
    -m 1G \
    -smp 4 \
    -serial stdio

Work in progress

There are other examples of similar setup, but they use versatilepb and only 256MB of RAM, so not perfect.

TODO

  • Newer Qemu (i was using 2.11.1)
  • raspi3 machine type
  • Network setup

RPI
RPI