Use PetaLinux Tools to complete the following steps:
1. Create the PetaLinux master project in a suitable directory without any spaces. In this guide it is named <plnx-proj-root>:
$ petalinux-create -t project -s <PATH_TO_PETALINUX_ZYNQMP_PROJECT_BSP>
Note: The petalinux bsp's can be found at https://www.xilinx.com/support/download/index.html/content/xilinx/en/downloadNav/embedded-design-tools.html .
2. Navigate to the directory:
$ cd <plnx-proj-root>
3. Enable the required rootfs packages and applications:
$ petalinux-config -c rootfs
4. Ensure libmetal and sysfs packages are enabled:
Filesystem Packages--->
misc --->
sysfsutils --->
[*] libsysfs
Libs --->
libmetal--->
[*] libmetal
Ensure the libmetal demo application is enabled:
Filesystem Packages --->
libs --->
libmetal-->
[*] libmetal-demos
5. Setting Device Tree for the Libmetal Linux Application Demonstration.
The device tree changes need to be added to system-user.dtsi.
Petalinux system-user.dtsi path: <plnx-proj-root>/project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi
Note: Reserved memory node is for shared memory and firmware. This can be moved if you wish to load firmware elsewhere. You need to add device tree nodes manually to the system-user.dtsi file.
For Zynq UltraScale+™ based system use the following device tree overlay example:
/ {
reserved-memory {
#address-cells = <2>;
#size-cells = <2>;
ranges;
rproc_0_reserved: rproc@3ed000000 {
no-map;
reg = <0x0 0x3ed00000 0x0 0x2000000>;
};
};
tcm_0a@ffe00000 {
no-map;
reg = <0x0 0xffe00000 0x0 0x10000>;
phandle = <0x40>;
status = "okay";
compatible = "mmio-sram";
power-domain = <&zynqmp_firmware 15>;
};
tcm_0b@ffe20000 {
no-map;
reg = <0x0 0xffe20000 0x0 0x10000>;
phandle = <0x41>;
status = "okay";
compatible = "mmio-sram";
power-domain = <&zynqmp_firmware 16>;
};
rf5ss@ff9a0000 {
compatible = "xlnx,zynqmp-r5-remoteproc";
xlnx,cluster-mode = <1>;
ranges;
reg = <0x0 0xFF9A0000 0x0 0x10000>;
#address-cells = <0x2>;
#size-cells = <0x2>;
r5f_0 {
compatible = "xilinx,r5f";
#address-cells = <2>;
#size-cells = <2>;
ranges;
sram = <0x40 0x41>;
memory-region = <&rproc_0_reserved>;
power-domain = <&zynqmp_firmware 7>;
};
};
amba {
compatible = "simple-bus";
u-boot,dm-pre-reloc;
#address-cells = <0x2>;
#size-cells = <0x2>;
ranges;
/* Shared memory */
shm0: shm@0 {
compatible = "shm_uio";
reg = <0x0 0x3ed80000 0x0 0x1000000>;
};
/* Inter-Processor Interrupt */
ipi_amp: ipi@ff340000 {
compatible = "ipi_uio";
reg = <0x0 0xff340000 0x0 0x1000>;
interrupt-parent = <&gic>;
interrupts = <0 29 4>;
};
};
};
&ttc0 {
status = "okay";
}
The shm0 device tree node is used by the Libmetal application for shared memory starting at the address 0x3ed80000.
The tcm0a, tcm0b and rf5ss nodes in the device tree overlay are needed only if system users plan to load their RPU firmware via the remoteproc Linux driver.
Note: Firmware memory needs to correspond to the firmware's linker script. An example linker script for this application can be found at: https://github.com/OpenAMP/libmetal/blob/master/examples/system/generic/zynqmp_r5/zynqmp_amp_demo/lscript.ld .
For a Versal based system, please, change "power-domain = <&versal_firmware 0x18110005>; and replace the ipi_amp node with the following:
ipi_amp: ipi@ff360000 {
compatible = "ipi_uio";
reg = <0x0 0xff360000 0x0 0x1000>;
interrupt-parent = <&gic>;
interrupts = <0 33 4>;
};
For Zynq systems the device tree overlay:
/ {
reserved-memory {
#address-cells = <1>;
#size-cells = <1>;
ranges;
rproc_0_reserved: rproc@3e000000 {
no-map;
reg = <0x3e000000 0x400000>;
};
rproc_0_dma: rproc@3e800000 {
no-map;
compatible = "shared-dma-pool";
reg = <0x3e800000 0x100000>;
};
};
remoteproc0: remoteproc@0 {
compatible = "xlnx,zynq_remoteproc";
firmware = "firmware";
vring0 = <15>;
vring1 = <14>;
memory-region = <&rproc_0_reserved>, <&rproc_0_dma>;
};
};
The source code of the libmetal example on the Linux side can be found on the following web site:
https://github.com/OpenAMP/libmetal/tree/master/examples/system/linux/zynqmp/zynqmp_amp_demo
• common.h
• ipi_latency_demo.c
• ipi_shmem_demo.c
• ipi-uio.c
• libmetal_amp_demo.c
• shmem_atomic_demo.c
• shmem_demo.c
• shmem_latency_demo.c
• shmem_throughput_demo.c
• sys_init.c
• sys_init.h
Note: If you are using https://github.com/Xilinx/libmetal.git sources, look in the CMakeLists.txt (For Example:examples/system/freertos/zynqmp_r5/zynqmp_amp_demo/CMakeLists.txt) to find the correct definitions for the following based on your ZynqMP or Versal target architecture.
° CONFIG_IPI_DEV_NAME
° CONFIG_TTC_DEV_NAME
° CONFIG_IPI_MASK