Installing Xen Support on Xilinx ZynqMP

Installing Xen Support on Xilinx ZynqMP

This post explains how to boot Xen + Linux Dom0 from an SD card on the Xilinx ZCU102 Rev 1.1 board. The setup uses a Yocto-generated rootfs but loads Xen manually (outside Yocto recipes) so it’s easy to test different Xen versions, change boot parameters, and debug domain configurations without rebuilding the entire Yocto image.

System Overview (Short Explanation)

The diagram below shows the runtime architecture:

  • Xen owns the CPU/RAM and creates two domains.
  • Dom0 (Linux) handles drivers, backends, and system initialization.
  • Dom2 (Zephyr) receives specific hardware through passthrough (PCIe/GPIO) for real-time RF control.

Everything else (file systems, network, logging, firmware, etc.) stays in Dom0.

Diagram

graph TB subgraph "Hardware" HW_CPU["CPU"] HW_RAM["RAM"] HW_PCIE["PCIe Device"] HW_GPIO["GPIO Pins"] end subgraph "Xen Hypervisor" XEN["Xen (bare-metal)"] end subgraph "Dom0" DOM0["Linux (Dom0)"] BACKENDS["Backend drivers"] end subgraph "Dom2" DOM2["Zephyr (Dom2 Guest)"] RF["RF Control Task"] end HW_CPU --> XEN HW_RAM --> XEN XEN --> DOM0 XEN --> DOM2 HW_PCIE -. "via passthrough" .-> DOM2 HW_GPIO -. "via passthrough" .-> DOM2 DOM0 --> BACKENDS

Boot Script

The following U-Boot script is used to load Xen, Linux, and the device tree blob (DTB) from the SD card. It also demonstrates how to patch the FDT in memory before booting.

setenv xen_addr 0x80000
fatload mmc 0:1 ${xen_addr} xen
setenv fdt_addr 0x1000000
fatload mmc 0:1 ${fdt_addr} system.dtb
fatload mmc 0:1 0x2000000 Image
booti ${xen_addr} - ${fdt_addr}

# Modify FDT in RAM if needed
fdt add
fdt addr ${fdt_addr}
fdt resize
fdt print /chosen
fdt set /chosen bootargs "root=/dev/mmcblk0p2 rw quiet loglevel=0"
fdt set /axi/usb@ff9d0000 status "disabled"

booti ${xen_addr} - ${fdt_addr}

Generate Boot Script Image

Convert your boot.cmd into a bootable U-Boot script image:

mkimage -A arm -T script -C none -n "Xen boot script" -d boot.cmd boot.scr

Set Static IP

If you’re running a minimal Linux system (e.g. via Yocto), network configuration is likely managed by systemd-networkd.

Create or edit:

/etc/systemd/network/10-eth0-static.network

[Match]
Name=eth0

[Network]
Address=192.168.1.100/24
Gateway=192.168.1.1
DNS=8.8.8.8

Disable DHCP (if present)

Check for any .network files with DHCP=yes. If found, rename or remove them to prevent conflicts.

Enable and Restart Networking

systemctl enable systemd-networkd
systemctl restart systemd-networkd

Add Xen Support to the Device Tree

In order for U-Boot and Xen to cooperate, the DTB must be modified to include a chosen node with Xen-specific fields.
Edit the file zynqmp-zcu102-revA.dts and replace or add the following section:

chosen {
    #address-cells = <2>;
    #size-cells = <1>;

    stdout-path = "serial0:115200n8";
    bootargs = "earlycon console=dtuart";

    xen,dom0-bootargs = "console=hvc0 root=/dev/mmcblk0p2 rw earlycon";

    module@0 {
        compatible = "multiboot,module", "multiboot,kernel";
        reg = <0x00000000 0x02000000 0x02000000>;
    };
};

This tells Xen how to find the kernel and pass the correct boot arguments to Linux running as Dom0.


Rebuilding the Kernel and Device Tree

The kernel and DTS sources are usually located under Yocto’s tmp/work-shared directory.
However, it is recommended to extract them into a standalone repository for ease of modification, version control, and iterative compilation.

Example:

make ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- dtbs

Create xen.ub

The xen.ub is a multi-image that bundles Xen, Linux, and the modified device tree into a single U-Boot-friendly file.
It’s typically placed under:

tmp/deploy/images/zcu102-zynqmp/

Steps:

  1. Recompile your modified device tree:
make ARCH=arm64 CROSS_COMPILE=aarch64-unknown-linux-gnu- dtbs
  1. Replace the deployed DTB:
cp ./arch/arm64/boot/dts/xilinx/zynqmp-zcu102-revB.dtb ./tmp/deploy/images/zcu102-zynqmp/system.dtb
  1. Create the multi-image:
mkimage -A arm64 -T multi -C none -n "Xen Image" -d xen:Image:system.dtb xen.ub

Create the SD Card

Use fdisk to create two partitions on the SD card:

  1. FAT32
  2. ext4 (Linux)

Example (GPT layout):

sudo fdisk /dev/sdX
# Use 'n' to create partitions, and 't' to set type (e.g., type c for FAT32)

mkfs.vfat /dev/sdX1
mkfs.ext4 /dev/sdX2

Copy Files:

Copy the following to the FAT32 partition:

  • xen.ub
  • boot.scr
  • Image (Linux kernel)
  • system.dtb

Manual U-Boot Script Execution

To run your boot script manually from the U-Boot shell:

load mmc 0:1 ${loadaddr} boot.scr
source ${loadaddr}

This is useful for debugging or testing different configurations without reflashing the board.


Comments
comments powered by Disqus




Archives

2025 (9)
2022 (3)
2021 (9)
2020 (18)
2014 (4)