System emulation using qemu: Raspberry PI 3
--
Welcome to a short series about using qemu
. I wanted to write about this for a while now but just didn’t get the opportunity so I said I will just spend a few weeks getting this sorted. You see, having virtual machines is easy these days: you can use Gnome Boxes, VirtualBox and many others. Some are open source, others free and of course many others paid. The main issue here is not all these virtual machines are created equal.
Gnome Boxes for example is great: just install and run. The catch? It cannot emulate a different system than the one you are currently running. Gnome Boxes simply runs a different Linux distribution on top of yours. There are talks about giving it the ability to at least emulate aarch64
but that’s all they are: talks. Same goes for containers like toolbox
: they just allow you to better compartmentalize your work or experiment with technologies that would not be recommended for the live system.
On the other hand qemu
, VirtualBox and other stronger emulators allow you to create any kind of system and use hardware acceleration where possible. There is no flatpak for VirtualBox yet, so you need to resort to other tricks to run it in Fedora Silverblue, but qemu
runs just fine in a toolbox
container. It’s also good to know that qemu
is the backbone of many such emulators including VirtualBox and KVM, so learning a bit about how it works never hurts.
Prerequisites for Raspberry PI 3
Let’s see what we need to run Raspberry PI 3 on our Fedora Silverblue PC. We need qemu
because the Raspberry PI is an ARM architecture and we are using an x64 PC so there is a total mismatch between the systems. To emulate the ARM machine we need three things: an ARM kernel, a hardware description file and a prepared disk image to boot (a Linux distribution like Raspbian will to). We will use all these three to configure qemu
and have our own emulated Raspberry PI 3.
But first, why do we need a kernel? Doesn’t the prepared Raspbian image have a kernel anyway? Well, we are creating a machine from scratch here which means we have to babysit the whole booting process…