Using QEMU to Emulate Raspberry Pi to Learn Assembler

There is no simple way to run a Raspberry Pi in an emulator so that you can learn some Arm assembler too. Yes, you can launch your Pi in VirtualBox, but it won’t let you also run assembler for an Arm architecture. So what to do? You go use Qemu emulator instead. This offers new challenges. See links below for more details.

Qemu needs a kernel plus an OS image for that system too, which you combine together into a launch script to suit your host system OS. Qemu is also limited to 256 MB of memory so don’t try to run a desktop system. Be happy with a terminal, or suffer a very slow system. Given it’s a script, you can tweak it to suit your needs. You only need to find, or create, a matching kernel and OS image to meet your needs and then you’re good to get started.

I needed a MacOS one for myself, and was able to modify the script from the link below and swap in our Pi image, and have it running nicely. I did have to edit the image once it was working so that it would boot to the console, and stop there, instead of booting to the desktop. As this image was modified, I couldn’t use the rasps-config tool, so had to run this command to change the boot level: sudo systemctl set-default multi-user.target

For our students, however, we need a version to run on Windows. At the moment I can only refer them to the one below, which is based on 2012 images of Debian and Raspberry Pi, so is not very current. But it does run (at least on my Windows 7 office machine), so all’s ok when you’re learning assembler and working with the terminal and Vi in any case. Hopefully it works on Windows 10 too.

At another time it would be useful to go through this more carefully and update the Windows version for our students.

QEMU https://www.qemu.org instead of VirtualBox, as it works with ARM

Raspberry Pi kernels to use https://github.com/dhruvvyas90/qemu-rpi-kernel with your Raspberry Pi image.

MacOSx https://gist.github.com/hfreire/5846b7aa4ac9209699ba – go to the bottom to find most recent updated script to run and tell you about options.

Linux https://azeria-labs.com/emulate-raspberry-pi-with-qemu/ Walks you through the basics, and explains some procedures to connect to your device that also work with MacOS.

Windows https://sourceforge.net/projects/rpiqemuwindows/files/ These are from 2012, but will get you started.

 

The University of Aberdeen is a charity registered in Scotland, No.SC013683