By Adam Taylor

The Zynq UltraScale MPSoC is a complex system on chip containing as many as four Arm Cortex-A53 application processors, a dual-core Arm Cortex-R5 real-time processor, a Mali GPU, and of course programmable logic. When it comes to generating our software application, we want to use the A53-based Application Processing Unit (APU) and R5 Real-Time Processing Unit (RPU) cores appropriately. This means we want to use the APU for computationally intensive, high-level applications or virtualization while using the RPU for real-time control and monitoring.

This means the APU will likely be running an operating system such as Linux while the real-time needs are addressed by the RPU using bare-metal software or a simplified OS such as FreeRTOS. Often an overall system solution requires communication between the APU and RPU to achieve the desired solution functionality but communication between different processors running different applications has previously been challenging and ad-hoc with inter-processor communications (IPC) using shared memory, mail boxes, or even networks for IPC. As a result, IPC solutions differed from implementation to implementation and device to device, which increased development time and hence time to market.

This is inefficient engineering.

To best leverage the capabilities of the UltraScale+ Zynq MPSoC, we need an open framework that allows us to abstract device-specific interfaces and enables the implementation of AMP (asymmetric multi-processing) with greater ease across multiple projects.

OpenAMP developed by the Multicore Association provides everything we need to run different operating systems on the APU and RPU. Of course, for OpenAMP to function from processor to processor, we need an abstraction layer that provides device-specific interfaces (e.g. interrupt handlers, memory requests, and device access). The libmetal library provides these for Xilinx devices through several APIs that abstract the processor.

OpenAMP Stack

For our Zynq UltraScale+ MPSoC designs, the provided OpenAMP frameworks enable messaging between the master processor and remote processor and lifecycle management of the remote processor using the following structures:

Remoteproc – enables lifecycle management of the remote processor. This includes downloading the application to the remote processor, stopping and starting the remote processor, and system resource allocation as required.

RPMsg - supports IPC between different processors in the system.

OpenAMP remoteproc and RPMsg concepts

For this example, we are going to run Linux on the APU and a bare-metal application on the RPU using RPMsg within the kernel space. When we run the RPMsg from within the kernel space, the remote application lifecycle must be managed by Linux. This means the remote processor application does not run independently. If we develop the RPMsg application to run within the Linux user space, the remote processor can run independently.

To create this example first we need to enable remote-processor support within our Linux build. This requires that we rebuild the petalinux project, customising the kernel and root fs. If you are not familiar with building petalinux you might want to read this blog.

Within our petalinux project, the first thing we need to do is enable the remoteproc driver. Using a terminal application within the petalinux project, issue the command:

petalinux-config -c kernel

This will open the kernel configuration menu. Here we can enable the remote-processor drivers which are located under:

Device Drivers -> Remoteproc drivers

Enabling the Remoteproc drivers

The second step is to include the OpenAMP examples within the file system. Again inside the project, issue the command:

petalinux-config -c rootfs

Within the configuration menu, navigate to Filesystem Packages -> misc and enable the packagegroup-petalinux-openamp:

Enabling the package group

The final step before we can rebuild the petalinux image is to update the device tree. We can find an OpenAMP template dtsi file at the location:

petalinux/components/yocto/source/arm/layers/meta-openamp/recipes-bsp/device-tree/files/zynqmp/

Within this location you will find example device trees for both the lockstep and split running modes of the RPU cores.

Select the dtsi file with the desired operating mode and copy the contents into the system-user.dtsi at the following location:

petalinux/<project>/project-spec/meta-user/recipes-bsp/device-tree/files/system-user.dtsi

Once the kernel, filesystem, and device tree have been updated, rebuild the petalinux image using the command below:

petalinux-build

This will generate an updated Linux build that we can copy onto the boot medium of choice and run on our Zynq UltraScale+ MPSoC design.

Using a terminal connected to our preferred development board (in my case the UltraZed), we can test the OpenAMP examples we included within the Linux file System. There are three examples provided: echo test, matrix multiplication, and proxy server.

I ran the matrix-multiply example because it demonstrates the remote processor performing mathematical calculations.

Using the terminal, I entered the following commands:

echo image_matrix_multiply > /sys/class/remoteproc/remoteproc0/firmware echo start > /sys/class/remoteproc/remoteproc0/state modprobe rpmsg_user_dev_driver mat_mul_demo

Following the on-screen menu and commands, I ran the example which provided the results below:

Executing the Matrix Multiply Example

Matrix Multiply example running

This example shows that the OpenAMP framework is running correctly on the Zynq UltraScale+ MPSoC petalinux build and that we can begin to create our own applications. If you want to run the other two examples refer to UG1186.

If we wish to create our own OpenAMP-based application for the RPU, which uses the kernel space RPMsg, we can create this using the SDK and install the generated elf as an app within petalinux. Although it does mean we need to rebuild the petalinux image again, we will look at how we do this in another blog. There is a lot more for us to explore here.

Note: We have looked at OpenAMP before for the Zynq 7000 series of devices in blogs 169 & 171.

You can find the example source code on GitHub.

Adam Taylor’s Web site is http://adiuvoengineering.com/.

If you want E book or hardback versions of previous MicroZed chronicle blogs, you can get them below.

First Year E Book here

First Year Hardback here.

Second Year E Book here

Second Year Hardback here