Skip to content

Commit

Permalink
samples: ipc: Modify icmsg_me sample allowing any multiendpoint backend
Browse files Browse the repository at this point in the history
There are more ipc_service backends that supports multiple endpoint.
This sample can be used for any of those backends, so this commits
makes the sample more generic. The default backend it still icmsg_me,
but now, the sample has files and instructions for icmsg_with_buf
backend.

Signed-off-by: Dominik Kilian <[email protected]>
  • Loading branch information
doki-nordic authored and carlescufi committed Nov 13, 2023
1 parent 28df449 commit 23254f2
Show file tree
Hide file tree
Showing 17 changed files with 208 additions and 12 deletions.
10 changes: 0 additions & 10 deletions samples/subsys/ipc/ipc_service/icmsg_me/sample.yaml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,3 @@ endif()
project(ipc_service)

target_sources(app PRIVATE src/main.c)

include(ExternalProject)
73 changes: 73 additions & 0 deletions samples/subsys/ipc/ipc_service/multi_endpoint/README.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
.. _ipc_multi_endpoint_sample:

IPC Service - Multi-endpoint Sample Application
###############################################

This application demonstrates how to use IPC Service with multiple endpoints.
By default, it uses the ``icmsg_me`` backend.
You can also configure it to use the ``icbmsg`` backend.

Building the application for nrf5340dk_nrf5340_cpuapp
*****************************************************

.. zephyr-app-commands::
:zephyr-app: samples/subsys/ipc/ipc_service/multi_endpoint
:board: nrf5340dk_nrf5340_cpuapp
:goals: debug

Open a serial terminal (for example Minicom or PuTTY) and connect the board with the following settings:

* Speed: 115200
* Data: 8 bits
* Parity: None
* Stop bits: 1

After resetting the board, the following message will appear on the corresponding
serial port:

.. code-block:: console
*** Booting Zephyr OS build v3.4.0-rc1-108-gccfbac8b0721 ***
IPC-service HOST [INST 0 - ENDP A] demo started
IPC-service HOST [INST 0 - ENDP B] demo started
IPC-service HOST [INST 1] demo started
HOST [0A]: 1
HOST [0A]: 3
HOST [0B]: 1
HOST [1]: 1
...
HOST [0A]: 99
IPC-service HOST [INST 0 - ENDP A] demo ended.
HOST [0B]: 99
IPC-service HOST [INST 0 - ENDP B] demo ended.
HOST [1]: 99
IPC-service HOST [INST 1] demo ended.
.. code-block:: console
*** Booting Zephyr OS build v3.4.0-rc1-108-gccfbac8b0721 ***
IPC-service REMOTE [INST 0 - ENDP A] demo started
IPC-service REMOTE [INST 0 - ENDP B] demo started
IPC-service REMOTE [INST 1] demo started
REMOTE [0A]: 0
REMOTE [0A]: 2
...
REMOTE [0A]: 98
IPC-service REMOTE [INST 0 - ENDP A] demo ended.
REMOTE [0B]: 98
IPC-service REMOTE [INST 0 - ENDP B] demo ended.
REMOTE [1]: 98
IPC-service REMOTE [INST 1] demo ended.
Changing the backend
********************

To change the backend to ``icbmsg``, switch the devicetree
overlay files as follows:

.. code-block:: console
west build -b nrf5340dk_nrf5340_cpuapp --sysbuild -- \
-DDTC_OVERLAY_FILE=boards/nrf5340dk_nrf5340_cpuapp_icbmsg.overlay \
-Dremote_DTC_OVERLAY_FILE=boards/nrf5340dk_nrf5340_cpunet_icbmsg.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright (c) 2023 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/

/ {
chosen {
/delete-property/ zephyr,ipc_shm;
};

reserved-memory {
/delete-node/ memory@20070000;

sram_ipc0_tx: memory@20070000 {
reg = <0x20070000 0x4000>;
};

sram_ipc0_rx: memory@20074000 {
reg = <0x20074000 0x4000>;
};

sram_ipc1_tx: memory@20078000 {
reg = <0x20078000 0x4000>;
};

sram_ipc1_rx: memory@2007C000 {
reg = <0x2007C000 0x4000>;
};
};

ipc {
/delete-node/ ipc0;

ipc0: ipc0 {
compatible = "zephyr,ipc-icbmsg";
tx-region = <&sram_ipc0_tx>;
rx-region = <&sram_ipc0_rx>;
tx-blocks = <16>;
rx-blocks = <24>;
mboxes = <&mbox 0>, <&mbox 1>;
mbox-names = "tx", "rx";
status = "okay";
};

ipc1: ipc1 {
compatible = "zephyr,ipc-icbmsg";
tx-region = <&sram_ipc1_tx>;
rx-region = <&sram_ipc1_rx>;
tx-blocks = <32>;
rx-blocks = <48>;
mboxes = <&mbox 2>, <&mbox 3>;
mbox-names = "tx", "rx";
status = "okay";
};
};
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
CONFIG_PRINTK=y
CONFIG_LOG_PRINTK=n

CONFIG_IPC_SERVICE=y
CONFIG_MBOX=y
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright (c) 2023 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/

/ {
chosen {
/delete-property/ zephyr,ipc_shm;
};

reserved-memory {
/delete-node/ memory@20070000;

sram_ipc0_rx: memory@20070000 {
reg = <0x20070000 0x4000>;
};

sram_ipc0_tx: memory@20074000 {
reg = <0x20074000 0x4000>;
};

sram_ipc1_rx: memory@20078000 {
reg = <0x20078000 0x4000>;
};

sram_ipc1_tx: memory@2007C000 {
reg = <0x2007C000 0x4000>;
};
};

ipc {
/delete-node/ ipc0;

ipc0: ipc0 {
compatible = "zephyr,ipc-icbmsg";
tx-region = <&sram_ipc0_tx>;
rx-region = <&sram_ipc0_rx>;
tx-blocks = <24>;
rx-blocks = <16>;
mboxes = <&mbox 0>, <&mbox 1>;
mbox-names = "rx", "tx";
status = "okay";
};

ipc1: ipc1 {
compatible = "zephyr,ipc-icbmsg";
tx-region = <&sram_ipc1_tx>;
rx-region = <&sram_ipc1_rx>;
tx-blocks = <48>;
rx-blocks = <32>;
mboxes = <&mbox 2>, <&mbox 3>;
mbox-names = "rx", "tx";
status = "okay";
};
};
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
CONFIG_PRINTK=y
CONFIG_LOG_PRINTK=n

CONFIG_IPC_SERVICE=y
CONFIG_MBOX=y
Expand Down
19 changes: 19 additions & 0 deletions samples/subsys/ipc/ipc_service/multi_endpoint/sample.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
sample:
name: IPC Service example integration (icmsg multi endpoint backend)
tests:
sample.ipc.multi_endpoint:
platform_allow: nrf5340dk_nrf5340_cpuapp
integration_platforms:
- nrf5340dk_nrf5340_cpuapp
tags: ipc
sysbuild: true
harness: remote
sample.ipc.multi_endpoint.icbmsg:
platform_allow: nrf5340dk_nrf5340_cpuapp
integration_platforms:
- nrf5340dk_nrf5340_cpuapp
tags: ipc
sysbuild: true
extra_args:
DTC_OVERLAY_FILE=boards/nrf5340dk_nrf5340_cpuapp_icbmsg.overlay
remote_DTC_OVERLAY_FILE=boards/nrf5340dk_nrf5340_cpunet_icbmsg.overlay

0 comments on commit 23254f2

Please sign in to comment.