FDT support for QEMU/Microblaze


As mentioned in the previous note on Customizing Microblaze emulation, the original microblaze/qemu provided support for a Petalogix Spartan3adsp1800 board only. Thanks to the modifications introduced in that note it was possible to create an external configuration file which listed the peripherals to be included in the emulation, thus enabling the support of any other Microblaze configuration.

As promised in the summary of the note, we have greatly improved this mechanism, so that all the information is extracted directly from the .dtb (Flattened Device Tree file) file and the mb.per file is no longer needed.

To modify the .dtb file simply decompile it with Device Tree Compiler using the following command:

dtc -I dtb -O dts mb.dtb > mb.dts

Once the modifications are performed, the altered data can be compiled back to .dtb file using the following command:

dtc -I dts -O dtb mb.dts > mb.dtb

For example, the uartlite UART is described using Flattened Device Tree file format in the following way:

RS232_Uart_1: serial@84000000 {
    clock-frequency = <125000000>;
    compatible = "xlnx,xps-uartlite-1.00.a";
    current-speed = <115200>;
    device_type = "serial";
    interrupt-parent = <&xps_intc_0>;
    interrupts = < 3 0 >;
    port-number = <0>;
    reg = < 0x84000000 0x10000 >;
    xlnx,baudrate = <0x1c200>;
    xlnx,data-bits = <0x8>;
    xlnx,family = "virtex5";
    xlnx,odd-parity = <0x0>;
    xlnx,use-parity = <0x0>;
} ;

In our modification, only the “compatible”, “interrupts” and “reg” fields are taken into consideration.

The attached .diff file is compatible with the latest QEMU 0.14.1

To include the change, QEMU must be compiled with libfdt support.

It modifies the original petalogix_s3adsp1800_mmu.c so that instead of adding default peripherals it loads the dtb file and dynamically adds peripherals basing on the data from the Flattened Device Tree file.

This modification is released under the GPL.