Skip to content

Qemu and GDB

Victor Correal Ramos edited this page May 2, 2020 · 2 revisions

Qemu

The latest qemu version can emule a the behavior of a real Raspberry Pi but with some differences with the real Raspberry pi:

  1. Some peripherals don't exists (like the GPIO pins)
  2. The starting address for the boot section is the 0x80000 while the real hardware uses the 0x80000.
  3. The time is not quite realistic For this reason, there is conditional compilation in some regions of code and a specific linker for the Qemu. A script is in all the working folders for running the Qemu with the specific flags and emulate the Raspberry Pi. For run the kernel image the correct flags where:
qemu-system-aarch64 -M raspi3 -kernel kernel-qemu.img -serial stdio

gdb-multiarch

For debug the qemu, is necessary to compile with the -g flag and run the qemu with some flags. The qemu should use the -s -S flags to stop in the first instruction, and the gdb need the following sentences:

target remote localhost:1234
file build/kernel-qemu.elf

Here, the .elf file (that contains the debugging symbols) is loaded and the debugger connects via localhost to the qemu. A script for a qemu debugging session (runDBG.sh) and a script for set the gdb debugger (gdbscript) with the qemu are written.

Clone this wiki locally