OpenAMP Project Build Process

This page provides general guidance for using the OpenAMP Application Building process using PetaLinux.

Table of Contents

Introduction

This document describes the process to build linux application using PetaLinux. This also covers booting up your board as well as how to run demo test applications. There is a faster way to test your hardware by using prebuilt images from PetaLinux BSP which is also covered in this document.

PetaLinux - Overview

PetaLinux is an embedded Linux Software Development Kit (SDK) targeting FPGA-based system on a chip (SoC) designs. PetaLinux SDK is a Xilinx development tool that contains everything necessary to build, develop, test, and deploy embedded Linux systems.

The PetaLinux tool contains:

  • Yocto Extensible SDK (eSDK)

  • XSCT (Xilinx Software Command-Line Tool), including XSDB and toolchains

  • PetaLinux CLI tools

PetaLinux needs to be installed first before use - refer to UG1144 - PetaLinux Tools Documentation for the Installation steps and setting up PetaLinux Environment

Building Linux Distribution using PetaLinux including OpenAMP demos

This section covers steps to be followed in order to modify created PetaLinux BSP as per user requirements.

Creating PetaLinux BSP

Create the PetaLinux master project in a suitable directory without any spaces.

$ petalinux-create -t project -s <PATH_TO_PETALINUX_PROJECT_BSP> -n <plnx-user-proj-root>

This will create directory named default project name same as BSP, indicating here as <plnx-user-proj-root>, in the current directory.

Navigate to the directory:

$ cd <plnx-user-proj-root>

PetaLinux Images Quick Try: Prebuilt images are present at <plnx-user-proj-root>/pre-built/linux/images which can directly be used to boot up hardware without doing any further steps. This can be helpful to verify hardware. You can also run demo tests with this prebuilt image.

Include a remote application in the PetaLinux project (Optional)

This step is needed only if you want to add your developed Firmware separately into PetaLinux BSP. Refer to section Building Firmware using PetaLinux.

Enable all of the modules and applications in the RootFS

Open the RootFS configuration menu:

petalinux-config -c rootfs

Select below to ensure OpenAMP applications and RPMsg modules are included

Filesystem Packages ---> -> Petalinux Package Groups -> packagegroup-petalinux-openamp

Select below to include default demo test firmware files

Filesystem Packages ---> misc ---> openamp-fw-echo-testd ---> [*] openamp-fw-echo-testd openamp-fw-mat-muld ---> [*] openamp-fw-mat-muld openamp-fw-rpc-demo ---> [*] openamp-fw-rpc-demo

Setting up Device Tree Binary

The PetaLinux reference BSP includes a DTB (Device Tree Binary) for OpenAMP located at:

<plnx-user-proj-root>/pre-built/linux/images/openamp.dtb

The device tree setting for the shared memory and the kernel remoteproc is demonstrated in:

<plnx-user-proj-root>/project-spec/meta-user/recipes-bsp/device-tree/files/openamp.dtsi

The openamp.dtb and openamp.dtsi files are provided for reference only. You can refer to the contents from these files to edit the system-user.dtsi file to include the content from openamp.dtsi for your project. Either you can copy paste the contents of openamp.dtsi in the system-user.dtsi or you can update system-user.dtsi to include openamp.dtsi (or any other reference dtsi file) as follows:

Append below line in system-user.dtsi:

/include/ "openamp.dtsi" or /include/ "<your-updated-dtsi-filename>.dtsi"

If you do above “include file step” then you will also have to give reference to this file to append device tree recipe as follows:

bbappend file to be updated can be found at:

<plnx-user-proj-root>/project-spec/meta-user/recipes-bsp/device-tree/device-tree.bbappend

Update below line to include openamp.dtsi

SRC_URI:append = " file://config file://system-user.dtsi"

to

SRC_URI:append = " file://config file://system-user.dtsi file://openamp.dtsi"

For OpenAMP version 2022.1 onwards use “:” i.e. SRC_URI:append. For versions 2021.2 and older releases use “_” i.e. SRC_URI_append.

Building the Application and Linux Project

Ensure that you are in the PetaLinux project root directory: <plnx-user-proj-root>

Build PetaLinux: petalinux-build

Clean project:

  • petalinux-build -x distclean - Clean up the project build. Removes tmp files and sstate cache files.

  • petalinux-build -x mrproper - Clean up the project build and the generated bootable images.

Removes <plnx-user-proj-root>/build , <plnx-user-proj-root>/images , <plnx-user-proj-root>/components/plnx_workspace , <plnx-user-proj-root>/components/yocto/workspace

Building Custom Firmware using PetaLinux

This step is needed while Building Linux Application if you have developed and built a remote application (for example, with Xilinx SDK) or you want to add any user application. It must be included in the PetaLinux project so that it is available from the Linux filesystem for remoteproc.

Create a PetaLinux application inside the components/apps/ directory, using the following command:

$ petalinux-create -t apps --template install -n <app-name> --enable

Adding firmware from Xilinx SDK

Copy the firmware (that is, the .elf file) built with Xilinx SDK for the remote processor into this directory:

$ cp <firmware.elf> project-spec/meta-user/recipes-apps/<app-name>/files/

Modify the <plnx-user-proj-root>/project-spec/meta-user/recipes-apps/<app-name>/<app-name>.bb to install the remote processor firmware in the RootFS.

for <app-name>.bb example,

SUMMARY = "Simple test application" SECTION = "PETALINUX/apps" LICENSE = "MIT" LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" SRC_URI = "file://<myfirmware>" S = "${WORKDIR}" INSANE_SKIP:${PN} = "arch" do_install() { install -d ${D}/lib/firmware install -m 0644 ${S}/<myfirmware> ${D}/lib/firmware/<myfirmware> } FILES:${PN} = "/lib/firmware/<myfirmware>"

For OpenAMP version 2022.1 onwards use “:” i.e. INSANE_SKIP:${PN}. For versions 2021.2 and older releases use “_” i.e. INSANE_SKIP_${PN}.

Building Firmware or User Applications

Make sure you are in <plnx-user-proj-root> Petalinux project root directory

  • To rebuild system image along with new application <app-name> : $ petalinux-build

  • To rebuild the selected user application: $ petalinux-build -c <app-name>

To build Firmware using Vitis refer Build RPU Firmware section in OpenAMP Base Hardware Configurations wiki page

Demo Tests Firmware

There are three demo tests available to verify RPMsg interface, Echo test, Matrix Multiply test, and Proxy Application test.

  • Individual demo tests specific code can be found at

https://github.com/OpenAMP/open-amp/tree/main/apps/examples

  • All three demo tests have common source code as follows,

https://github.com/OpenAMP/open-amp/tree/main/apps/machine/zynqmp_r5

The resource table is defined in rsc_table.c and rsc_table.h files that are built into the remote binary and is then parsed by the host application during Remoteproc ELF Load to establish RPMsg IPC. The platform_info.c and platform_info.h files which define platform specific data and implement API’s to set platform specific information for OpenAMP.

  • If you want to do any modifications in demo tests firmware code, then to get the source code from git url specified in meta-layers (as given above), run below command to create firmware specific workspace at <plnx-proj-root>/components/yocto :

petalinux-devtool modify <recipe-name>

for example,

Echo test: petalinux-devtool modify openamp-fw-echo-testd

Matrix multiply test: petalinux-devtool modify openamp-fw-mat-muld

Proxy application test: petalinux-devtool modify openamp-fw-rpc-demo

  • You can find source code files (rsc_table.c, rsc_table.h, platform_info.c, platform_info.h) at <plnx-proj-root>/components/yocto/workspace/sources/<recipe-name>/lib/sw_apps/<demo-test-name>/src/machine/<machine-name>/<filename>

For example, <plnx-proj-root>/components/yocto/workspace/sources/openamp-fw-echo-testd/lib/sw_apps/openamp_echo_test/src/machine/zynqmp_r5/rsc_table.c

  • In case of any changes in files, build Firmware with: petalinux-build -c openamp-fw-echo-testd

  • Verify firmware file is generated at <plnx-proj-root>/components/yocto/workspace/sources/<recipe-name>/<recipe-name>/<rpu-firmware>

For example, <plnx-proj-root>/components/yocto/workspace/sources/openamp-fw-echo-testd/openamp-fw-echo-testd/executable.elf

Booting the PetaLinux Project

You can boot up built-up image virtually from QEMU (Quick Emulator) or from hardware that is either SD card or through JTAG. You can use images from your built images directory i.e. <plnx-user-proj-root>/images/linux or you can also use prebuilt images from <plnx-user-proj-root>/pre-built/linux/images for quick try instead of building whole project.

Booting on QEMU

Ensure that you are in the PetaLinux project root directory: <plnx-user-proj-root>

Run PetaLinux boot:

  • petalinux-boot --qemu --kernel or

  • petalinux-boot --qemu --prebuilt 2 --tftp images/linux

prebuilt option 2 says Boot U-Boot only

directory to refer images from - <plnx-user-proj-root>/images/linux

  • As above both option doesn’t load rootfs, you will have to load it separately as follows.

On boot up it will show message “press any key to stop autoboot” - press any key to stop auto booting here and you can follow below steps,

dhcp

tftpb <memory-start-location-to-store-dtb> <dtb-file>

tftpb <memory-start-location-to-store-image> <Image-file>

tftpb <memory-start-location-to-store-rootfs-file> <rootfs-file>

for example,

<zynqmp> dhcp ; tftpb 1000 system.dtb ; tftpb 80000 Image ; tftpb 6000000 rootfs.cpio.gz.u-boot ; booti 80000 6000000 1000

For further explanation on PetaLinux boot you can run: petalinux-boot --help

Booting on Hardware with SD card

To boot up board from SD card copy the generated BOOT.BIN file (also copy BOOT.BIN, Image, boot.scr, rootfs.cpio.gz.u-boot files from <plnx-proj-root>/images/linux or <plnx-proj-root>/pre-built/linux/images/ ) into the boot directory in SD card and power ON board with that SD card.

For detail steps follow as mentioned in PetaLinux Tools Documentation: Reference Guide (UG1144) - Steps to Boot a PetaLinux Image on Hardware with SD Card

Creating a Boot.bin File

  • Create BIF file: bootgen.bif (can be located at <plnx-proj-root> or <plnx-proj-root>/images/linux/)

bootgen.bif example for Zync series:

the_ROM_image: { [fsbl_config] a53_x64 [bootloader]  <plnx-proj-root>/images/linux/zynqmp_fsbl.elf [destination_device=pl] <plnx-proj-root>/images/linux/system.bit [destination_cpu=pmu]  <plnx-proj-root>/images/linux/pmufw.elf [destination_cpu=r5-0]  <RPU firmware> [destination_cpu=a53-0, exception_level=el-3, trustzone] <plnx-proj-root>/images/linux/bl31.elf [destination_cpu=a53-0, exception_level=el-2] <plnx-proj-root>/images/linux/u-boot.elf }

bootgen.bif example for Versal series:

the_ROM_image: { image { { type=bootimage, file=<plnx-proj-root>/project-spec/hw-description/vpl_gen_fixed.pdi } { type=bootloader, file=<plnx-proj-root>/images/linux/plm.elf } { core=psm, file=<plnx-proj-root>/images/linux/psmfw.elf } } image { id = 0x1c000000, name=apu_subsystem { type=raw, load=0x00001000, file=<plnx-proj-root>/images/linux/system-default.dtb } { core=a72-0, exception_level=el-3, trustzone, file=<plnx-proj-root>/images/linux/bl31.elf } { core=a72-0, exception_level=el-2, file=<plnx-proj-root>/images/linux/u-boot.elf } { core=r5-0, file=<RPU firmware> } } }
  • Generate BOOT.BIN

petalinux-package --boot --bif <bootgen.bif> --force

Running OpenAMP Demo Test Applications

After the system is up and running, log in with the username and password.

Username is “petalinux” from 2022.1 onwards and verison previous to that it is “root”. Keep simple password for example, “root”. In order to run demo applications you need to be root.

xilinx-zcu102-20221 login: petalinux You are required to change your password immediately (administrator enforced). New password: Retype new password: [ 37.029943] audit: type=1006 audit(1659496543.347:2): pid=573 uid=0 old-auid=4294967295 auid=1000 tty=(none) old-ses=4294967295 ses=1 res=1 [ 37.031000] audit: type=1300 audit(1659496543.347:2): arch=c00000b7 syscall=64 success=yes exit=4 a0=8 a1=ffffcb6856b0 a2=4 a3=ffff807616b0 items=0 ppid=1 pid=573 auid=1000 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=1 comm="(systemd)" exe="/lib/systemd/systemd" key=(null) [ 37.032490] audit: type=1327 audit(1659496543.347:2): proctitle="(systemd)" xilinx-zcu102-20221:~$ sudo -s We trust you have received the usual lecture from the local System Administrator. It usually boils down to these three things: #1) Respect the privacy of others. #2) Think before you type. #3) With great power comes great responsibility. Password: xilinx-zcu102-20221:/home/petalinux#

Make sure you have remoteproc driver loaded. If you have unloaded the remoteproc driver, you can load it as follows:

  • For the Zynq UltraScale+ MPSoC device: modprobe zynqmp_r5_remoteproc

  • For the Zynq-7000 SoC device: modprobe zynq_remoteproc

xilinx-zcu102-20221:/home/petalinux# lsmod Module Size Used by zynqmp_r5_remoteproc 20480 0 uio_pdrv_genirq 16384 0 zocl 167936 0 xilinx-zcu102-20221:/home/petalinux#

Running the Echo Test

For RPMsg in Kernel space

  • Load the Echo test firmware and RPMsg module:

echo image_echo_test > /sys/class/remoteproc/remoteproc0/firmware

echo start > /sys/class/remoteproc/remoteproc0/state

  • Run the test: echo_test The test starts.

  • Follow the on-screen instructions to complete the test.

  • After you have completed the test, unload the application:

echo stop > /sys/class/remoteproc/remoteproc0/state

xilinx-zcu102-20221:/home/petalinux# echo image_echo_test > /sys/class/remoteproc/remoteproc0/firmware xilinx-zcu102-20221:/home/petalinux# echo start > /sys/class/remoteproc/remoteproc0/state [ 324.510671] remoteproc remoteproc0: powering up ff9a0000.rf5ss:r5f_0 [ 324.514926] remoteproc remoteproc0: Booting fw image image_echo_test, size 615944 [ 324.574954] remoteproc0#vdev0buffer: registered virtio0 (type 7) [ 324.576755] remoteproc remoteproc0: remote processor ff9a0000.rf5ss:r5f_0 is now up main():98 openamp lib version: 1.1.0 (main():99 Major: 1, main():100 Minor: 1, main():101 Patch: 0) main():103 libmetal lib version: 1.1.0 (main():104 Major: 1, main():105 Minor: 1, main():106 Patch: 0) main():108 Starting application... xilinx-zcu102-20221:/home/petalinux# 0 L7 registered generic bus 1 L7 init_system():160 c_buf,c_len = 0x3ed201c0,4096 2 L6 platform_init():176 platform_create_proc() 3 L6 platform_create_proc():109 rsc_table, rsc_size = 0x3ed20000, 0x100 4 L7 zynqmp_r5_a53_proc_init():73 metal_device_open(generic, poll_dev, 0x2770) 5 L7 platform_create_proc():119 poll{name,bus,chn_mask} = poll_dev,generic,0x1000000 6 L7 zynqmp_r5_a53_proc_mmap():138 lpa,lda= 0x3ed20000,0xffffffff 7 L7 zynqmp_r5_a53_proc_mmap():150 mem= 0x3a28 8 L7 zynqmp_r5_a53_proc_mmap():154 tmpio= 0x3a68 9 L7 zynqmp_r5_a53_proc_mmap():138 lpa,lda= 0x3ed40000,0xffffffff 10 L7 zynqmp_r5_a53_proc_mmap():150 mem= 0x3ab0 11 L7 zynqmp_r5_a53_proc_mmap():154 tmpio= 0x3af0 12 L6 platform_create_proc():148 Initialize remoteproc successfully. 13 L6 platform_create_rpmsg_vdev():208 creating remoteproc virtio rproc 0x3ed20138 14 L6 platform_create_rpmsg_vdev():216 initializing rpmsg shared buffer pool [ 324.649797] virtio_rpmsg_bus virtio0: rpmsg host is online 15 L6 platform_create_rpmsg_vdev():221 initializing rpmsg vdev 16 L6 app():63 Try to create rpmsg endpoint. 17 L6 app():74 Successfully created rpmsg endpoint. [ 324.655948] virtio_rpmsg_bus virtio0: creating channel rpmsg-openamp-demo-channel addr 0x400 xilinx-zcu102-20221:/home/petalinux# echo_test Echo test start Master>probe rpmsg_char + lsmod Module Size Used by rpmsg_char 16384 0 virtio_rpmsg_bus 20480 0 rpmsg_ns 16384 1 virtio_rpmsg_bus rpmsg_core 16384 3 virtio_rpmsg_bus,rpmsg_char,rpmsg_ns zynqmp_r5_remoteproc 20480 0 uio_pdrv_genirq 16384 0 zocl 167936 0 + modprobe rpmsg_char lookup_channel():231 using dev file: virtio0.rpmsg-openamp-demo-channel.-1.1024 bind_rpmsg_chrdev():127 open /sys/bus/rpmsg/devices/virtio0.rpmsg-openamp-demo-channel.-1.1024/driver_override bind_rpmsg_chrdev():150 write virtio0.rpmsg-openamp-demo-channel.-1.1024 to /sys/bus/rpmsg/drivers/rpmsg_chrdev/bind get_rpmsg_chrdev_fd():170 opendir /sys/bus/rpmsg/devices/virtio0.rpmsg-openamp-demo-channel.-1.1024/rpmsg get_rpmsg_chrdev_fd():180 open /dev/rpmsg_ctrl1 main():300 rpmsg_create_ept: rpmsg-openamp-demo-channel[src=0,dst=0x400] checking /sys/class/rpmsg/rpmsg_ctrl1/rpmsg0/name svc_name: rpmsg-openamp-demo-channel . open /dev/rpmsg0 ************************************** Echo Test Round 0 ************************************** sending payload number 0 of size 17 echo test: sent : 17 received payload number 0 of size 17 sending payload number 1 of size 18 echo test: sent : 18 received payload number 1 of size 18 : : : sending payload number 470 of size 487 echo test: sent : 487 received payload number 470 of size 487 sending payload number 471 of size 488 echo test: sent : 488 received payload number 471 of size 488 ************************************** Echo Test Round 0 Test Results: Error count = 0 ************************************** 18 L6 rpmsg_endpoint_cb():36 shutdown message is received. 19 L7 app():82 done [ 403.172430] virtio_rpmsg_bus virtio0: destroying channel rpmsg-openamp-demo-channel addr 0x400 20 L6 main():129 Stopping application... 21 L7 unregistered generic bus xilinx-zcu102-20221:/home/petalinux# echo stop > /sys/class/remoteproc/remoteproc0/state [ 495.603000] remoteproc remoteproc0: stopped remote processor ff9a0000.rf5ss:r5f_0 xilinx-zcu102-20221:/home/petalinux#

For RPMsg in Userspace

Load Firmware and module, run the test, unload application - all is taken care of by running this application: rpmsg-echo-ping-shared

xilinx-zcu102-20221:/home/petalinux# rpmsg-echo-ping-shared metal: info: metal_linux_dev_open: checking driver vfio-platform,3ed20000.shm,(null) metal: info: metal_uio_dev_open: No IRQ for device 3ed20000.shm. Successfully14 L6 platform_create_rpmsg_vdev():216 initializing rpmsg shared buffer pool 15 L6 platform_create_rpmsg_vdev():221 initializing rpmsg vdev 16 L6 app():63 Try to create rpmsg endpoint. 17 L6 app():74 Successfully created rpmsg endpoint. open shm device. Successfully added shared memory metal: info: metal_linux_dev_open: checking driver vfio-platform,ff340000.ipi,(null) Successfully probed IPI device Successfully initialized Linux r5 remoteproc. Successfully initialized remoteproc Calling mmap resource table. Successfully mmap resource table. Successfully set resource table to remoteproc. Creating virtio... Successfully created virtio device. initializing rpmsg vdev 1 - Send data to remote core, retrieve the echo and validate its integrity .. RPMSG endpoint is binded with remote. sending payload number 0 of size 17 echo test: sent : 17 received payload number 0 of size 17 sending payload number 1 of size 18 echo test: sent : 18 received payload number 1 of size 18 : : : sending payload number 477 of size 494 echo test: sent : 494 received payload number 477 of size 494 sending payload number 478 of size 495 echo test: sent : 495 received payload number 478 of size 495 sending payload number 479 of size 496 echo test: sent : 496 received payload number 479 of size 496 ********************************** Test Results: Error count = 0 ********************************** Quitting application .. Echo test end Stopping application... xilinx-zcu102-20221:/home/petalinux#

Running the Matrix Multiplication Test

For RPMsg in Kernel space

Load the Matrix Multiply test firmware and RPMsg module, Run the test and unload the application after test is done

echo image_matrix_multiply > /sys/class/remoteproc/remoteproc0/firmware

echo start > /sys/class/remoteproc/remoteproc0/state

mat_mul_demo

echo stop > /sys/class/remoteproc/remoteproc0/state

xilinx-zcu102-20221:/home/petalinux# echo image_matrix_multiply > /sys/class/remoteproc/remoteproc0/firmware xilinx-zcu102-20221:/home/petalinux# echo start > /sys/class/remoteproc/remoteproc0/state [ 616.999517] remoteproc remoteproc0: powering up ff9a0000.rf5ss:r5f_0 [ 617.002872] remoteproc remoteproc0: Booting fw image image_matrix_multiply, size 613684 main():128 Starting application... [ 617.067125] virtio_rpmsg_bus virtio0: rpmsg host is online [ 617.067857] remoteproc0#vdev0buffer: registered virtio0 (type 7) [ 617.068370] remoteproc remoteproc0: remote processor ff9a0000.rf5ss:r5f_0 is now up 0 L7 registered generic bus xilinx-zcu102-20221:/home/petalinux# 1 L7 init_system():160 c_buf,c_len = 0x3ed201c0,4096 2 L6 platform_init():176 platform_create_proc() 3 L6 platform_create_proc():109 rsc_table, rsc_size = 0x3ed20000, 0x100 4 L7 zynqmp_r5_a53_proc_init():73 metal_device_open(generic, poll_dev, 0x26a8) 5 L7 platform_create_proc():119 poll{name,bus,chn_mask} = poll_dev,generic,0x1000000 6 L7 zynqmp_r5_a53_proc_mmap():138 lpa,lda= 0x3ed20000,0xffffffff 7 L7 zynqmp_r5_a53_proc_mmap():150 mem= 0x3958 8 L7 zynqmp_r5_a53_proc_mmap():154 tmpio= 0x3998 9 L7 zynqmp_r5_a53_proc_mmap():138 lpa,lda= 0x3ed40000,0xffffffff 10 L7 zynqmp_r5_a53_proc_mmap():150 mem= 0x39e0 11 L7 zynqmp_r5_a53_proc_mmap():154 tmpio= 0x3a20 12 L6 platform_create_proc():148 Initialize remoteproc successfully. 13 L6 platform_create_rpmsg_vdev():208 creating remoteproc virtio rproc 0x3ed2017c 14 L6 platform_create_rpmsg_vdev():216 initializing rpmsg shared buffer pool 15 L6 platform_create_rpmsg_vdev():221 initializing rpmsg vdev 16 L6 app():106 Waiting for events... [ 617.095410] virtio_rpmsg_bus virtio0: creating channel rpmsg-openamp-demo-channel addr 0x400 xilinx-zcu102-20221:/home/petalinux# mat_mul_demo Matrix multiplication demo start Master>probe rpmsg_char + lsmod Module Size Used by rpmsg_char 16384 0 virtio_rpmsg_bus 20480 0 rpmsg_ns 16384 1 virtio_rpmsg_bus rpmsg_core 16384 3 virtio_rpmsg_bus,rpmsg_char,rpmsg_ns zynqmp_r5_remoteproc 20480 0 uio_pdrv_genirq 16384 0 zocl 167936 0 + modprobe rpmsg_char lookup_channel():277 using dev file: virtio0.rpmsg-openamp-demo-channel.-1.1024 bind_rpmsg_chrdev():173 open /sys/bus/rpmsg/devices/virtio0.rpmsg-openamp-demo-channel.-1.1024/driver_override bind_rpmsg_chrdev():196 write virtio0.rpmsg-openamp-demo-channel.-1.1024 to /sys/bus/rpmsg/drivers/rpmsg_chrdev/bind get_rpmsg_chrdev_fd():216 opendir /sys/bus/rpmsg/devices/virtio0.rpmsg-openamp-demo-channel.-1.1024/rpmsg get_rpmsg_chrdev_fd():226 open /dev/rpmsg_ctrl1 main():344 rpmsg_create_ept: rpmsg-openamp-demo-channel[src=0,dst=0x400] checking /sys/class/rpmsg/rpmsg_ctrl1/rpmsg0/name svc_name: rpmsg-openamp-demo-channel . open /dev/rpmsg0 main():364 matrix_mult(1) Master : Linux : Input matrix 0 8 2 5 9 0 6 5 4 0 3 0 0 2 0 1 2 5 4 8 1 2 4 3 7 7 1 8 5 0 8 6 8 0 1 8 3 Master : Linux : Input matrix 1 0 5 9 0 1 2 3 3 2 6 7 0 0 6 1 4 2 5 1 9 8 2 6 8 2 2 8 3 6 8 8 6 6 7 8 7 0: write rpmsg: 296 bytes read results Master : Linux : Printing results 63 193 189 92 134 155 15 64 77 30 51 34 44 68 99 51 78 93 69 139 174 80 117 131 72 179 161 104 124 150 65 97 160 95 140 105 End of Matrix multiplication demo Round 0 Quitting application .. Matrix multiply application end xilinx-zcu102-20221:/home/petalinux# echo stop > /sys/class/remoteproc/remoteproc0/state [ 636.153518] remoteproc remoteproc0: stopped remote processor ff9a0000.rf5ss:r5f_0 xilinx-zcu102-20221:/home/petalinux#

For RPMsg in Userspace

Load Firmware and module, run the test, unload application - all is taken care of by running this application: matrix_multiply-shared

xilinx-zcu102-20221:/home/petalinux# matrix_multiply-shared metal: info: metal_linux_dev_open: checking driver vfio-platform,3ed20000.shm,(null) metal: info: metal_uio_dev_open: No IRQ for device 3ed20000.shm. Successfully 14 L6 platform_create_rpmsg_vdev():216 initializing rpmsg shared buffer pool 15 L6 platform_create_rpmsg_vdev():221 initializing rpmsg vdev 16 L6 app():63 Try to create rpmsg endpoint. o17 L6 app():74 Successfully created rpmsg endpoint. e18 L6 rpmsg_service_unbind():51 unexpected Remote endpoint destroy 19 L7 app():82 done 20 L6 main():129 Stopping application... 21 L7 unregistered generic bus n shm device. Successfully added shared memory metal: info: metal_linux_dev_open: checking driver vfio-platform,ff340000.ipi,(null) Successfully probed IPI device Successfully initialized Linux r5 remoteproc. Successfully initialized remoteproc Calling mmap resource table. Successfully mmap resource table. Successfully set resource table to remoteproc. Creating virtio... Successfully created virtio device. initializing rpmsg vdev CLIENT> Compute thread unblocked .. CLIENT> It will generate two random matrices. CLIENT> Send to the remote and get the computation result back. CLIENT> It will then check if the result is expected. CLIENT> RPMSG endpoint is binded with remote. CLIENT> Input matrix 0 5 2 7 1 7 8 4 4 9 7 8 4 9 7 5 0 7 1 6 1 1 6 8 8 2 4 0 8 8 7 5 3 9 4 4 8 CLIENT> Input matrix 1 2 0 4 1 0 2 7 9 1 4 0 8 6 8 2 9 4 0 7 6 6 9 7 6 6 4 0 7 8 6 5 2 7 1 3 7 CLIENT> Matrix multiply: sent : 296 : : : CLIENT> Input matrix 0 9 7 4 7 0 2 8 3 5 0 9 1 9 8 5 0 6 1 4 4 0 7 9 8 9 7 8 0 0 8 6 1 5 3 9 7 CLIENT> Input matrix 1 7 9 2 2 0 2 3 9 0 0 1 9 2 7 5 2 5 4 2 6 4 1 6 4 9 5 5 6 0 6 3 7 6 6 9 6 CLIENT> Matrix multiply: sent : 296 CLIENT> ********************************** CLIENT> Test Results: Error count = 0 CLIENT> ********************************** CLIENT> Quitting application ..17 L3 rpmsg_service_unbind():86 Endpoint is destroy Matrix multipled ication end CLIENT> Stopping application... 18 L6 main():149 Stopping application... 19 L7 unregistered generic bus xilinx-zcu102-20221:/home/petalinux#

Running the Proxy Application Test

For RPMsg in Kernel space

Load the Proxy Application test firmware and RPMsg module, Run the test and unload the application after test is done

echo image_rpc_demo > /sys/class/remoteproc/remoteproc0/firmware

echo start > /sys/class/remoteproc/remoteproc0/state

proxy_app

echo stop > /sys/class/remoteproc/remoteproc0/state

xilinx-zcu102-20221:/home/petalinux# echo image_rpc_demo > /sys/class/remoteproc/remoteproc0/firmware xilinx-zcu102-20221:/home/petalinux# echo start > /sys/class/remoteproc/remoteproc0/state [ 145.782852] remoteproc remoteproc0: powering up ff9a0000.rf5ss:r5f_0 [ 145.785939] remoteproc remoteproc0: Booting fw image image_rpc_demo, size 624084 Starting application... [ 145.841165] virtio_rpmsg_bus virtio0: rpmsg host is online [ 145.842383] remoteproc0#vdev0buffer: registered virtio0 (type 7) [ 145.843265] remoteproc remoteproc0: remote processor ff9a0000.rf5ss:r5f_0 is now up xilinx-zcu102-20221:/home/petalinux# 0 L7 registered generic bus 1 L7 init_system():160 c_buf,c_len = 0x3ed2017c,4096 2 L6 platform_init():176 platform_create_proc() 3 L6 platform_create_proc():109 rsc_table, rsc_size = 0x3ed20000, 0x100 4 L7 zynqmp_r5_a53_proc_init():73 metal_device_open(generic, poll_dev, 0x2bd8) 5 L7 platform_create_proc():119 poll{name,bus,chn_mask} = poll_dev,generic,0x1000000 6 L7 zynqmp_r5_a53_proc_mmap():138 lpa,lda= 0x3ed20000,0xffffffff 7 L7 zynqmp_r5_a53_proc_mmap():150 mem= 0x3e98 8 L7 zynqmp_r5_a53_proc_mmap():154 tmpio= 0x3ed8 9 L7 zynqmp_r5_a53_proc_mmap():138 lpa,lda= 0x3ed40000,0xffffffff 10 L7 zynqmp_r5_a53_proc_mmap():150 mem= 0x3f20 11 L7 zynqmp_r5_a53_proc_mmap():154 tmpio= 0x3f60 12 L6 platform_create_proc():148 Initialize remoteproc successfully. 13 L6 platform_create_rpmsg_vdev():208 creating remoteproc virtio rproc 0x3ed20138 14 L6 platform_create_rpmsg_vdev():216 initializing rpmsg shared buffer pool 15 L6 platform_create_rpmsg_vdev():221 initializing rpmsg vdev Initializating I/Os redirection... [ 145.879312] virtio_rpmsg_bus virtio0: creating channel rpmsg-openamp-demo-channel addr 0x400 xilinx-zcu102-20221:/home/petalinux# proxy_app Master>Loading remote firmware Master>probe rpmsg_char using dev file: virtio0.rpmsg-openamp-demo-channel.-1.1024 open /sys/bus/rpmsg/devices/virtio0.rpmsg-openamp-demo-channel.-1.1024/driver_override write virtio0.rpmsg-openamp-demo-channel.-1.1024 to /sys/bus/rpmsg/drivers/rpmsg_chrdev/bind opendir /sys/bus/rpmsg/devices/virtio0.rpmsg-openamp-demo-channel.-1.1024/rpmsg open /dev/rpmsg_ctrl1 rpmsg_create_ept: rpmsg-openamp-demo-channel[src=0,dst=0x400] checking /sys/class/rpmsg/rpmsg_ctrl1/rpmsg0/name svc_name: rpmsg-openamp-demo-channel . Master>RPC service started !! Remote>Baremetal Remote Procedure Call (RPC) Demonstration Remote>*************************************************** Remote>Rpmsg based retargetting to proxy initialized.. Remote>FileIO demo .. Remote>Creating a file on master and writing to it.. Remote>Opened file 'remote.file' with fd = 6 Remote>Wrote to fd = 6, size = 45, content = This is a test string being written to file.. Remote>Closed fd = 6 Remote>Reading a file on master and displaying its contents.. Remote>Opened file 'remote.file' with fd = 6 handle_read: 4, 45 Remote>Read from fd = 6, size = 45, printing contents below .. This is a test string being written to file.. Remote>Closed fd = 6 Remote>Remote firmware using scanf and printf .. Remote>Scanning user input from master.. Remote>Enter name zynq handle_read: 4, 5 Remote>Enter age 10 handle_read: 4, 3 Remote>Enter value for pi 3.14159265358979 handle_read: 4, 17 Remote>User name = 'zynq' Remote>User age = '10' Remote>User entered value of pi = '3.141593' Remote>Repeat demo ? (enter yes or no) no handle_read: 4, 3 Remote>RPC retargetting quitting ... Remote> Firmware's rpmsg-rpc-channel going down! Release remoteproc procedure call [ 738.862033] virtio_rpmsg_bus virtio0: destroying channel rpmsg-openamp-demo-channel addr 0x400 Stopping application... 16 L7 unregistered generic bus xilinx-zcu102-20221:/home/petalinux# echo stop > /sys/class/remoteproc/remoteproc0/state [ 291.874626] remoteproc remoteproc0: stopped remote processor ff9a0000.rf5ss:r5f_0 xilinx-zcu102-20221:/home/petalinux#

For RPMsg in Userspace

Load Firmware and module, run the test, unload application - all is taken care of by running this application: rpc_demod-shared

xilinx-zcu102-20221:/home/petalinux# rpc_demod-shared Master> Starting application... metal: info: metal_linux_dev_open: checking driver vfio-platform,3ed20000.shm,(null) metal: info: metal_uio_dev_open: No IRQ for device 3ed20000.shm. Successfully open shm device. Successfully added shared memory metal: info: metal_linux_dev_open: checking driver vfio-platform,ff340000.ipi,(null) Successfully probed IPI device Successfully initialized Linux r5 remoteproc. Successfully initialized remoteproc Calling mmap resource table. Successfully mmap resource table. Successfully set resource table to remoteproc. Creating virtio... Successfully created virtio device. initializing rpmsg vdev Master> Try to create rpmsg endpoint. 14 L6 platform_create_rpmsg_vdev():216 initializing rpmsg shared buffer pool 15 L6 platform_create_rpmsg_vdev():221 initializing rpmsg vdev Master> Successfully created rpmsg endpoint. Initializating I/Os redirection... Remote>Baremetal Remote Procedure Call (RPC) Demonstration Remote>*************************************************** Remote>Rpmsg based retargetting to proxy initialized.. Remote>FileIO demo .. Remote>Creating a file on master and writing to it.. Remote>Opened file 'remote.file' with fd = 7 Remote>Wrote to fd = 7, size = 45, content = This is a test string being written to file.. Remote>Closed fd = 7 Remote>Reading a file on master and displaying its contents.. Remote>Opened file 'remote.file' with fd = 7 Remote>Read from fd = 7, size = 45, printing contents below .. This is a test string being written to file.. Remote>Closed fd = 7 Remote>Remote firmware using scanf and printf .. Remote>Scanning user input from master.. Remote>Enter name zynq Remote>Enter age 10 Remote>Enter value for pi 3.1415 Remote>User name = 'zynq' Remote>User age = '10' Remote>User entered value of pi = '3.141500' Remote>Repeat demo ? (enter yes or no) no Remote>RPC retargetting quitting ... Remote> Firmware's rpmsg-rpc-channel going down! Release remoteproc procedure call Master> Received termination request Stopping application... Master> Endpoint is destroyed Master> 16 L7 unregistered generic bus RPC service exiting !! Master> Destroying endpoint. Master> Stopping application... xilinx-zcu102-20221:/home/petalinux#

Related Links

 

© Copyright 2019 - 2022 Xilinx Inc. Privacy Policy