1Xilinx Versal Virt (``xlnx-versal-virt``) 2========================================= 3 4Xilinx Versal is a family of heterogeneous multi-core SoCs 5(System on Chip) that combine traditional hardened CPUs and I/O 6peripherals in a Processing System (PS) with runtime programmable 7FPGA logic (PL) and an Artificial Intelligence Engine (AIE). 8 9More details here: 10https://www.xilinx.com/products/silicon-devices/acap/versal.html 11 12The family of Versal SoCs share a single architecture but come in 13different parts with different speed grades, amounts of PL and 14other differences. 15 16The Xilinx Versal Virt board in QEMU is a model of a virtual board 17(does not exist in reality) with a virtual Versal SoC without I/O 18limitations. Currently, we support the following cores and devices: 19 20Implemented CPU cores: 21 22- 2 ACPUs (ARM Cortex-A72) 23 24Implemented devices: 25 26- Interrupt controller (ARM GICv3) 27- 2 UARTs (ARM PL011) 28- An RTC (Versal built-in) 29- 2 GEMs (Cadence MACB Ethernet MACs) 30- 8 ADMA (Xilinx zDMA) channels 31- 2 SD Controllers 32- OCM (256KB of On Chip Memory) 33- XRAM (4MB of on chip Accelerator RAM) 34- DDR memory 35 36QEMU does not yet model any other devices, including the PL and the AI Engine. 37 38Other differences between the hardware and the QEMU model: 39 40- QEMU allows the amount of DDR memory provided to be specified with the 41 ``-m`` argument. If a DTB is provided on the command line then QEMU will 42 edit it to include suitable entries describing the Versal DDR memory ranges. 43 44- QEMU provides 8 virtio-mmio virtio transports; these start at 45 address ``0xa0000000`` and have IRQs from 111 and upwards. 46 47Running 48""""""" 49If the user provides an Operating System to be loaded, we expect users 50to use the ``-kernel`` command line option. 51 52Users can load firmware or boot-loaders with the ``-device loader`` options. 53 54When loading an OS, QEMU generates a DTB and selects an appropriate address 55where it gets loaded. This DTB will be passed to the kernel in register x0. 56 57If there's no ``-kernel`` option, we generate a DTB and place it at 0x1000 58for boot-loaders or firmware to pick it up. 59 60If users want to provide their own DTB, they can use the ``-dtb`` option. 61These DTBs will have their memory nodes modified to match QEMU's 62selected ram_size option before they get passed to the kernel or FW. 63 64When loading an OS, we turn on QEMU's PSCI implementation with SMC 65as the PSCI conduit. When there's no ``-kernel`` option, we assume the user 66provides EL3 firmware to handle PSCI. 67 68A few examples: 69 70Direct Linux boot of a generic ARM64 upstream Linux kernel: 71 72.. code-block:: bash 73 74 $ qemu-system-aarch64 -M xlnx-versal-virt -m 2G \ 75 -serial mon:stdio -display none \ 76 -kernel arch/arm64/boot/Image \ 77 -nic user -nic user \ 78 -device virtio-rng-device,bus=virtio-mmio-bus.0 \ 79 -drive if=none,index=0,file=hd0.qcow2,id=hd0,snapshot \ 80 -drive file=qemu_sd.qcow2,if=sd,index=0,snapshot \ 81 -device virtio-blk-device,drive=hd0 -append root=/dev/vda 82 83Direct Linux boot of PetaLinux 2019.2: 84 85.. code-block:: bash 86 87 $ qemu-system-aarch64 -M xlnx-versal-virt -m 2G \ 88 -serial mon:stdio -display none \ 89 -kernel petalinux-v2019.2/Image \ 90 -append "rdinit=/sbin/init console=ttyAMA0,115200n8 earlycon=pl011,mmio,0xFF000000,115200n8" \ 91 -net nic,model=cadence_gem,netdev=net0 -netdev user,id=net0 \ 92 -device virtio-rng-device,bus=virtio-mmio-bus.0,rng=rng0 \ 93 -object rng-random,filename=/dev/urandom,id=rng0 94 95Boot PetaLinux 2019.2 via ARM Trusted Firmware (2018.3 because the 2019.2 96version of ATF tries to configure the CCI which we don't model) and U-boot: 97 98.. code-block:: bash 99 100 $ qemu-system-aarch64 -M xlnx-versal-virt -m 2G \ 101 -serial stdio -display none \ 102 -device loader,file=petalinux-v2018.3/bl31.elf,cpu-num=0 \ 103 -device loader,file=petalinux-v2019.2/u-boot.elf \ 104 -device loader,addr=0x20000000,file=petalinux-v2019.2/Image \ 105 -nic user -nic user \ 106 -device virtio-rng-device,bus=virtio-mmio-bus.0,rng=rng0 \ 107 -object rng-random,filename=/dev/urandom,id=rng0 108 109Run the following at the U-Boot prompt: 110 111.. code-block:: bash 112 113 Versal> 114 fdt addr $fdtcontroladdr 115 fdt move $fdtcontroladdr 0x40000000 116 fdt set /timer clock-frequency <0x3dfd240> 117 setenv bootargs "rdinit=/sbin/init maxcpus=1 console=ttyAMA0,115200n8 earlycon=pl011,mmio,0xFF000000,115200n8" 118 booti 20000000 - 40000000 119 fdt addr $fdtcontroladdr 120 121Boot Linux as DOM0 on Xen via U-Boot: 122 123.. code-block:: bash 124 125 $ qemu-system-aarch64 -M xlnx-versal-virt -m 4G \ 126 -serial stdio -display none \ 127 -device loader,file=petalinux-v2019.2/u-boot.elf,cpu-num=0 \ 128 -device loader,addr=0x30000000,file=linux/2018-04-24/xen \ 129 -device loader,addr=0x40000000,file=petalinux-v2019.2/Image \ 130 -nic user -nic user \ 131 -device virtio-rng-device,bus=virtio-mmio-bus.0,rng=rng0 \ 132 -object rng-random,filename=/dev/urandom,id=rng0 133 134Run the following at the U-Boot prompt: 135 136.. code-block:: bash 137 138 Versal> 139 fdt addr $fdtcontroladdr 140 fdt move $fdtcontroladdr 0x20000000 141 fdt set /timer clock-frequency <0x3dfd240> 142 fdt set /chosen xen,xen-bootargs "console=dtuart dtuart=/uart@ff000000 dom0_mem=640M bootscrub=0 maxcpus=1 timer_slop=0" 143 fdt set /chosen xen,dom0-bootargs "rdinit=/sbin/init clk_ignore_unused console=hvc0 maxcpus=1" 144 fdt mknode /chosen dom0 145 fdt set /chosen/dom0 compatible "xen,multiboot-module" 146 fdt set /chosen/dom0 reg <0x00000000 0x40000000 0x0 0x03100000> 147 booti 30000000 - 20000000 148 149Boot Linux as Dom0 on Xen via ARM Trusted Firmware and U-Boot: 150 151.. code-block:: bash 152 153 $ qemu-system-aarch64 -M xlnx-versal-virt -m 4G \ 154 -serial stdio -display none \ 155 -device loader,file=petalinux-v2018.3/bl31.elf,cpu-num=0 \ 156 -device loader,file=petalinux-v2019.2/u-boot.elf \ 157 -device loader,addr=0x30000000,file=linux/2018-04-24/xen \ 158 -device loader,addr=0x40000000,file=petalinux-v2019.2/Image \ 159 -nic user -nic user \ 160 -device virtio-rng-device,bus=virtio-mmio-bus.0,rng=rng0 \ 161 -object rng-random,filename=/dev/urandom,id=rng0 162 163Run the following at the U-Boot prompt: 164 165.. code-block:: bash 166 167 Versal> 168 fdt addr $fdtcontroladdr 169 fdt move $fdtcontroladdr 0x20000000 170 fdt set /timer clock-frequency <0x3dfd240> 171 fdt set /chosen xen,xen-bootargs "console=dtuart dtuart=/uart@ff000000 dom0_mem=640M bootscrub=0 maxcpus=1 timer_slop=0" 172 fdt set /chosen xen,dom0-bootargs "rdinit=/sbin/init clk_ignore_unused console=hvc0 maxcpus=1" 173 fdt mknode /chosen dom0 174 fdt set /chosen/dom0 compatible "xen,multiboot-module" 175 fdt set /chosen/dom0 reg <0x00000000 0x40000000 0x0 0x03100000> 176 booti 30000000 - 20000000 177 178