Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

This page is intended to complement  UG1186 "LibMetal and OpenAMP User Guide"  for Zynq-7000 and Zynq UltraScale+ MPSoC.

...

Here are the basic steps to boot Linux and run an OpenAMP application using pre-built images.

e.g for ZCU102:
The echo-test application sends packets from Linux running on quad-core Cortex-A53 to a single Cortex-R5 core within the Cortex-R5 cluster running FreeRTOS which sends them back.

Extract the files to boot Linux from u-boot prompt rom a pre-built PetaLinux BSP.  Ensure that openamp.dtb file is used as the system.dtb does not have OpenAMP R5 Remoteproc device tree nodes.

Code Block
themeMidnight
host shell$ tar xvf xilinx-zcu102-v2020.2-final.bsp --strip-components=4 --wildcards  */Image */openamp.dtb */rootfs.cpio.gz.u-boot
host shell$ petalinux-boot --jtag --prebuilt 2 --hw_server-url <hostname:3121> # boot to u-boot prompt on the board



Note

Note: Alternatively, if you already created a PetaLinux project with a provided BSP for your board, pre-built images can also be found under the <your project>/pre-built/linux/images/ directory.

Make sure you have configured TFTP server in host.

...

For ZynqMP and Versal platforms that are using OpenAMP R5 remoteproc kernel driver running on Linux in Cortex A cluster, ensure that Kernel Config option SPARSE_VMEMMAP is enabled. The reasoning is as follows:

 If CONFIG_SPARSEMEM_VMEMMAP is not set, then kernel will try to find a page to get the physical page frame number from.

In other words the OpenAMP-related device tree has DDR memory spaces for IPC carved out such that the kernel does not map these in (hence these should be in the reserved-memory node). Once these are carved out on the A-cluster, then the pages that are needed without CONFIG_SPARSEMEM_VMEMMAP  are not present. E.g. the pfn's are not present.

So to make sure that the pages for these reserved-mem nodes can be found, enable CONFIG_SPARSEMEM_VMEMMAP so that vmemmap will be called and subsequently the PFN's that contain these carveouts can be found.

For more documentation on the memory model see on the kernel config option SPARSE_VMEMMAP see https://www.kernel.org/doc/Documentation/vm/memory-model.rst 

...

Xilinx OpenAMP and LibMetal related code

The following locations provide access to the code:

...

Target Remote ProcessorConfiguration Information
RPU 0

use default application in PetaLinux BSP: build with petalinux-build -c openamp-fw-echo-testd

RPU 1

In PetaLinux project, modify <plnx proj root>/components/yocto/layers/meta-xilinx-tools/recipes-openamp/examples/openamp-fw.inc :  XSCTH_PROC_zynqmp ?= "psu_cortexr5_0" to "psu_cortexr5_1"

Device Tree

Append the following to <plnx proj root>/ project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi

...

ZynqMP RPU to manage Linux


Note

Please note that this example is release specific.


Note

NOTE: RPU slave applications presently are only supported by default to run in TCM. What this means in practice is that for RPU to load and start other RPU, the entirety of the slave application must be loaded and run in TCM. APU remoteproc slave does support running application in DDR.


Create R5-0 standalone BSP

...

Note

NOTE: make sure that Cortex-R5 BSP has XilPM and GIC software components built. XilPM is used to interface with the ZU+ PMUFW to bring up RPU. The GIC is needed as IPIs are the mechanism by which to communicate with the XilPM framework.

Build Libmetal

To build the OpenAMP application a Xilinx Cortex-R5 BSP and the Libmetal library are needed. This section details how to build the Libmetal library.

Libmetal is built using CMake. An example toolchain file is below:

Code Block
themeMidnight
set (CMAKE_SYSTEM_PROCESSOR "arm"           CACHE STRING "")
set (MACHINE        "zynqmp_r5" CACHE STRING "")
  
set (CROSS_PREFIX           "armr5-none-eabi-" CACHE STRING "")
set (CMAKE_C_FLAGS          "-mfloat-abi=hard -mcpu=cortex-r5 -mfpu=vfpv3-d16  -Wall -Werror -Wextra \
   -flto -Os -I<path to bsp>/bsp/psu_cortexr5_0/include" CACHE STRING "")
  
link_directories(
<path to bsp>/bsp/psu_cortexr5_0/lib
)
set (PLATFORM_LIB_DEPS      "  -lxil -lxilstandalone  -lc -lm  -lxilpm " CACHE STRING "")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto")
SET(CMAKE_AR  "gcc-ar" CACHE STRING "")
SET(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> qcs <TARGET> <LINK_FLAGS> <OBJECTS>")
SET(CMAKE_C_ARCHIVE_FINISH   true)
include (cross-generic-gcc)

...

Code Block
themeMidnight
git clone https://github.com/openamp/libmetal.git
cd libmetal
   
mkdir build_r5
cd build_r5
cmake .. -DCMAKE_TOOLCHAIN_FILE=<toolchain_file>  \
-DCMAKE_LIBRARY_PATH=<path to bsp>/bsp/psu_cortexr5_0/lib 
   
make DESTDIR=. install VERBOSE=1

Build OpenAMP library and application

OpenAMP is built using CMake. An example toolchain file is below:

Code Block
themeMidnight
set (CMAKE_SYSTEM_PROCESSOR "arm" CACHE STRING "")
    set (MACHINE                zynqmp_r5 )
    set (CROSS_PREFIX           "armr5-none-eabi-" CACHE STRING "")
    set (CMAKE_C_FLAGS          "-mfloat-abi=hard -mcpu=cortex-r5 -Os -flto -mfpu=vfpv3-d16 -DUNDEFINE_FILE_OPS \
    -I<path to libmetal repo>/libmetal/build_r5/usr/local/include \
    -I<bsp path>/bsp/psu_cortexr5_0/include" CACHE STRING "")
    set (CMAKE_ASM_FLAGS        " -mcpu=cortex-r5  " CACHE STRING "")
    set (PLATFORM_LIB_DEPS      "  -lxil -lxilstandalone  -lxilpm -lxilmem -lc -lm" CACHE STRING "")
    SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -flto ")
    SET(CMAKE_AR  "gcc-ar" CACHE STRING "")
    SET(CMAKE_C_ARCHIVE_CREATE "<CMAKE_AR> qcs <TARGET> <LINK_FLAGS> <OBJECTS>")
    SET(CMAKE_C_ARCHIVE_FINISH   true)
    link_directories(
<path to libmetal repo>/libmetal/build_r5/usr/local/include/
<path to libmetal repo>/libmetal/build_r5/usr/local/lib/
        )
   set (WITH_LOAD_FW ON)
   set (CMAKE_FIND_ROOT_PATH <path to LibMetal repo>/libmetal/build/usr/local/lib <bsp path>/bsp/psu_cortexr5_0/lib )
    include (cross_generic_gcc)
    string (TOLOWER "FreeRTOS"                PROJECT_SYSTEM)
    string (TOUPPER "FreeRTOS"                PROJECT_SYSTEM_UPPER)
# vim: expandtab:ts=2:sw=2:smartindent

...

Code Block
themeMidnight
git clone https://github.com/openamp/open-amp.git
cd open-amp
mkdir build
cd build
cmake .. \
 -DCMAKE_TOOLCHAIN_FILE=toolchain \
 -DCMAKE_INCLUDE_PATH="<path to LibMetal repo>/libmetal/build_r5/lib/include/;<path to bsp>/bsp/psu_cortexr5_0/include/" \
 -DCMAKE_LIBRARY_PATH="<path to LibMetal repo>/libmetal/build_r5/usr/local/lib/<path to bsp>/bsp/psu_cortexr5_0/lib/" -DWITH_APPS=on -DWITH_LOAD_FW=ON
make DESTDIR=$(pwd) install VERBOSE=1


Note


Note: how to set remoteproc elf-load slave

  1. If RPU1 is slave, add thef ollowing after -DWITH_LOAD_FW=ON, add -DLOAD_FW_TARGET=NODE_RPU_1
  2. If APU is slave, add thef ollowing after -DWITH_LOAD_FW=ON, add -DLOAD_FW_TARGET=NODE_APU_1

Boot ZynqMP OpenAMP Cortex-R5 application on hardware

To boot up to u-boot on target zcu102 see the following directions:

In XSDB do the following:

...