OpenAMP Linux Zephyr RPMsg

Browse source code on GitHub

Overview

This application demonstrates how to use OpenAMP for communication between Zephyr and Linux, where both sides utilize the OpenAMP library.

On the Linux side, the application uses the OpenAMP library provided by meta-openamp, ensuring a consistent and standardized approach to inter-core communication.

Building the application

Zephyr

Build command for RZ/G3S-SMARC

west build -b rzg3s_smarc/r9a08g045s33gbg/cm33 samples/boards/renesas/openamp_linux_zephyr

Build command for RZ/V2L-SMARC

west build -b rzv2l_smarc/r9a07g054l23gbg/cm33 samples/boards/renesas/openamp_linux_zephyr

Running the sample

Linux setup

For RZ/G3S-SMARC

The sample currently supports the Linux RZ/G Multi-OS Package v3.0.0. The build steps for Renesas Multi-OS Package are described below.

  1. Follow the procedures in ‘’3.2 Integration of Multi-OS Package related stuff’’ of Quick Start Guide for RZ/G3S Multi-OS Package [1] without initiating the build process.

  2. For RZ/G3S, add PLAT_M33_BOOT_SUPPORT=1 by following this guide: RZ/G3S SMARC Evaluation Board Kit [2]

  3. Insert the highlighted lines of code into the following file: meta-rz-features/meta-rz-multi-os/meta-rzg3s/recipes-example/rpmsg-sample/files/platform_info.c

    if (ret) {
    LPRINTF("failed rpmsg_init_vdev");
    goto err;
    }
    /* RPMsg virtio enables callback for avail flags */
    ret = virtqueue_enable_cb(rpmsg_vdev->rvq);
    if (ret) {
       LPRINTF("Failed release availability flags");
       goto err;
    }
    #ifndef __linux__ /* uC3 */
    start_ipi_task(rproc);
    #endif
    return rpmsg_virtio_get_rpmsg_device(rpmsg_vdev);
    
  4. Start the build.

  5. For deploying bootloader files, Linux kernel image, device tree and rootfs, please refer to: SMARC EVK of RZ/G3S Linux Start-up Guide [3]

For RZ/V2L-SMARC

The sample currently supports the Linux RZ/V Multi-OS Package v3.1.1. The build steps for Renesas Multi-OS Package are described below.

  1. Follow the steps (1) and (2) from the ‘’Flashing’’ section of RZ/V2L SMARC Evaluation Board Kit [4]

  2. Insert the highlighted lines of code into the following file: meta-rz-features/meta-rz-multi-os/meta-rzv2l/recipes-example/rpmsg-sample/files/platform_info.c

    if (ret) {
    LPRINTF("failed rpmsg_init_vdev");
    goto err;
    }
    /* RPMsg virtio enables callback for avail flags */
    ret = virtqueue_enable_cb(rpmsg_vdev->rvq);
    if (ret) {
       LPRINTF("Failed release availability flags");
       goto err;
    }
    #ifndef __linux__ /* uC3 */
    start_ipi_task(rproc);
    #endif
    return rpmsg_virtio_get_rpmsg_device(rpmsg_vdev);
    
  3. Start the build.

4. For deploying bootloader files, Linux kernel image, device tree and rootfs, follow the steps (4) to (8) from the ‘’Flashing’’ section of RZ/V2L SMARC Evaluation Board Kit [4]

Zephyr setup

  1. Flash the sample to the board by following the ‘’Flashing’’ instructions for your board.

  2. Open a serial terminal (minicom, putty, etc.) and connect to the board with the following settings:

    • Speed: 115200

    • Data: 8 bits

    • Parity: None

    • Stop bits: 1

Linux console

  1. Open a Linux shell (minicom, ssh, etc.) and login as root:

    smarc-<device> login: root
    
  2. Run the following command:

    root@smarc-<device>:~# rpmsg_sample_client 0 0
    
  3. The following output should appear:

    root@smarc-<device>:~# rpmsg_sample_client 0 0
    [211] proc_id:0 rsc_id:0 mbx_id:0
    metal: info:      metal_uio_dev_open: No IRQ for device 10400000.mbox-uio.
    metal: info:      metal_uio_dev_open: No IRQ for device 11010000.cpg-uio.
    [211] Successfully probed IPI device
    metal: info:      metal_uio_dev_open: No IRQ for device 42f00000.rsctbl.
    [211] Successfully open uio device: 42f00000.rsctbl.
    [211] Successfully added memory device 42f00000.rsctbl.
    metal: info:      metal_uio_dev_open: No IRQ for device 43000000.vring-ctl0.
    [211] Successfully open uio device: 43000000.vring-ctl0.
    [211] Successfully added memory device 43000000.vring-ctl0.
    metal: info:      metal_uio_dev_open: No IRQ for device 43200000.vring-shm0.
    [211] Successfully open uio device: 43200000.vring-shm0.
    [211] Successfully added memory device 43200000.vring-shm0.
    metal: info:      metal_uio_dev_open: No IRQ for device 43100000.vring-ctl1.
    [211] Successfully open uio device: 43100000.vring-ctl1.
    [211] Successfully added memory device 43100000.vring-ctl1.
    metal: info:      metal_uio_dev_open: No IRQ for device 43500000.vring-shm1.
    [211] Successfully open uio device: 43500000.vring-shm1.
    [211] Successfully added memory device 43500000.vring-shm1.
    metal: info:      metal_uio_dev_open: No IRQ for device 42f01000.mhu-shm.
    [211] Successfully open uio device: 42f01000.mhu-shm.
    [211] Successfully added memory device 42f01000.mhu-shm.
    [211] Initialize remoteproc successfully.
    [211] proc_id:1 rsc_id:1 mbx_id:0
    [211] Initialize remoteproc successfully.
    [211] proc_id:0 rsc_id:0 mbx_id:1
    [211] Initialize remoteproc successfully.
    [211] proc_id:1 rsc_id:1 mbx_id:1
    [211] Initialize remoteproc successfully.
    [217] thread start
    [CM33] creating remoteproc virtio
    [CM33] initializing rpmsg shared buffer pool
    [CM33] initializing rpmsg vdev
    [CM33]  1 - Send data to remote core, retrieve the echo and validate its integrity ..
    [CM33] Remote proc init.
    [CM33] RPMSG endpoint has created. rp_ept:0xffff9c86f870
    [CM33] register sig:2 succeeded.
    [CM33] register sig:15 succeeded.
    [CM33] RPMSG service has created.
    [CM33] sending payload number 0 of size 17
    [CM33]  received payload number 0 of size 17
    [CM33] sending payload number 1 of size 18
    [CM33]  received payload number 1 of size 18
    
    [snip]
    
    [CM33] sending payload number 471 of size 488
    [CM33]  received payload number 471 of size 488
    [CM33] ************************************
    [CM33]  Test Results: Error count = 0
    [CM33] ************************************
    [CM33] Quitting application .. Echo test end
    [CM33] Stopping application...
    [211] 42f00000.rsctbl closed
    [211] 43000000.vring-ctl0 closed
    [211] 43200000.vring-shm0 closed
    [211] 43100000.vring-ctl1 closed
    [211] 43500000.vring-shm1 closed
    [211] 42f01000.mhu-shm closed
    

Zephyr console

The following message will appear on the Zephyr console.

*** Booting Zephyr OS build zephyr-v#.#.#-####-g########## ***
I: Starting application..!
I: Starting application threads!
I: OpenAMP[remote]  linux responder demo started
I: new_service_cb: message received from service rpmsg-service-0
I: OpenAMP[remote] Linux sample client responder started
I: OpenAMP demo ended
I: OpenAMP Linux sample client responder ended

References

See also

MBOX