Zephyr OpenAMP RPU Firmware Demo

EDF includes an OpenAMP example based on Zephyr. The Zephyr OpenAMP example currently runs on Versal Gen 2 boards (such as the VEK385). After booting a board with edf-platform-disk-image, the example can be demonstrated as follows. For the build and boot flow, see Operating System Integration and Development.

In the following OpenAMP example, 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 VEK385 running the a78-mali-common platform image; on any future Zephyr-capable board the commands are identical, but the accelerator name uses that board’s prefix and the on-disk firmware path uses that board’s name (for example, /lib/firmware/xilinx/vek385/rpu/0/ on the VEK385).

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

amd-edf:~$ dmesg | grep remoteproc
    [    3.227478] remoteproc remoteproc0: eba00000.r52f is available
    [    3.252067] remoteproc remoteproc1: ebb80000.r52f is available
    [    3.252839] remoteproc remoteproc2: ebbc0000.r52f is available
    [    3.311668] remoteproc remoteproc3: ebc00000.r52f is available
    [    3.312282] remoteproc remoteproc4: ebc40000.r52f is available

Now list the firmware available in the image:

amd-edf:~$ sudo dfx-mgr-client -listPackage
    ID accelType   Base        slotLoc Accelerator
    -- ----------- ----------- ------- -----------
     1 XRT_FLAT    vek385-p... -1      vek385-pl-bram-gpio-fw
     2 RPU         rpu         -1      vek385-r52-0-zephyr-openamp
     3 XRT_FLAT    vek385-r... -1      vek385-revb-pl-bram-gpio-fw
     4 RPU         rpu         -1      vek385-revb-r52-0-zephyr-openamp

Notice that the common a78-mali-common image installs the Zephyr OpenAMP example firmware for every Versal Gen 2 board the rootfs targets. Each board contributes one XRT_FLAT entry (the PL bitstream) plus one RPU entry, with the accelerator name prefixed by the board name (for example, vek385-r52-0-zephyr-openamp) so the listing disambiguates the per-board ELFs at a glance.

The on-disk ELF for the running board lives under /lib/firmware/xilinx/vek385/rpu/0/:

amd-edf:~$ ls /lib/firmware/xilinx/vek385/rpu/0/vek385-r52-0-zephyr-openamp.elf
    /lib/firmware/xilinx/vek385/rpu/0/vek385-r52-0-zephyr-openamp.elf

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

On platforms that ship more than one OpenAMP firmware variant the listing can grow long. dfx-mgr-client exposes a -filter flag that uses the EEPROM identification of the running platform to narrow the listing to the firmware that targets the running board:

amd-edf:~$ sudo dfx-mgr-client -listPackage -filter
    ID accelType   Base        slotLoc Accelerator
    -- ----------- ----------- ------- -----------
     1 XRT_FLAT    vek385-p... -1      vek385-pl-bram-gpio-fw
     2 RPU         rpu         -1      vek385-r52-0-zephyr-openamp

Load the firmware 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 vek385-r52-0-zephyr-openamp
    vek385-r52-0-zephyr-openamp: Loaded with slot_handle 0

Check the kernel:

amd-edf:~$ dmesg | grep remoteproc
    [    3.227478] remoteproc remoteproc0: eba00000.r52f is available
    [    3.252067] remoteproc remoteproc1: ebb80000.r52f is available
    [    3.252839] remoteproc remoteproc2: ebbc0000.r52f is available
    [    3.311668] remoteproc remoteproc3: ebc00000.r52f is available
    [    3.312282] remoteproc remoteproc4: ebc40000.r52f is available
    [  310.471869] remoteproc remoteproc0: powering up eba00000.r52f
    [  310.492539] remoteproc remoteproc0: Booting fw image vek385-r52-0-zephyr-openamp.elf, size 1465652
    [  310.567205] remoteproc remoteproc0: remote processor eba00000.r52f is now up

Check dfx-mgr-client:

amd-edf:~$ sudo dfx-mgr-client -listPackage
    ID accelType   Base        slotLoc Accelerator
    -- ----------- ----------- ------- -----------
     1 XRT_FLAT    vek385-p... -1      vek385-pl-bram-gpio-fw
     2 RPU         rpu          0      vek385-r52-0-zephyr-openamp
     3 XRT_FLAT    vek385-r... -1      vek385-revb-pl-bram-gpio-fw
     4 RPU         rpu         -1      vek385-revb-r52-0-zephyr-openamp

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

Run the test. The Zephyr firmware exposes an RPMsg-backed TTY at /dev/ttyRPMSG0 on the Linux side; send a line into it from one terminal and the same line is echoed back in dmesg (or in another terminal that is reading from the device) prefixed by the RPMsg Endpoint:

amd-edf:~$ echo "Hello Zephyr" > /dev/ttyRPMSG0
    TTY 0: Hello Zephyr

When you are done testing, unload the firmware:

amd-edf:~$ sudo dfx-mgr-client -unloadByName vek385-r52-0-zephyr-openamp
    unload vek385-r52-0-zephyr-openamp returns: 0 (Ok)

Check the kernel:

amd-edf:~$ dmesg | grep remoteproc
    [    3.227478] remoteproc remoteproc0: eba00000.r52f is available
    [    3.252067] remoteproc remoteproc1: ebb80000.r52f is available
    [    3.252839] remoteproc remoteproc2: ebbc0000.r52f is available
    [    3.311668] remoteproc remoteproc3: ebc00000.r52f is available
    [    3.312282] remoteproc remoteproc4: ebc40000.r52f is available
    [  310.471869] remoteproc remoteproc0: powering up eba00000.r52f
    [  310.492539] remoteproc remoteproc0: Booting fw image vek385-r52-0-zephyr-openamp.elf, size 1465652
    [  310.567205] remoteproc remoteproc0: remote processor eba00000.r52f is now up
    [ 4691.687253] remoteproc remoteproc0: stopped remote processor eba00000.r52f

Check with dfx-mgr-client:

amd-edf:~$ sudo dfx-mgr-client -listPackage
    ID accelType   Base        slotLoc Accelerator
    -- ----------- ----------- ------- -----------
     1 XRT_FLAT    vek385-p... -1      vek385-pl-bram-gpio-fw
     2 RPU         rpu         -1      vek385-r52-0-zephyr-openamp
     3 XRT_FLAT    vek385-r... -1      vek385-revb-pl-bram-gpio-fw
     4 RPU         rpu         -1      vek385-revb-r52-0-zephyr-openamp