To follow some older (as in two years) ARM assembler howto, I searched for a quick and dirty way to run a current Rasbian with qemu 4.2 on Debian/unstable. The end result are the following notes to get that up and running:

# Download a binary device tree file and matching kernel a good soul uploaded to github
wget https://github.com/vfdev-5/qemu-rpi2-vexpress/raw/master/kernel-qemu-4.4.1-vexpress
wget https://github.com/vfdev-5/qemu-rpi2-vexpress/raw/master/vexpress-v2p-ca15-tc1.dtb
# Download the official Rasbian image without X
wget -O raspbian_lite_latest.zip https://downloads.raspberrypi.org/raspbian_lite_latest
unzip raspbian_lite_latest.zip
# Convert it from the raw image to a qcow2 image and add some space
qemu-img convert -f raw -O qcow2 2020-02-13-raspbian-buster-lite.img rasbian.qcow2
qemu-img resize rasbian.qcow2 4G
# start qemu
qemu-system-arm -m 2048M -M vexpress-a15 -cpu cortex-a15 \
 -kernel kernel-qemu-4.4.1-vexpress -no-reboot \
 -smp 2 -serial stdio \
 -dtb vexpress-v2p-ca15-tc1.dtb -sd rasbian.qcow2 \
 -append "root=/dev/mmcblk0p2 rw rootfstype=ext4 console=ttyAMA0,15200 loglevel=8" \
 -nic user,hostfwd=tcp::5555-:22
# login at the serial console as user pi with password raspberry
sudo -i
# enable ssh
systemctl enable ssh
# resize partition and filesystem
parted /dev/mmcblk0 resizepart 2 100%
resize2fs /dev/mmcblk0p2

Now I can login via ssh and start to play:

ssh pi@localhost -p 5555

So for me that is sufficient, I have network connectivity to install an editor, transfer files and can otherwise work with tmux to have some session multiplexing.

Additional Notes

  • Qemu supports a raspi2 machine, but this one does not support networking or USB for keyboard and mouse (in case you like to try the version with a desktop), but in general it works. You can extract the offical kernel and device tree file from the image and boot. But you're limited to the serial console as far as I could figure it out.
  • Using the full Rasbian image with the vexpress-a15 machine works, but I got only a resolution of 640x480 out of it, so I decided that ssh access to the emulated machine is sufficient and easier to deal with.
  • You've no ICMP available inside the qemu machine, so test your network connectivity with curl instead of ping.
  • Many tutorials use the versatilepb machine, you can find a matching device tree file and kernel on github as well. The drawback here is that the machine supports only 256MB of RAM, so you're more constrained.
  • Qemu flags change all the time, this works right now in April 2020 with qemu 4.2.