It recently came to our attention at Avnet that PetaLinux QEMU boot was broken for our MicroZed SOMs, and possibly also broken for PicoZed, UltraZed, MiniZed, and Ultra96-V2. After spending some time to dive in and debug this problem we discovered that QEMU was failing on the node in the device tree for the Ethernet PHY, specifically the “compatible =" string. For example, the fix to get QEMU working for MicroZed was as simple as changing the lower case ‘88e1510’ to upper case ‘88E1510’ as in "compatible = "marvell,88E1510"". Interesting that this setting is case-sensitive for QEMU boot, but never appeared to matter when booting this OS image on MicroZed hardware. That explains why we never caught this oversight previously. I must admit I rarely use QEMU since I am lucky enough to always (or nearly always) have actual hardware to boot and test on. Lesson learned! Add QEMU boot to the BSP release test plan from now on! These devicetree fixes will be incorporated into the upcoming PetaLinux 2020.2 BSPs for the MicroZed, PicoZed, UltraZed, MiniZed, and Ultra96-V2.
Changing this devicetree setting to "compatible = "marvell,88E1510"" does produce a warning during boot, though, but this can be safely ignored:
[Firmware Warn]: /amba/ethernet@e000b000/phy@0: Whitelisted compatible string. Please remove Marvell 88E1149R e000b000.ethernet-ffffffff:00: attached PHY driver [Marvell 88E1149R] (mii_bus:phy_addr=e000b000.ethernet-ffffffff:00, irq=POLL)
Once the PetaLinux OS image is built (or BSP is installed), booting QEMU in PetaLinux for MicroZed is remarkably easy. The following command will fetch the boot binaries from the prebuilt folder in the PetaLinux project and will boot the MicroZed Linux OS image in QEMU, with the host PC emulating the MicroZed's Zynq processing system:
$ petalinux-boot --qemu --prebuilt 3
Once the OS is booted you can interact with it just as if it were running on hardware (Login user=root, password=root).
Admittedly this MicroZed example of using QEMU is a simple one since it normally boots using a RAMdisk. It is also possible to boot more sophisticated configurations with QEMU like persistent root file systems such as you would find on the EXT4 partition of an SD card used for hardware boot. You can even setup advanced debug environments and networking so the emulated hardware can be connected to your local LAN. That sounds like a good topic for a future blog, so stay tuned for that!
For more information on QEMU and how to use it in PetaLinux check out Xilinx UG1169 and Xilinx UG1144.