This page describes how to access the Linux logbuf from within QEMU's memory without needing an attached console. This is useful for when a kernel started to boot but hangs prior to getting a console up for early print output.

Get The Logbuf Address/Size

Use readelf to get the logbuf
# readelf -a images/image.elf | grep __log_buf
     1: c0ae1a80 16384 OBJECT  LOCAL  DEFAULT   20 __log_buf
The two important values are the virtual address of the logbuf at 0xc0ae1a80 and the size 16384 (16KB)

Dump the Memory Contents from QEMU

Run QEMU directly or via 'petalinux-qemu-boot -g', interrupt the session and bringup the QEMU monitor via pressing Ctrl+A, C. Run the following monitor command (substituting the correct memory location and size).
(qemu) memsave 0xc0ae1a80 16384 dumpmem.logbuf
You can view the contents of dumpmem.logbuf now, however they will not be in the proper logbuf output, and the memory will have partial binary data.

Pipe it through logbuf-reader

Grab the attached , , build it:
# gcc -o logbuf-reader logbuf-reader.c

Then cat the memory dump through the reader:

# cat dumpmem.logbuf | logbuf-reader
Creating 6 MTD partitions on "a0000000.flash":
0x000000000000-0x000000200000 : "fpga"
0x000000200000-0x000000240000 : "boot"
0x000000240000-0x000000260000 : "bootenv"
0x000000260000-0x000000280000 : "config"
0x000000280000-0x000000e80000 : "image"
0x000000e80000-0x000002000000 : "spare"
xilinx_axienet 40b40000.axi-ethernet: TX_CSUM 0
xilinx_axienet 40b40000.axi-ethernet: RX_CSUM 0
libphy: Xilinx Axi Ethernet MDIO: probed
TCP: cubic registered
NET: Registered protocol family 17
Freeing unused kernel memory: 8096k freed
net eth0: Promiscuous mode disabled.
net eth0: Promiscuous mode disabled.
net eth0: Promiscuous mode disabled.
libphy: 40b40000:07 - Link is Up - 100/Full