QemuKernelTracing - GaloisInc/renovate GitHub Wiki
Deeper debugging of the loader requires poking around in the kernel loader. The easiest way to do that is to just build a custom kernel with calls to printk
and run it in qemu.
cd $KERNEL_SOURCES make ARCH=arm versatile_defconfig make ARCH=arm CROSS_COMPILE=arm-linux-gnueabi- all -j10 cd arch/arm/boot
This builds a kernel. Rebuild as-needed with additional instrumentation. Next, we need a filesystem (or at least an init process) for the kernel to boot. We don’t actually need much here, so we can just set our test binary as init. The kernel will panic when the binary exits, but that is fine.
# Assume that the test binary is called 'init' echo init | cpio -o --format=newc > initramfs
To run the image with the test binary, use
qemu-system-arm -M versatilepb -m 128M -kernel zImage -nographic -append "earlyprintk=vga,keep" -dtb ./dts/versatile-pb.dtb -initrd initramfs
- The
-dtb
argument provides an ARM device tree to qemu to tell it how to map various devices. We don’t bother to initialize graphics and just dump logs to the terminal we are running qemu in. - To exit qemu after it crashes, hit
C-a, c, q <enter>
.