RunningXilinxOEWithZephyrQEMU - pfalcon/openamp-system-reference GitHub Wiki

Reference instructions to build Xilinx OpenAMP image: https://docs.google.com/document/d/1pfUR177hAsQQrclR1Osz5rM8wAdFjL5GTL38OB5eqfY/edit

The idea: run an image built in such a way using Xilinx QEMU as included in Zephyr SDK (where it's primary used for emulation of BOARD=qemu_cortex_r7).

As of Zephyr SDK 0.13.1, sysroots/x86_64-pokysdk-linux/usr/bin/qemu-system-xilinx-aarch64 is 5.0.0 (v2.6.0-32592-gfe968e21be-dirty). Running the OpenAMP image requires aarch64 and microblazeel QEMU binaries (the latter is for PMU functionality, required to boot image). The version built by Xilinx OE (PetaLinux 2021.1) is 5.1.0 (v2.6.0-35778-ge40b634b24-dirty). Running Zephyr's qemu-aarch64 5.0.0 against OE's qemu-microblazeel 5.1.0 leads to a crash.

https://github.com/zephyrproject-rtos/sdk-ng/pull/404 was submitted to upgrade Zephyr's version to that of PetaLinux 2021.1. It's merged as of now and intended to be included in Zephyr SDK 0.13.2. With it, it's possible to run Zephyr's qemu-system-xilinx-aarch64 against OE's qemu-system-microblazeel successfully, the image boots.

Further patch https://github.com/zephyrproject-rtos/sdk-ng/pull/406 (merged as of now too) was posted to add qemu-system-xilinx-microblazeel to Zephyr SDK. With it, it's possible to run a complete OpenAMP image with just Zephyr SDK (e.g., it would be possible to provide test/sample images for download (e.g. from CI), and let people to run them with just Zephyr SDK tools, which is more cross-vendor, without requiring huge vendor-specific downloads).

The described changes should be available in Zephyr SDK 0.13.2 (or 0.14).

The actual script to run the image is along the lines:

mkdir -p /tmp/tmpkt1flce7

#QEMU_M=/mnt/hdd/projects-3rdparty/Embedded/OE-Linaro/xilinx_yocto/build/tmp/work/x86_64-linux/qemu-xilinx-helper-native/1.0-r1/recipe-sysroot-native/usr/bin/qemu-system-microblazeel
QEMU_M=/home/pfalcon/projects-3rdparty/Embedded/Zephyr/sdk-ng/xtract/sysroots/x86_64-pokysdk-linux/usr/xilinx/bin/qemu-system-microblazeel

#PMU instance cmd: 
$QEMU_M \
-M microblaze-fdt -display none -hw-dtb /mnt/hdd/projects-3rdparty/Embedded/OE-Linaro/xilinx_yocto/build/tmp/deploy/images/zcu102-zynqmp/qemu-hw-devicetrees/multiarch/zynqmp-pmu.dtb \
-kernel /mnt/hdd/projects-3rdparty/Embedded/OE-Linaro/xilinx_yocto/build/tmp/deploy/images/zcu102-zynqmp/pmu-rom.elf \
-device loader,file=/mnt/hdd/projects-3rdparty/Embedded/OE-Linaro/xilinx_yocto/build/tmp/deploy/images/zcu102-zynqmp/pmu-firmware-zcu102-zynqmp.elf -device loader,addr=0xfd1a0074,data=0x1011003,data-len=4 \
-device loader,addr=0xfd1a007C,data=0x1010f03,data-len=4 -machine-path /tmp/tmpkt1flce7 &

sleep 1

#APU instance cmd: 
#QEMU=/home/pfalcon/opt/zephyr-sdk-0.13.1/sysroots/x86_64-pokysdk-linux/usr/bin/qemu-system-aarch64
#QEMU=/home/pfalcon/opt/zephyr-sdk-0.13.1/sysroots/x86_64-pokysdk-linux/usr/xilinx/bin/qemu-system-aarch64
#QEMU_A=/mnt/hdd/projects-3rdparty/Embedded/OE-Linaro/xilinx_yocto/build/tmp/work/x86_64-linux/qemu-xilinx-helper-native/1.0-r1/recipe-sysroot-native/usr/bin/qemu-system-aarch64
QEMU_A=/home/pfalcon/projects-3rdparty/Embedded/Zephyr/sdk-ng/xtract/sysroots/x86_64-pokysdk-linux/usr/xilinx/bin/qemu-system-aarch64

#echo 
sudo $QEMU_A \
-net nic -net nic -net nic -net nic,netdev=net0,macaddr=52:54:00:12:34:02 -netdev tap,id=net0,ifname=tap1,script=no,downscript=no \
-drive if=sd,index=1,file=/mnt/hdd/projects-3rdparty/Embedded/OE-Linaro/xilinx_yocto/build/tmp/deploy/images/zcu102-zynqmp/openamp-image-minimal-zcu102-zynqmp-20211005112258.rootfs.wic.qemu-sd,format=raw \
-nographic -serial mon:stdio -serial null \
-hw-dtb /mnt/hdd/projects-3rdparty/Embedded/OE-Linaro/xilinx_yocto/build/tmp/deploy/images/zcu102-zynqmp/qemu-hw-devicetrees/multiarch/zcu102-arm.dtb \
-global xlnx,zynqmp-boot.cpu-num=0 \
-global xlnx,zynqmp-boot.use-pmufw=true \
-device loader,file=/mnt/hdd/projects-3rdparty/Embedded/OE-Linaro/xilinx_yocto/build/tmp/deploy/images/zcu102-zynqmp/arm-trusted-firmware.elf,cpu-num=0 \
-device loader,file=/mnt/hdd/projects-3rdparty/Embedded/OE-Linaro/xilinx_yocto/build/tmp/deploy/images/zcu102-zynqmp/u-boot.elf \
-device loader,file=/mnt/hdd/projects-3rdparty/Embedded/OE-Linaro/xilinx_yocto/build/tmp/deploy/images/zcu102-zynqmp/system.dtb,addr=0x100000 \
-boot mode=5 \
-machine arm-generic-fdt -m 4096 -machine-path /tmp/tmpkt1flce7

(Note: pmu-rom.elf, a MicroBlaze image, is required for the commands above, which, as of now, requires downloading large vendor archives with click-thru licensing.)