Table of Contents

Debian Buster for RaspberryPi 3 with Qemu in 64bits (aarch64)

This guide explains how to get Debian Buster using a RaspberryPi 3 image running with Qemu. These images are 64bits (aarch64), therefore, taking advantage of RPi 3 and 4 newest hardware.

This configuration is useful in order to use a big PC to precompile and afterwards export the binaries to the slower/real Raspberry Pi.

This will be used to get ROS2 installed.

Preparing your host system

sudo apt-get install qemu-system-arm xz-utils
mkdir ~/db_rpi3_qemu
cd ~/db_rpi3_qemu
wget https://people.debian.org/~gwolf/raspberrypi/20190628/20190628_raspberry-pi-3_buster_PREVIEW.img.xz
xz --decompress 20190628_raspberry-pi-3_buster_PREVIEW.img.xz
sudo fdisk -l 20190628_raspberry-pi-3_buster_PREVIEW.img
Disk 20190628_raspberry-pi-3_buster_PREVIEW.img: 1.5 GiB, 1572864000 bytes, 3072000 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x36969c21

Device                                      Boot  Start     End Sectors  Size Id Type
20190628_raspberry-pi-3_buster_PREVIEW.img1        2048  614399  612352  299M  c W95 FAT32 (LBA)
20190628_raspberry-pi-3_buster_PREVIEW.img2      614400 3071999 2457600  1.2G 83 Linux
mkdir -p ~/mnt/test
sudo mount -o offset=1048576 20190628_raspberry-pi-3_buster_PREVIEW.img ~/mnt/test
cp ~/mnt/test/vmlinuz-4.19.0-5-arm64 ~/db_rpi3_qemu
cp ~/mnt/test/initrd.img-4.19.0-5-arm64 ~/db_rpi3_qemu
qemu-system-aarch64 -M virt -m 1024 -smp 4 -cpu cortex-a53   -kernel vmlinuz-4.19.0-5-arm64   -initrd initrd.img-4.19.0-5-arm64   -drive if=none,file=20190628_raspberry-pi-3_buster_PREVIEW.img,format=raw,id=hd  -append 'root=/dev/vda2 noresume'   -device virtio-blk-pci,drive=hd   -device virtio-net-pci,netdev=mynet -netdev user,id=mynet,hostfwd=tcp::2222-:22 -device virtio-rng-pci   -no-reboot -nographic
nano /etc/network/interfaces.d/enp0s2
auto enp0s2

# TODO: switch back to iptables-persistent once it re-enters testing
iface enp0s2 inet dhcp
	pre-up iptables-restore < /etc/iptables/rules.v4
	pre-up ip6tables-restore < /etc/iptables/rules.v6
poweroff
ssh root@localhost -p 2222

References

https://wiki.debian.org/RaspberryPiImages

https://people.debian.org/~gwolf/raspberrypi/

https://translatedcode.wordpress.com/2017/07/24/installing-debian-on-qemus-64-bit-arm-virt-board/

https://translatedcode.wordpress.com/2018/04/25/debian-on-qemus-raspberry-pi-3-model/

https://wiki.debian.org/RaspberryPi

https://wiki.debian.org/RaspberryPi3

https://salsa.debian.org/raspi-team/image-specs

https://wiki.debian.org/RaspberryPi/qemu-user-static

https://people.debian.org/~stapelberg/raspberrypi3/2018-01-08/

https://github.com/wimvanderbauwhede/limited-systems/wiki/Debian-%22buster%22-for-Raspberry-Pi-3-on-QEMU

https://wiki.debian.org/QemuUserEmulation