Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.


Debugging Standalone Application on Microblaze using QEMU


In this article we shall use the QEMU to emulate a Microblaze system. We shall use the GDB debugger, to debug a standalone
Hello World Application. The recommended flow is to use QEMU via the Petalinux tool, however, users can use the DeviceTree Generator (DTG), and DeviceTree Compiler
from github to do this manually. It is this flow that is discussed here.

Creating the Hardware

User can create the design using the Vivado IP Integrator tool (see related links). Export to SDK, to create the HDF file.
This HDF file is to be used to create the devicetree that is used in QEMU

Creating the devicetree

Xilinx provide a devicetree generator (DTG) to create devicetree from a HDF file

Download the devicetree generator (DTG)

Note: Make sure that these is a memory node added to the pl.dtsi. This may not be added by the DTG.
If not, users can add this as shown below:
Code Block
themeMidnight
 lmb_bram: memory@0 {
                device_type = "memory";
                reg = < 0x0 0x10000000 >;
 } ;
Then update the Microblaze node with this:
Code Block
themeMidnight
memory = <&&lmb_bram>;
Also, the Microblaze Node should be updated to change the model and version:
Code Block
themeMidnight
model = "microblaze,8.40.b";
version = "8.40.b";

Create the DTS

  • launch HSI, source the TCL file below and run the command gen_dtb <HDF FILE>.hdf
Code Block
themeMidnight
proc gen_dtb {hdf} {
   open_hw_design $hdf
   set_repo_path ./repo
   create_sw_design device-tree -os device_tree -proc microblaze_0
   generate_target -dir my_dts
}
  • Exit HSI

Download devicetree compiler (DTC)


Create the DTB

  • dtc -I dts -O dtb -o my_dts/system-top.dtb my_dts/system-top.dts

Launching QEMU

Code Block
themeMidnight
qemu-system-microblazeel -M microblaze-fdt-plnx -m 256 -serial mon:stdio -device loader,file=mb_bootloop_le.elf -gdb tcp::1137 -hw-dtb my_dts/system-top.dtb -display none
Note: Here users can ether pass the bootloop elf, or the actual executable that they want to test.

Launching debugger and connecting to QEMU

Currently, the XSDB debugger does not support the Microblaze via QEMU. Users, can use the GDB debugger.
Users can connect to the debugger using the target remote: <port> command

Since the Microblaze is configured to use Little Endian (this is hard-coded in the Microblaze config), then we must tell the debugger this.
Load the ELF, and symbol info and then user is ready to debug.


Here, we can see the output on the serial port:


Type Ctrl A + x to terminate the QEMU


Related Links

  • Vivado Embedded Processor Hardware Guide here
  • Xilinx QEMU User Guide here
  • ZCU102 OSL Flow here