Tested on Ubuntu 16.04, QEMU 2.5.0, Raspbian Jessie 2016-05
-
We pick
4.4.12since that is the kernel version in the Raspbian image.The process to generate that kernel blob is described at in the repository at: https://github.com/dhruvvyas90/qemu-rpi-kernel/tree/36ede073f4ccb64f60200ede36c231afe9502070/tools
Why this extra kernel image is needed: Emulating with Qemu: why the extra kernel?
Modify the Raspbian image as mentioned at: https://github.com/dhruvvyas90/qemu-rpi-kernel/wiki/Emulating-Jessie-image-with-4.x.xx-kernel/0068f0c21d942b0f331e18014ff8e22c20cada5c Summary:
Mount the second image of the partition. The easiest way is:
sudo losetup -f --show -P 2016-05-27-raspbian-jessie.imgbut it only works with latest
losetupon Ubuntu 16.04. Other methods at: https://askubuntu.com/questions/69363/mount-single-partition-from-image-of-entire-disk-device/496576#496576This prints a loop device, e.g.:
/dev/loop0and then mount the second partition from that device:
sudo mkdir /mnt/rpi sudo mount /dev/loop0p2 /mnt/rpiEdit the image:
# Comment out the line present there with # sudo vim /mnt/rpi/etc/ld.so.preload # Comment out the lines of type: "/dev/mmcblk*" sudo vim /mnt/rpi/etc/fstabCleanup:
sudo umount /mnt/rpi sudo losetup -d /dev/loop0
Enjoy:
sudo apt-get install qemu-system-arm qemu-system-arm \ -kernel kernel-qemu-4.4.12-jessie \ -cpu arm1176 \ -m 256 \ -M versatilepb \ -no-reboot \ -serial stdio \ -append "root=/dev/sda2 panic=1 rootfstype=ext4 rw" \ -hda 2016-05-27-raspbian-jessie.img
Edit: -M raspi2 was added in QEMU 2.6, and is likely the best bet since, but I haven't tested it yet.