1.. zephyr:code-sample:: rz-openamp-linux-zephyr 2 :name: OpenAMP Linux Zephyr RPMsg 3 :relevant-api: mbox_interface 4 5 Enable message exchange between two cores, with the application core running Linux 6 and the real-time core running Zephyr, using the OpenAMP library. 7 8Overview 9******** 10 11This application demonstrates how to use OpenAMP for communication between Zephyr and Linux, 12where both sides utilize the OpenAMP library. 13 14On the Linux side, the application uses the OpenAMP library provided by `meta-openamp <https://github.com/OpenAMP/meta-openamp>`_, ensuring 15a consistent and standardized approach to inter-core communication. 16 17Building the application 18************************* 19 20Zephyr 21====== 22 23Build command: 24 25.. zephyr-app-commands:: 26 :zephyr-app: samples/boards/renesas/openamp_linux_zephyr 27 :board: rzg3s_smarc/r9a08g045s33gbg/cm33 28 :goals: build 29 :compact: 30 31Running the sample 32************************* 33 34Linux setup 35=========== 36 37The sample currently supports the Linux RZ/G Multi-OS Package V2.2.0. The build steps for Renesas Multi-OS Package V2.2.0 are described below. 38 391. Follow the procedures in ''3.Multi-OS Package Setup'' of `Release Note for RZ/G Multi-OS Package V2.2.0 <https://www.renesas.com/en/document/rln/release-note-rzg-multi-os-package-v220?r=1522841>`_ 40 without initiating the build process. 412. For RZ/G3S, add ``PLAT_M33_BOOT_SUPPORT=1`` by following this guide: 42 `RZ/G3S SMARC Evaluation Board Kit <https://docs.zephyrproject.org/latest/boards/renesas/rzg3s_smarc/doc/index.html#programming-and-debugging>`_ 43 443. 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 45 46 .. code-block:: c 47 :emphasize-lines: 5,6,7,8,9,10 48 49 if (ret) { 50 LPRINTF("failed rpmsg_init_vdev"); 51 goto err; 52 } 53 /* RPMsg virtio enables callback for avail flags */ 54 ret = virtqueue_enable_cb(rpmsg_vdev->rvq); 55 if (ret) { 56 LPRINTF("Failed release availability flags"); 57 goto err; 58 } 59 #ifndef __linux__ /* uC3 */ 60 start_ipi_task(rproc); 61 #endif 62 return rpmsg_virtio_get_rpmsg_device(rpmsg_vdev); 63 644. Start the build. 65 665. For deploying bootloader files, Linux kernel image, device tree and rootfs, follow the procedures in ''3.5.1 In case of configuring CA55 as Boot CPU'' of `Release Note for RZ/G Multi-OS Package V2.2.0 <https://www.renesas.com/en/document/rln/release-note-rzg-multi-os-package-v220?r=1522841>`_ 67 68Zephyr setup 69============ 70 711. Flash the sample to the board. 72 732. Open a serial terminal (minicom, putty, etc.) and connect to the board with the following 74 settings: 75 76 - Speed: 115200 77 - Data: 8 bits 78 - Parity: None 79 - Stop bits: 1 80 81Linux console 82============= 83 841. Open a Linux shell (minicom, ssh, etc.) and login as root: 85 86 .. code-block:: console 87 88 smarc-<device> login: root 89 902. Run the following command: 91 92 .. code-block:: console 93 94 root@smarc-<device>:~# rpmsg_sample_client 0 0 95 963. The following output should appear: 97 98 .. code-block:: console 99 100 root@smarc-<device>:~# rpmsg_sample_client 0 0 101 [211] proc_id:0 rsc_id:0 mbx_id:0 102 metal: info: metal_uio_dev_open: No IRQ for device 10400000.mbox-uio. 103 metal: info: metal_uio_dev_open: No IRQ for device 11010000.cpg-uio. 104 [211] Successfully probed IPI device 105 metal: info: metal_uio_dev_open: No IRQ for device 42f00000.rsctbl. 106 [211] Successfully open uio device: 42f00000.rsctbl. 107 [211] Successfully added memory device 42f00000.rsctbl. 108 metal: info: metal_uio_dev_open: No IRQ for device 43000000.vring-ctl0. 109 [211] Successfully open uio device: 43000000.vring-ctl0. 110 [211] Successfully added memory device 43000000.vring-ctl0. 111 metal: info: metal_uio_dev_open: No IRQ for device 43200000.vring-shm0. 112 [211] Successfully open uio device: 43200000.vring-shm0. 113 [211] Successfully added memory device 43200000.vring-shm0. 114 metal: info: metal_uio_dev_open: No IRQ for device 43100000.vring-ctl1. 115 [211] Successfully open uio device: 43100000.vring-ctl1. 116 [211] Successfully added memory device 43100000.vring-ctl1. 117 metal: info: metal_uio_dev_open: No IRQ for device 43500000.vring-shm1. 118 [211] Successfully open uio device: 43500000.vring-shm1. 119 [211] Successfully added memory device 43500000.vring-shm1. 120 metal: info: metal_uio_dev_open: No IRQ for device 42f01000.mhu-shm. 121 [211] Successfully open uio device: 42f01000.mhu-shm. 122 [211] Successfully added memory device 42f01000.mhu-shm. 123 [211] Initialize remoteproc successfully. 124 [211] proc_id:1 rsc_id:1 mbx_id:0 125 [211] Initialize remoteproc successfully. 126 [211] proc_id:0 rsc_id:0 mbx_id:1 127 [211] Initialize remoteproc successfully. 128 [211] proc_id:1 rsc_id:1 mbx_id:1 129 [211] Initialize remoteproc successfully. 130 [217] thread start 131 [CM33] creating remoteproc virtio 132 [CM33] initializing rpmsg shared buffer pool 133 [CM33] initializing rpmsg vdev 134 [CM33] 1 - Send data to remote core, retrieve the echo and validate its integrity .. 135 [CM33] Remote proc init. 136 [CM33] RPMSG endpoint has created. rp_ept:0xffff9c86f870 137 [CM33] register sig:2 succeeded. 138 [CM33] register sig:15 succeeded. 139 [CM33] RPMSG service has created. 140 [CM33] sending payload number 0 of size 17 141 [CM33] received payload number 0 of size 17 142 [CM33] sending payload number 1 of size 18 143 [CM33] received payload number 1 of size 18 144 145 [snip] 146 147 [CM33] sending payload number 471 of size 488 148 [CM33] received payload number 471 of size 488 149 [CM33] ************************************ 150 [CM33] Test Results: Error count = 0 151 [CM33] ************************************ 152 [CM33] Quitting application .. Echo test end 153 [CM33] Stopping application... 154 [211] 42f00000.rsctbl closed 155 [211] 43000000.vring-ctl0 closed 156 [211] 43200000.vring-shm0 closed 157 [211] 43100000.vring-ctl1 closed 158 [211] 43500000.vring-shm1 closed 159 [211] 42f01000.mhu-shm closed 160 161Zephyr console 162============== 163 164The following message will appear on the Zephyr console. 165 166 .. code-block:: console 167 168 *** Booting Zephyr OS build zephyr-v#.#.#-####-g########## *** 169 I: Starting application..! 170 I: Starting application threads! 171 I: OpenAMP[remote] linux responder demo started 172 I: new_service_cb: message received from service rpmsg-service-0 173 I: OpenAMP[remote] Linux sample client responder started 174 I: OpenAMP demo ended 175 I: OpenAMP Linux sample client responder ended 176