I am building a Raspberry Pi specific snap package and learned you don't simply build software on an x86 Intel machine and run it on a Raspberry Pi. The Pi has an ARM processor and the software needs to be purposely built for this. Fine, but I don't always have a free Raspberry Pi at hand.
Why not virtualize the Raspberry in a VM on my laptop? No need for a physical Raspberry, no extra hardware to carry around, and I can boot up as many Pi's as I desire (or my laptop can handle).
I used the free and open-source QEMU hypervisor to virtualise the Raspberry hardware. Let’s download and install QEMU:
QEMU does not (yet) know the Raspberry kernel. I downloaded the most recent kernel from Dhruv Vyas’ QEMU RPi Kernel repository and the
versatile-pb.dtb device tree blob from the same repo (not the slightest idea what this does but it won’t run without it).
Only the Linux image itself left. I don’t need a GUI on the Pi, it’s a build machine, so I took the Raspbian Stretch Lite version. Unzipping the image gives a
With QEMU installed, the patched kernel and dtb file in place, and the Raspbian image it’s time to get the VM spun up:
The user-mode network used in the previous command does not support the
ping command out-of-the-box, only TCP and UDP are. I've found better network configurations online, but they look too complex for my little test setup.
This post is heavily based on Alistair Chapman’s blog post with slight modifications to make it work for me.