FreeRTOS OpenAMP RPU Firmware Demo

EDF includes OpenAMP examples based on FreeRTOS. The FreeRTOS OpenAMP examples currently run on Versal Gen 1 boards (such as the VEK280, VCK190, VPK120, and VMK180) and on Kria SoM boards (such as the KR260, KV260, and KD240), which are based on Zynq UltraScale+ MPSoC. After booting a board with edf-platform-disk-image, the OpenAMP examples can be demonstrated as follows. For the build and boot flow, see Operating System Integration and Development.

In the following OpenAMP examples, the Linux shell prompt is left-justified. Any output from the provided command is indented to help distinguish it from the command to type. The transcripts below were captured on a Versal Gen 1 board (the VEK280) running the a72-common platform image; the equivalent commands on a Kria SoM board running a53-mali-common-kria are identical, but the accelerator names use that board’s prefix (for example, k26-r5-0-echo-freertos on a KR260) and the on-disk firmware path uses that board’s name (for example, /lib/firmware/xilinx/kr260/rpu/0/).

OpenAMP is built on top of remoteproc. First make sure that remoteproc is enabled/available:

amd-edf:~$ dmesg | grep remoteproc
    [    3.886733] remoteproc remoteproc0: ffe00000.r5f is available

Now list the firmware available in the image:

amd-edf:~$ sudo dfx-mgr-client -listPackage
    ID accelType   Base        slotLoc Accelerator
    -- ----------- ----------- ------- -----------
     1 RPU         rpu         -1      versal-vm-p-m1369-00-reva-x-prc-01-r5-0-matrix-freertos
     2 RPU         rpu         -1      versal-vm-p-m1369-00-reva-x-prc-01-r5-0-echo-freertos
     3 RPU         rpu         -1      versal-vm-p-m1369-00-reva-x-prc-01-r5-0-proxy-freertos
     4 RPU         rpu         -1      vpk120-r5-0-matrix-freertos
     5 RPU         rpu         -1      vpk120-r5-0-proxy-freertos
     6 RPU         rpu         -1      vpk120-r5-0-echo-freertos
     7 XRT_FLAT    vpk120-p... -1      vpk120-pl-bram-gpio-fw
     8 XRT_FLAT    vrk165-p... -1      vrk165-pl-bram-gpio-fw
     9 RPU         rpu         -1      vck190-r5-0-echo-freertos
    10 RPU         rpu         -1      vck190-r5-0-proxy-freertos
    11 RPU         rpu         -1      vck190-r5-0-matrix-freertos
    12 XRT_FLAT    vck190-p... -1      vck190-pl-bram-gpio-fw
    13 RPU         rpu         -1      vmk180-r5-0-matrix-freertos
    14 RPU         rpu         -1      vmk180-r5-0-echo-freertos
    15 RPU         rpu         -1      vmk180-r5-0-proxy-freertos
    16 XRT_FLAT    vmk180-p... -1      vmk180-pl-bram-gpio-fw
    17 XRT_FLAT    vpk180-p... -1      vpk180-pl-bram-gpio-fw
    18 RPU         rpu         -1      vek280-r5-0-matrix-freertos
    19 RPU         rpu         -1      vek280-r5-0-proxy-freertos
    20 RPU         rpu         -1      vek280-r5-0-echo-freertos
    21 XRT_FLAT    vek280-p... -1      vek280-pl-bram-gpio-fw
    22 RPU         rpu         -1      vrk160-r5-0-matrix-freertos
    23 RPU         rpu         -1      vrk160-r5-0-echo-freertos
    24 RPU         rpu         -1      vrk160-r5-0-proxy-freertos
    25 XRT_FLAT    vrk160-p... -1      vrk160-pl-bram-gpio-fw

Notice that the common a72-common image installs the FreeRTOS OpenAMP example firmware for every Versal Gen 1 board the rootfs targets. Each board contributes one XRT_FLAT entry (the PL bitstream) plus three RPU entries (the echo, matrix, and proxy demos), and the accelerator names are prefixed with the board name (for example, vek280-r5-0-echo-freertos) so the listing disambiguates the per-board ELFs at a glance.

Any firmware intended for the RPUs has an accelType of RPU in the table given by dfx-mgr-client -listPackage.

The listing covers every board the common image targets; to narrow it to the firmware that targets the running board, dfx-mgr-client exposes a -filter flag that uses the EEPROM identification of the running platform:

amd-edf:~$ sudo dfx-mgr-client -listPackage -filter
    ID accelType   Base        slotLoc Accelerator
    -- ----------- ----------- ------- -----------
    18 RPU         rpu         -1      vek280-r5-0-matrix-freertos
    19 RPU         rpu         -1      vek280-r5-0-proxy-freertos
    20 RPU         rpu         -1      vek280-r5-0-echo-freertos
    21 XRT_FLAT    vek280-p... -1      vek280-pl-bram-gpio-fw

The filtered listing shows only the single PL bitstream and the three RPU demos for the running board, with the original ID numbers preserved so they still match the full listing above.

The same flag works on Kria SoM boards, where the EEPROM identifies the SoM (k26 or k24) rather than the carrier. On a KR260 (k26 SoM with KR carrier) running the a53-mali-common-kria image, the unfiltered listing covers every Kria-family board the common image targets:

amd-edf:~$ sudo dfx-mgr-client -listPackage
    ID accelType   Base        slotLoc Accelerator
    -- ----------- ----------- ------- -----------
     1 XRT_FLAT    k24-star... -1      k24-starter-kits
     2 XRT_FLAT    zcu106-p... -1      zcu106-pl-bram-gpio-fw
     3 XRT_FLAT    k26-star... 0       k26-starter-kits
     4 RPU         rpu         -1      k24-r5-0-matrix-freertos
     5 RPU         rpu         -1      k24-r5-0-echo-freertos
     6 RPU         rpu         -1      k24-r5-0-proxy-freertos
     7 RPU         rpu         -1      k26-r5-0-matrix-freertos
     8 RPU         rpu         -1      k26-r5-0-proxy-freertos
     9 RPU         rpu         -1      k26-r5-0-echo-freertos
    10 XRT_FLAT    zcu104-p... -1      zcu104-pl-bram-gpio-fw
    11 XRT_FLAT    zcu102-p... -1      zcu102-pl-bram-gpio-fw

and -filter narrows it to the rows whose accelerator names carry the k26- SoM prefix (here, the k26-starter-kits PL bitstream and the three FreeRTOS RPU demos):

amd-edf:~$ sudo dfx-mgr-client -listPackage -filter
    ID accelType   Base        slotLoc Accelerator
    -- ----------- ----------- ------- -----------
     3 XRT_FLAT    k26-star... 0       k26-starter-kits
     7 RPU         rpu         -1      k26-r5-0-matrix-freertos
     8 RPU         rpu         -1      k26-r5-0-proxy-freertos
     9 RPU         rpu         -1      k26-r5-0-echo-freertos

The on-disk ELFs for the running board live under /lib/firmware/xilinx/<board>/rpu/0/. For the VEK280 that is:

amd-edf:~$ ls /lib/firmware/xilinx/vek280/rpu/0/vek280-r5-0-*
    /lib/firmware/xilinx/vek280/rpu/0/vek280-r5-0-echo-freertos.elf
    /lib/firmware/xilinx/vek280/rpu/0/vek280-r5-0-matrix-freertos.elf
    /lib/firmware/xilinx/vek280/rpu/0/vek280-r5-0-proxy-freertos.elf

Load one of the FreeRTOS examples by name. The legacy -load flag now requires a numeric ID and will error out if given a name; use -loadByName instead:

amd-edf:~$ sudo dfx-mgr-client -loadByName vek280-r5-0-echo-freertos
    RPU0: FreeRTOS Version: 10.6.1
    RPU0: openamp lib version: 1.9.0
    RPU0: libmetal lib version: 1.9.1
    RPU0: Starting application...
    RPU0: created rpmsg channel rpmsg-openamp-demo-channel, src=0x400, dst=0xffffffff

    vek280-r5-0-echo-freertos: Loaded with slot_handle 0

Take note of the messages from the Linux kernel indicating the RPU is powered, loaded, and up:

amd-edf:~$ dmesg | grep remoteproc
    [    3.886733] remoteproc remoteproc0: ffe00000.r5f is available
    [ 1604.024230] remoteproc remoteproc0: powering up ffe00000.r5f
    [ 1604.024913] remoteproc remoteproc0: Booting fw image vek280-r5-0-echo-freertos.elf, size 1079372
    [ 1604.026988] remoteproc remoteproc0: remote processor ffe00000.r5f is now up

This is how dfx-mgr-client is updated as a result:

amd-edf:~$ sudo dfx-mgr-client -listPackage
    ID accelType   Base        slotLoc Accelerator
    -- ----------- ----------- ------- -----------
     1 RPU         rpu         -1      versal-vm-p-m1369-00-reva-x-prc-01-r5-0-matrix-freertos
     2 RPU         rpu         -1      versal-vm-p-m1369-00-reva-x-prc-01-r5-0-echo-freertos
     3 RPU         rpu         -1      versal-vm-p-m1369-00-reva-x-prc-01-r5-0-proxy-freertos
     4 RPU         rpu         -1      vpk120-r5-0-matrix-freertos
     5 RPU         rpu         -1      vpk120-r5-0-proxy-freertos
     6 RPU         rpu         -1      vpk120-r5-0-echo-freertos
     7 XRT_FLAT    vpk120-p... -1      vpk120-pl-bram-gpio-fw
     8 XRT_FLAT    vrk165-p... -1      vrk165-pl-bram-gpio-fw
     9 RPU         rpu         -1      vck190-r5-0-echo-freertos
    10 RPU         rpu         -1      vck190-r5-0-proxy-freertos
    11 RPU         rpu         -1      vck190-r5-0-matrix-freertos
    12 XRT_FLAT    vck190-p... -1      vck190-pl-bram-gpio-fw
    13 RPU         rpu         -1      vmk180-r5-0-matrix-freertos
    14 RPU         rpu         -1      vmk180-r5-0-echo-freertos
    15 RPU         rpu         -1      vmk180-r5-0-proxy-freertos
    16 XRT_FLAT    vmk180-p... -1      vmk180-pl-bram-gpio-fw
    17 XRT_FLAT    vpk180-p... -1      vpk180-pl-bram-gpio-fw
    18 RPU         rpu         -1      vek280-r5-0-matrix-freertos
    19 RPU         rpu         -1      vek280-r5-0-proxy-freertos
    20 RPU         rpu          0      vek280-r5-0-echo-freertos
    21 XRT_FLAT    vek280-p... -1      vek280-pl-bram-gpio-fw
    22 RPU         rpu         -1      vrk160-r5-0-matrix-freertos
    23 RPU         rpu         -1      vrk160-r5-0-echo-freertos
    24 RPU         rpu         -1      vrk160-r5-0-proxy-freertos
    25 XRT_FLAT    vrk160-p... -1      vrk160-pl-bram-gpio-fw

The slotLoc column for the loaded entry now shows the slot the firmware occupies (0 in this case) instead of -1.

The echo test we have loaded is a simple send/receive OpenAMP example between the APU and the RPU. The provided Linux user-space test application runs indefinitely; stop it manually with Ctrl-C when you are done.

amd-edf:~$ sudo echo_test
     Echo test start
    using dev file: virtio0.rpmsg-openamp-demo-channel.-1.1025
    open /sys/bus/rpmsg/devices/virtio0.rpmsg-openamp-demo-channel.-1.1025/driver_override
    current drv override = (null)
    write virtio0.rpmsg-openamp-demo-channel.-1.1025 to /sys/bus/rpmsg/drivers/rpmsg_chrdev/bind
    opendir /sys/bus/rpmsg/devices/virtio0.rpmsg_ctrl.0.0/rpmsg
    open /dev/rpmsg_ctrl0
    main():143 app_rpmsg_create_ept: rpmsg-openamp-demo-channel[src=0,dst=0x401]
    checking /sys/class/rpmsg/rpmsg_ctrl0/rpmsg0/name
    checking /sys/class/rpmsg/rpmsg_ctrl0/rpmsg1/name
    svc_name: rpmsg-openamp-demo-channel
    .
    open /dev/rpmsg1
     ************************************
      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 2 of size 19
    echo test: sent : 19
     received payload number 2 of size 19
     sending payload number 3 of size 20
    echo test: sent : 20
     received payload number 3 of size 20
    ...^C

Now we can unload the firmware:

amd-edf:~$ sudo dfx-mgr-client -unloadByName vek280-r5-0-echo-freertos
    unload vek280-r5-0-echo-freertos returns: 0 (Ok)

Check the kernel:

amd-edf:~$ dmesg | grep remoteproc
    [    3.886733] remoteproc remoteproc0: ffe00000.r5f is available
    [ 1604.024230] remoteproc remoteproc0: powering up ffe00000.r5f
    [ 1604.024913] remoteproc remoteproc0: Booting fw image vek280-r5-0-echo-freertos.elf, size 1079372
    [ 1604.026988] remoteproc remoteproc0: remote processor ffe00000.r5f is now up
    [ 1789.213441] remoteproc remoteproc0: stopped remote processor ffe00000.r5f

Check dfx-mgr-client:

amd-edf:~$ sudo dfx-mgr-client -listPackage
    ID accelType   Base        slotLoc Accelerator
    -- ----------- ----------- ------- -----------
     1 RPU         rpu         -1      versal-vm-p-m1369-00-reva-x-prc-01-r5-0-matrix-freertos
     2 RPU         rpu         -1      versal-vm-p-m1369-00-reva-x-prc-01-r5-0-echo-freertos
     3 RPU         rpu         -1      versal-vm-p-m1369-00-reva-x-prc-01-r5-0-proxy-freertos
     4 RPU         rpu         -1      vpk120-r5-0-matrix-freertos
     5 RPU         rpu         -1      vpk120-r5-0-proxy-freertos
     6 RPU         rpu         -1      vpk120-r5-0-echo-freertos
     7 XRT_FLAT    vpk120-p... -1      vpk120-pl-bram-gpio-fw
     8 XRT_FLAT    vrk165-p... -1      vrk165-pl-bram-gpio-fw
     9 RPU         rpu         -1      vck190-r5-0-echo-freertos
    10 RPU         rpu         -1      vck190-r5-0-proxy-freertos
    11 RPU         rpu         -1      vck190-r5-0-matrix-freertos
    12 XRT_FLAT    vck190-p... -1      vck190-pl-bram-gpio-fw
    13 RPU         rpu         -1      vmk180-r5-0-matrix-freertos
    14 RPU         rpu         -1      vmk180-r5-0-echo-freertos
    15 RPU         rpu         -1      vmk180-r5-0-proxy-freertos
    16 XRT_FLAT    vmk180-p... -1      vmk180-pl-bram-gpio-fw
    17 XRT_FLAT    vpk180-p... -1      vpk180-pl-bram-gpio-fw
    18 RPU         rpu         -1      vek280-r5-0-matrix-freertos
    19 RPU         rpu         -1      vek280-r5-0-proxy-freertos
    20 RPU         rpu         -1      vek280-r5-0-echo-freertos
    21 XRT_FLAT    vek280-p... -1      vek280-pl-bram-gpio-fw
    22 RPU         rpu         -1      vrk160-r5-0-matrix-freertos
    23 RPU         rpu         -1      vrk160-r5-0-echo-freertos
    24 RPU         rpu         -1      vrk160-r5-0-proxy-freertos
    25 XRT_FLAT    vrk160-p... -1      vrk160-pl-bram-gpio-fw

A demonstration of the remaining two OpenAMP examples is left as an exercise. In the same way that the echo_test Linux user-space application was provided to help test the vek280-r5-0-echo-freertos firmware:

  • the mat_mul_demo user-space application is provided to test vek280-r5-0-matrix-freertos

  • the proxy_app user-space application is provided to test vek280-r5-0-proxy-freertos