⚠️ This demo is based on PetaLinux 2024.1 release.


  • Download 2024.1 PetaLinux Tools Installer & ZCU102 BSP: https://www.xilinx.com/support/download/index.html/content/xilinx/en/downloadNav/embedded-design-tools/2024-1.html

  • Switch to bash:

    1
    
    $ bash
    
  • Set $SHELL to /bin/bash:

    1
    
    $ export SHELL=/bin/bash
    
  • Disable dash as the default system shell (/bin/sh):

    1
    
    $ sudo dpkg-reconfigure dash
    
    • Select:
  • Install PetaLinux Tools Installer:

    1
    2
    
    $ chmod u+x petalinux-v2024.1-05202009-installer.run
    $ ./petalinux-v2024.1-05202009-installer.run -d install
    
    • Installer will be installed to: ./install
  • Source PetaLinux environments:

    1
    2
    
    $ cd ./install
    $ source settings.sh
    
  • Create project from ZCU102 BSP:

    1
    2
    
    $ petalinux-create project -s xilinx-zcu102-v2024.1-05230256.bsp
    $ cd ./xilinx-zcu102-2024.1
    
    • The project will be created to: ./xilinx-zcu102-2024.1
  • Build OpenAMP dtb:

    1
    
    $ petalinux-config
    
    • Select configs:
      • DTG Settings → Enable openamp dtsi
      • Yocto Settings → Parallel thread execution → Set number of bb threads (BB_NUMBER_THREADS)
        • E.g. 8
    • PetaLinux project config is located at: ./project-spec/configs/config
  • Enable OpenAMP and its examples in rootfs:

    1
    
    $ petalinux-config -c rootfs
    
    • Select the configs:
      • Filesystem Packages → misc → openamp-fw-echo-testd
      • Filesystem Packages → misc → openamp-fw-mat-muld
      • Filesystem Packages → misc → openamp-fw-rpc-demo
      • Petalinux Package Groups → packagegroup-petalinux-openamp → packagegroup-petalinux-openamp
  • Enable Linux Kernel debug info:

    1
    
    $ petalinux-config -c kernel
    
    • Select the configs:
      • Kernel hacking → Kernel debugging
      • Kernel hacking → Compile-time checks and compiler options → Debug information → Rely on the toolchain’s implicit default DWARF version
      • General setup →Compiler optimization level → Optimize for size (-Os)
      • Device Drivers → Character devices → /dev/mem virtual device support
  • If we want to build zynqmp_r5_remoteproc driver into kernel, instead of kernel module:

    • Select the configs:
      • Device Drivers → Remoteproc drivers → Support for Remote Processor subsystem → ZynqMP R5 remoteproc support, choose: y
  • Build the project:

    1
    
    $ nice -19 petalinux-build
    
  • Boot QEMU with Linux kernel and rootfs we just built:

    1
    2
    3
    4
    5
    6
    7
    8
    
    $ petalinux-boot qemu --kernel
    [INFO] Set QEMU tftp to "/tftpboot"
    [INFO] qemu-system-microblazeel -M microblaze-fdt  -serial mon:stdio -serial /dev/null -display none  -kernel /home/frank.chang/Projects/sifive/petalinux/2024.1/xilinx-zcu102-2024.1/images/linux/pmu_rom_qemu_sha3.elf -device loader,file=/home/frank.chang/Projects/sifive/petalinux/2024.1/xilinx-zcu102-2024.1/images/linux/pmufw.elf -hw-dtb /home/frank.chang/Projects/sifive/petalinux/2024.1/xilinx-zcu102-2024.1/images/linux/zynqmp-qemu-multiarch-pmu.dtb -machine-path /tmp/tmp29lts2le -device loader,addr=0xfd1a0074,data=0x1011003,data-len=4 -device loader,addr=0xfd1a007C,data=0x1010f03,data-len=4 &
    Image resized.
    [INFO] qemu-system-aarch64 -M arm-generic-fdt  -serial mon:stdio -serial /dev/null -display none  -device loader,file=/home/frank.chang/Projects/sifive/petalinux/2024.1/xilinx-zcu102-2024.1/images/linux/system.dtb,addr=0x100000,force-raw=on  -device loader,file=/home/frank.chang/Projects/sifive/petalinux/2024.1/xilinx-zcu102-2024.1/images/linux/u-boot.elf -device loader,file=/home/frank.chang/Projects/sifive/petalinux/2024.1/xilinx-zcu102-2024.1/images/linux/Image,addr=0x200000,force-raw=on  -device loader,file=/home/frank.chang/Projects/sifive/petalinux/2024.1/xilinx-zcu102-2024.1/images/linux/ramdisk.cpio.gz.u-boot,addr=0x4000000,force-raw=on  -device loader,file=/home/frank.chang/Projects/sifive/petalinux/2024.1/xilinx-zcu102-2024.1/images/linux/bl31.elf,cpu-num=0 -drive if=sd,format=raw,index=1,file=/home/frank.chang/Projects/sifive/petalinux/2024.1/xilinx-zcu102-2024.1/images/linux/rootfs.ext4 -global xlnx,zynqmp-boot.cpu-num=0 -global xlnx,zynqmp-boot.use-pmufw=true  -global xlnx,zynqmp-boot.drive=pmu-cfg -blockdev node-name=pmu-cfg,filename=/home/frank.chang/Projects/sifive/petalinux/2024.1/xilinx-zcu102-2024.1/images/linux/pmu-conf.bin,driver=file -hw-dtb /home/frank.chang/Projects/sifive/petalinux/2024.1/xilinx-zcu102-2024.1/images/linux/zynqmp-qemu-multiarch-arm.dtb -device loader,file=/home/frank.chang/Projects/sifive/petalinux/2024.1/xilinx-zcu102-2024.1/images/linux/boot.scr,addr=0x20000000,force-raw=on  -gdb tcp:localhost:9000  -net nic -net nic -net nic -net nic,netdev=eth3 -netdev user,id=eth3,tftp=/tftpboot -machine-path /tmp/tmp29lts2le  -m 4G
    qemu-system-microblazeel: Failed to connect to '/tmp/tmp29lts2le/qemu-rport-_pmu@0': No such file or directory
    qemu-system-microblazeel: info: QEMU waiting for connection on: disconnected:unix:/tmp/tmp29lts2le/qemu-rport-_pmu@0,server=on
    qemu-system-aarch64: warning: hub 0 is not connected to host network
    
    • When --kernel is specified, PetaLinux will try to load all the images from <plnx-proj-root>/images/linux/:
      • For Zynq UltraScale+ MPSoC:
        • TF-A image: <plnx-proj-root>/images/linux/bl31.elf
        • U-Boot: <plnx-proj-root>/images/linux/u-boot.elf
        • Linux kernel image: <plnx-proj-root>/images/linux/Image
        • Initrd/Initramfs image: <plnx-proj-root>/images/linux/ramdisk.cpio.gz.u-boot
        • Rootfs (as SD card image): <plnx-proj-root>/images/linux/rootfs.ext4
        • DTB: <plnx-proj-root>/images/linux/system.dtb
        • HW DTB: <plnx-proj-root>/images/linux/zynqmp-qemu-multiarch-arm.dtb
        • … etc
        • P.S. The TF-A boots the loaded kernel image, with PMU firmware running in the background.
  • After booting to Linux shell:

  • Remote debug Linux kernel:

    1
    2
    
    $ petalinux-util gdb linux/image/vmlinux
    (gdb) target remote :9000