This design note is to document a set of steps in Vitis and PetaLinux that will create a system with Linux on the APU and bare metal on each of the R5s in the RPU of a Versal device (on the in this example a VCK190) which utilize . Libmetal will be used to communicate between the APU and RPU.
In this system the APU will boot first and bring up and initialize each of the R5s. Example applications for the R5s and Linux on the APU will be created to utilize many features of Libmetal.
...
This demonstration leverages Versal Libmetal Demo and UG1186, the Libmetal AMP Demo in (UG1186). In each of those references there is only a single R5 instance running along with a single Linux application interacting with it. For this exercise the R5s will operate in split mode with each having its own application. There will be two Linux applications, each paired with an R5 instance.
General Steps
It is assumed that you have an XSA exported from a Vivado project for the VCK190 which incorporates the requirements noted in the Appendix
Create bare metal applications for each of the R5s which use Libmetal and have been configured to run on the respective core.
Create a PetaLinux project which includes Libmetal with a properly configured device tree and make the resultant sysroot available for the creation of the Linux applications.
Create Linux applications which will utilize use Libmetal to communicate with each of the R5s respectively.
Integrate the R5 bare metal applications as well as the Linux applications into the Linux image and package the project to be deployed on the target board.
Deploy the packaged project on the VCK190 and exercise the various included Libmetal functions.
...
PetaLinux Pass 1 : Create a PetaLinux project for the VCK190 using its BSP, configure the project, and create a sysroot which can be utilized used in Vitis for the creation of the Linux applications.
...
PetaLinux Pass 2 : Integrate the R5 and Linux apps into the Linux image, configure the PetaLinux project, build, and package.
Deploy & and Test : Provision the VCK190 to boot into the demo and run the demo.
Vitis Pass 1 & and 2 can be merged if PetaLinux Pass 1 is completed first.
...
Create a Vitis project in a workspace named vitis_prj
.
Close the welcome tab.
Select File->New->Platform Project…
Platform Project Name: VCK190_hw
Click Next
Under the tab "Create a new platform from hardware (XSA)' use the
drop down menu to select vck190
Set the Processor to versal_cips_0_pspmc_0_psv_cortexr5_0
Click Finish
Modify the
versal_cips_0_pspmc_0_psv_cortexr5_0
Domain.
Use Modify BSP Settings… to add the LibMetal library
...
Create bare metal application for R5-0
Select File->New->Application Project…
Click Next
Click Next (use the newly created platform and domain)
Application project name: my-R5-0-app
Click Next
Select Libmetal AMP Demo
Click Finish
Modify the
my-R5-0-app
application. The changes are to define the shared memory region between R5-0 and the APU (adjusted because another region for the R5-1 & APU will be needed) as well as make the print statements easily identifiable to R5-0.
...
Use Modify BSP Settings… to add the LibMetal library
Build the platform.
Select File->New->Application Project . . .
Click Next
Click Next (use the VCK190_hw plaform)
...
Choose the R5-1 processor
Click Next
Select Libmetal AMP Demo
Click Finish
Modify the
my-R5-1-app
application. The changes are to define the shared memory region between R5-1 and the APU (accounting for the region allocated to R5-0 & APU) as well as make the print statements easily identifiable to R5-1. Additionally, a different IPI channel is being used for the R5-1 communications with the APU than the one for the R5-0 so its corresponding base address, interrupt vector ID and mask are adjusted accordingly. Lastly, a different TTC is used for R5-1 so its corresponding values are modified.
...
Build the application by right clicking on it and selecting Build Project.
PetaLinux Pass 1
Create and configure the
...
PetaLinux project
Create the project using the VCK190 BSP.
...
Code Block |
---|
petalinux-config --get-hw-description=./vivado_prj/HSI |
Build and package the
...
PetaLinux project
Build and package the sysroot.
Code Block |
---|
petalinux-build -s petalinux-package --sysroot petalinux-build |
Vitis Pass 2
Create the platform for
...
Linux applications
Create a new platform project (for Linux) in the original workspace.
Select File->New->Platform Project…
Platform Project Name : libmetaldemo-plat
...
Operating system : linux
Processor : psv_cortexa72
Click Finish
In the platform.spr for libmetaldemo-plat select the 'linux on psv_cortexa72’ setting group.
...
Create a new application project (Libmetal).
Select File->New->Application Project…
Use the libmetaldemo-plat platform, Next
...
Template : Linux Empty Application
Click Finish
Open C/C++ Build Settings on the app.
C/C++ Settings->ARM v8 Linux gcc linker->Libraries
add metal
as a library
Click Apply and Close
Clone the Libmetal repository to get the example code.
...
Import the following source files from <>/libmetal/examples/system/linux/zynqmp/zynqmp_amp_demo by right clicking on the app, selecting Import Sources… and navigating to the directory just noted.
...
Build the application by right clicking on it and selecting Build Project.
Create
...
Linux application paired to R5-1
Create a new application project (Libmetal).
Select File->New->Application Project…
Use the libmetaldemo-plat platform, click Next
Application project name : my-lm-linux-app1
...
Template : Linux Empty Application
Click Finish
Open C/C++ Build Settings on the app.
C/C++ Settings->ARM v8 Linux gcc linker->Libraries
add metal as a library
Click Apply and Close
Import the same set of source files from
<>/libmetal/examples/system/linux/zynqmp/zynqmp_amp_demo
as was done formy-lm-linux-app0
.Add the compiler flag
CONFIG_IPI_MASK=0x10
under ARM v8 Linux gcc compiler symbols. This will select a different IPI channel from what is used formy-lm-linux-app0
.
...
Copy in pre-built apps for APU & and RPU.
Code Block |
---|
cd <>/plnx_prj/project-spec/meta-user/recipes-apps/my-lm-linux-app0/files cp <>/vitis_prj/my-lm-linux-app0/Debug/my-lm-linux-app0.elf . cp <>/vitis_prj/my-R5-0-app/Debug/my-R5-0-app.elf . |
Replace the contents of
<>/plnx_prj/project-spec/meta-user/recipes-apps/my-lm-linux-app0/my-lm-linux-app0.bb
with the code below. This adds references to the apps for R5-0 and APU (app0), notes dependencies for the linux Linux app, and instructs where to locate these apps in the root file system.
...
Copy in pre-built apps for APU & and RPU.
Code Block | ||
---|---|---|
| ||
cd <>/plnx_prj/project-spec/meta-user/recipes-apps/my-lm-linux-app1/files cp <>/vitis_prj/my-lm-linux-app1/Debug/my-lm-linux-app1.elf . cp <>/vitis_prj/my-R5-1-app/Debug/my-R5-1-app.elf . |
Replace the contents of
<>/plnx_prj/project-spec/meta-user/recipes-apps/my-lm-linux-app1/my-lm-linux-app1.bb
with the code below. This adds references to the apps for R5-1 and APU (app1), notes dependencies for the linux Linux app, and instructs where to locate these apps in the root file system.
...
Exit all the way out, saving the configuration changes when prompted.
Build and package
...
PetaLinux project
Rebuild and package the PetaLinux project.
Code Block |
---|
petalinux-build petalinux-package --boot --format BIN --u-boot --force |
Deploy
...
and Test
Prepare test platform
Copy
BOOT.BIN
,boot.scr
, andimage.ub
onto SD card.Power up the VCK190 with the SD inserted and boot mode set to SD.
...
Execute tests
At the Linux prompt, execute the following.
Code Block |
---|
sudo su - echo pm_request_node 0x18224024 0x7 0x64 0 > /sys/kernel/debug/zynqmp-firmware/pm echo pm_request_node 0x18224025 0x7 0x64 0 > /sys/kernel/debug/zynqmp-firmware/pm echo my-R5-0-app.elf > /sys/class/remoteproc/remoteproc0/firmware echo my-R5-1-app.elf > /sys/class/remoteproc/remoteproc1/firmware echo start > /sys/class/remoteproc/remoteproc0/state echo start > /sys/class/remoteproc/remoteproc1/state my-lm-linux-app0.elf my-lm-linux-app1.elf |
...
In the Vivado project it is necessary to ensure that the Inter-Processor Interrupts (IPI) and the Triple Timer Counters (TTCs) are properly enabled / configured.
The IPIs are used for communications between the APU and R5-0 / R5-1. The TTCs are used to measure time intervals in the demo applications.
See below for where this is done in the CIPS wizard.
...
Related Links
UG643 - OS & Libs Doc and Libraries Documentation Collection, Enumeration XPmNodeId values
https://github.com/Xilinx/linux-xlnx/blob/master/include/dt-bindings/power/xlnx-versal-power.h#L15
...