This repository was archived by the owner on Apr 14, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 108
Early Kernel Boot Debug
Manohar Castelino edited this page Oct 22, 2018
·
1 revision
On the virt platform if the kernel crashes early (even before the virtio-serial port comes up), you need to be able to debug the early boot process. This can be done using the sysbug-debugcon device which is available right at boot.
The key items to note below are
- Kernel commandline:
console=ttyS0
- Additional sysbus-debugcon device:
-device sysbus-debugcon,iobase=0x3f8,chardev=serialcon -chardev file,path=/tmp/serial-log,id=serialcon
Note:
- 0x3f8 maps to COM1. You can have additional serial ports if needed.
- As modeled by sysbus-debugcon these are output only ports
dos common IO
name name major minor address
COM1 /dev/ttyS0 4, 64; 3F8
COM2 /dev/ttyS1 4, 65; 2F8
COM3 /dev/ttyS2 4, 66; 3E8
COM4 /dev/ttyS3 4, 67; 2E8
QEMU=~/build-x86_64/x86_64-softmmu/qemu-system-x86_64
KERNEL=~/linux/arch/x86_64/boot/bzImage
BIOS=~/ovmf.fd.virt
OSIMAGE=~/clear.img
sudo $QEMU \
-kernel $KERNEL -append 'console=ttyS0 console=hvc0 root=/dev/vda3 rw rootfstype=ext4 data=ordered rcupdate.rcu_expedited=1 tsc=reliable no_timer_check noapictimer log_buf_len=1M debug loglevel=7' \
-bios $BIOS \
-nographic \
-nodefaults \
-L . \
-net none \
-machine virt,accel=kvm,kernel_irqchip \
-smp 4,maxcpus=8\
-m 512M,slots=3,maxmem=4G \
-device virtio-serial-pci,id=virtio-serial0 -device virtconsole,chardev=charconsole0,id=console0 -chardev stdio,id=charconsole0 \
-device virtio-blk-pci,drive=image -drive if=none,id=image,file=$OSIMAGE,format=raw \
-monitor telnet:127.0.0.1:55555,server,nowait \
-netdev user,id=mynet0,hostfwd=tcp::${VMN}0022-:22 -device virtio-net-pci,netdev=mynet0 \
-device sysbus-debugcon,iobase=0x402,chardev=debugcon -chardev file,path=/tmp/debug-log,id=debugcon \
-device sysbus-debugcon,iobase=0x3f8,chardev=serialcon -chardev file,path=/tmp/serial-log,id=serialcon
You can now observe the kernel boot prints at /tmp/serial-log
and the firmware bootup prints at /tmp/debug-log