Simulate a Raspberry PI Link to heading
We did our first tests with the real hardware, this will become tedious over time. But don’t worry QEMU got us covered. For creating a virtual SD card we also need GNU mtools.
Generating an virtual SD card Link to heading
To simulate the boot process we need to give QEMU all the firmware files which can be downloaded from the official repo. We need bootcode.bin
, start.elf
. We also require a config.txt
with following content:
kernel=kernel8.img
arm_64bit=1
enable_uart=1
Now we need a virtual SD card that will be mounted by the simulator.
dd if=/dev/zero of=sd.img bs=1M count=64
A raspberry PI uses the FAT32
format for /boot
partition, so lets convert our sd.img
to FAT32
:
mformat -i sd.img -F ::
At last we have to move our firmware files
+ config.txt
into sd.img
.
mcopy -i sd.img -s bootcode.bin start.elf config.txt ::
And now we should have a fully functional SD card for QEMU.
Starting the simulator Link to heading
> qemu-system-aarch64 \
-M raspi3b \
-cpu cortex-a53 \
-serial stdio \
-sd sd.img \
-display none \
-kernel ../target/aarch64-unknown-none/release/kernel8.img
-M raspi3b
- Tells QEMU
that we want to simulate the Raspberry PI 3b peripherals
-cpu cortex-a53
- Sets the processor to one of the Raspberry Pi 3 B+
-serial stdio
- Will print all PL011 UART communication to the terminal
-display none
- Disables the display because we don’t have a video output yet
-kernel target/aarch64-unknown-none/release/kernel8.img
- Sets the kernel file
-s
- Will be used later for attaching a debugger so we can step through code
-sd sd.img
- Mounts the SD card.