2

I'm trying to emulate baremetal Microblaze code using QEMU but don't get any output from the "print" function. The microblaze is produced from a xilinx project, this produces a .dts file which is used to make a .dtb for use with QEMU. I'm using Xilinx's fork of QEMU

I run QEMU with the following command

~/.local/bin/qemu-system-microblazeel -M microblaze-fdt -dtb system-top.dtb -m 256 -serial mon:stdio -display none -kernel ./workspace/app_0/Debug/app_0.elf -s -S -nographic

I can connect with gdb, and step through the code, it clearly writes to address 0x40600004 which is the UART TX data FIFO, but still nothing is seen at the QEMU terminal. I even added some debug inside the QEMU xilinx UART model, it was registered but never called when the code ran.

#include <stdio.h>
#include "platform.h"
#include "xil_printf.h"

int main()
{
    init_platform();

    print("Hello World\n\r");

    cleanup_platform();
    return 0;
}

This is the UART node from the .dts file

top_axi_uartlite_0: serial@40600000 {
        clock-frequency = <294999169>;
        clocks = <&clk_bus_0>;
        compatible = "xlnx,axi-uartlite-2.0", "xlnx,xps-uartlite-1.00.a";
        current-speed = <115200>;
        device_type = "serial";
        interrupt-names = "interrupt";
        interrupt-parent = <&top_axi_intc_0>;
        interrupts = <1 0>;
        port-number = <0>;
        reg = <0x40600000 0x10000>;
        xlnx,baudrate = <0x1c200>;
        xlnx,data-bits = <0x8>;
        xlnx,odd-parity = <0x0>;
        xlnx,s-axi-aclk-freq-hz-d = "294.999169";
        xlnx,use-parity = <0x0>;
    };

QEMU monitor shows the following memory space

address-space: memory
  0000000000000000-ffffffffffffffff (prio 0, i/o): system
    0000000000000000-000000000fffffff (prio 0, ram): memory@0

address-space: I/O
  0000000000000000-000000000000ffff (prio 0, i/o): io

address-space: cpu-memory-0
  0000000000000000-000000000fffffff (prio 0, ram): memory@0
StanOverflow
  • 557
  • 1
  • 5
  • 21
  • 1
    Upstream QEMU doesn't have a "microblaze-fdt" machine model; you should probably say what QEMU fork you're using... – Peter Maydell May 06 '20 at 15:55
  • dts/dtb means operating system, but you said baremetal. – old_timer May 06 '20 at 20:04
  • @old_timer the xilinx tools produce an elf file, you can specify it as "standalone" ie. without an OS, that function in the code is "print", it basically does what you said, write raw characters to the UART memory location. The program seems to run properly when I debug with gdb and step through, I just don't get any serial out of the QEMU terminal. – StanOverflow May 07 '20 at 10:39
  • divide the problem in half get rid of the library call and poke some characters right into the uart tx, get rid of the sandbox, dts/dtb, etc and use your own bootstrap. there may be exceptions but my experience so far is the uarts are more fake than real and you can just jam characters into the tx without initializing the uart. I dont have a microblaze qemu per the comment above so would have done this already... – old_timer May 07 '20 at 12:51
  • Of course LONG before coming to SO this should have been discussed with xilinx directly or through forums. What did they tell you when you asked? – old_timer May 07 '20 at 12:57
  • @old_timer thanks, I will try that, I did ask on the Xilinx forums, rather frustratingly it was marked as spam, perhaps someone considered QEMU outside the scope of the embedded tools forum. – StanOverflow May 07 '20 at 13:28
  • @old_timer could you point me at something that would explain "without sandbox", or without dts/dtb? Thanks – StanOverflow May 07 '20 at 13:30
  • @old_timer I added some information from monitor -> info mtree, if you could have any other ideas it would be much appreciated – StanOverflow May 10 '20 at 21:02

0 Answers0