From 23254f2a160e8e955a4545c1cd098b0085a9fac9 Mon Sep 17 00:00:00 2001 From: Dominik Kilian Date: Thu, 9 Nov 2023 12:00:34 +0100 Subject: [PATCH] samples: ipc: Modify icmsg_me sample allowing any multiendpoint backend 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 --- .../ipc/ipc_service/icmsg_me/sample.yaml | 10 --- .../CMakeLists.txt | 2 - .../Kconfig.sysbuild | 0 .../ipc/ipc_service/multi_endpoint/README.rst | 73 +++++++++++++++++++ .../boards/nrf5340dk_nrf5340_cpuapp.conf | 0 .../boards/nrf5340dk_nrf5340_cpuapp.overlay | 0 .../nrf5340dk_nrf5340_cpuapp_icbmsg.overlay | 57 +++++++++++++++ .../{icmsg_me => multi_endpoint}/prj.conf | 1 + .../remote/CMakeLists.txt | 0 .../boards/nrf5340dk_nrf5340_cpunet.conf | 0 .../boards/nrf5340dk_nrf5340_cpunet.overlay | 0 .../nrf5340dk_nrf5340_cpunet_icbmsg.overlay | 57 +++++++++++++++ .../remote/prj.conf | 1 + .../remote/src/main.c | 0 .../ipc_service/multi_endpoint/sample.yaml | 19 +++++ .../{icmsg_me => multi_endpoint}/src/main.c | 0 .../sysbuild.cmake | 0 17 files changed, 208 insertions(+), 12 deletions(-) delete mode 100644 samples/subsys/ipc/ipc_service/icmsg_me/sample.yaml rename samples/subsys/ipc/ipc_service/{icmsg_me => multi_endpoint}/CMakeLists.txt (93%) rename samples/subsys/ipc/ipc_service/{icmsg_me => multi_endpoint}/Kconfig.sysbuild (100%) create mode 100644 samples/subsys/ipc/ipc_service/multi_endpoint/README.rst rename samples/subsys/ipc/ipc_service/{icmsg_me => multi_endpoint}/boards/nrf5340dk_nrf5340_cpuapp.conf (100%) rename samples/subsys/ipc/ipc_service/{icmsg_me => multi_endpoint}/boards/nrf5340dk_nrf5340_cpuapp.overlay (100%) create mode 100644 samples/subsys/ipc/ipc_service/multi_endpoint/boards/nrf5340dk_nrf5340_cpuapp_icbmsg.overlay rename samples/subsys/ipc/ipc_service/{icmsg_me => multi_endpoint}/prj.conf (83%) rename samples/subsys/ipc/ipc_service/{icmsg_me => multi_endpoint}/remote/CMakeLists.txt (100%) rename samples/subsys/ipc/ipc_service/{icmsg_me => multi_endpoint}/remote/boards/nrf5340dk_nrf5340_cpunet.conf (100%) rename samples/subsys/ipc/ipc_service/{icmsg_me => multi_endpoint}/remote/boards/nrf5340dk_nrf5340_cpunet.overlay (100%) create mode 100644 samples/subsys/ipc/ipc_service/multi_endpoint/remote/boards/nrf5340dk_nrf5340_cpunet_icbmsg.overlay rename samples/subsys/ipc/ipc_service/{icmsg_me => multi_endpoint}/remote/prj.conf (83%) rename samples/subsys/ipc/ipc_service/{icmsg_me => multi_endpoint}/remote/src/main.c (100%) create mode 100644 samples/subsys/ipc/ipc_service/multi_endpoint/sample.yaml rename samples/subsys/ipc/ipc_service/{icmsg_me => multi_endpoint}/src/main.c (100%) rename samples/subsys/ipc/ipc_service/{icmsg_me => multi_endpoint}/sysbuild.cmake (100%) diff --git a/samples/subsys/ipc/ipc_service/icmsg_me/sample.yaml b/samples/subsys/ipc/ipc_service/icmsg_me/sample.yaml deleted file mode 100644 index 2fe7f79ef405..000000000000 --- a/samples/subsys/ipc/ipc_service/icmsg_me/sample.yaml +++ /dev/null @@ -1,10 +0,0 @@ -sample: - name: IPC Service example integration (icmsg multi endpoint backend) -tests: - sample.ipc.icmsg_me: - platform_allow: nrf5340dk_nrf5340_cpuapp - integration_platforms: - - nrf5340dk_nrf5340_cpuapp - tags: ipc - sysbuild: true - harness: remote diff --git a/samples/subsys/ipc/ipc_service/icmsg_me/CMakeLists.txt b/samples/subsys/ipc/ipc_service/multi_endpoint/CMakeLists.txt similarity index 93% rename from samples/subsys/ipc/ipc_service/icmsg_me/CMakeLists.txt rename to samples/subsys/ipc/ipc_service/multi_endpoint/CMakeLists.txt index 18a138548cfb..b342f5506163 100644 --- a/samples/subsys/ipc/ipc_service/icmsg_me/CMakeLists.txt +++ b/samples/subsys/ipc/ipc_service/multi_endpoint/CMakeLists.txt @@ -15,5 +15,3 @@ endif() project(ipc_service) target_sources(app PRIVATE src/main.c) - -include(ExternalProject) diff --git a/samples/subsys/ipc/ipc_service/icmsg_me/Kconfig.sysbuild b/samples/subsys/ipc/ipc_service/multi_endpoint/Kconfig.sysbuild similarity index 100% rename from samples/subsys/ipc/ipc_service/icmsg_me/Kconfig.sysbuild rename to samples/subsys/ipc/ipc_service/multi_endpoint/Kconfig.sysbuild diff --git a/samples/subsys/ipc/ipc_service/multi_endpoint/README.rst b/samples/subsys/ipc/ipc_service/multi_endpoint/README.rst new file mode 100644 index 000000000000..faff69e007fb --- /dev/null +++ b/samples/subsys/ipc/ipc_service/multi_endpoint/README.rst @@ -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 diff --git a/samples/subsys/ipc/ipc_service/icmsg_me/boards/nrf5340dk_nrf5340_cpuapp.conf b/samples/subsys/ipc/ipc_service/multi_endpoint/boards/nrf5340dk_nrf5340_cpuapp.conf similarity index 100% rename from samples/subsys/ipc/ipc_service/icmsg_me/boards/nrf5340dk_nrf5340_cpuapp.conf rename to samples/subsys/ipc/ipc_service/multi_endpoint/boards/nrf5340dk_nrf5340_cpuapp.conf diff --git a/samples/subsys/ipc/ipc_service/icmsg_me/boards/nrf5340dk_nrf5340_cpuapp.overlay b/samples/subsys/ipc/ipc_service/multi_endpoint/boards/nrf5340dk_nrf5340_cpuapp.overlay similarity index 100% rename from samples/subsys/ipc/ipc_service/icmsg_me/boards/nrf5340dk_nrf5340_cpuapp.overlay rename to samples/subsys/ipc/ipc_service/multi_endpoint/boards/nrf5340dk_nrf5340_cpuapp.overlay diff --git a/samples/subsys/ipc/ipc_service/multi_endpoint/boards/nrf5340dk_nrf5340_cpuapp_icbmsg.overlay b/samples/subsys/ipc/ipc_service/multi_endpoint/boards/nrf5340dk_nrf5340_cpuapp_icbmsg.overlay new file mode 100644 index 000000000000..3db9db032f4c --- /dev/null +++ b/samples/subsys/ipc/ipc_service/multi_endpoint/boards/nrf5340dk_nrf5340_cpuapp_icbmsg.overlay @@ -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"; + }; + }; +}; diff --git a/samples/subsys/ipc/ipc_service/icmsg_me/prj.conf b/samples/subsys/ipc/ipc_service/multi_endpoint/prj.conf similarity index 83% rename from samples/subsys/ipc/ipc_service/icmsg_me/prj.conf rename to samples/subsys/ipc/ipc_service/multi_endpoint/prj.conf index 4c5326d13976..3d2c799c4eb6 100644 --- a/samples/subsys/ipc/ipc_service/icmsg_me/prj.conf +++ b/samples/subsys/ipc/ipc_service/multi_endpoint/prj.conf @@ -1,4 +1,5 @@ CONFIG_PRINTK=y +CONFIG_LOG_PRINTK=n CONFIG_IPC_SERVICE=y CONFIG_MBOX=y diff --git a/samples/subsys/ipc/ipc_service/icmsg_me/remote/CMakeLists.txt b/samples/subsys/ipc/ipc_service/multi_endpoint/remote/CMakeLists.txt similarity index 100% rename from samples/subsys/ipc/ipc_service/icmsg_me/remote/CMakeLists.txt rename to samples/subsys/ipc/ipc_service/multi_endpoint/remote/CMakeLists.txt diff --git a/samples/subsys/ipc/ipc_service/icmsg_me/remote/boards/nrf5340dk_nrf5340_cpunet.conf b/samples/subsys/ipc/ipc_service/multi_endpoint/remote/boards/nrf5340dk_nrf5340_cpunet.conf similarity index 100% rename from samples/subsys/ipc/ipc_service/icmsg_me/remote/boards/nrf5340dk_nrf5340_cpunet.conf rename to samples/subsys/ipc/ipc_service/multi_endpoint/remote/boards/nrf5340dk_nrf5340_cpunet.conf diff --git a/samples/subsys/ipc/ipc_service/icmsg_me/remote/boards/nrf5340dk_nrf5340_cpunet.overlay b/samples/subsys/ipc/ipc_service/multi_endpoint/remote/boards/nrf5340dk_nrf5340_cpunet.overlay similarity index 100% rename from samples/subsys/ipc/ipc_service/icmsg_me/remote/boards/nrf5340dk_nrf5340_cpunet.overlay rename to samples/subsys/ipc/ipc_service/multi_endpoint/remote/boards/nrf5340dk_nrf5340_cpunet.overlay diff --git a/samples/subsys/ipc/ipc_service/multi_endpoint/remote/boards/nrf5340dk_nrf5340_cpunet_icbmsg.overlay b/samples/subsys/ipc/ipc_service/multi_endpoint/remote/boards/nrf5340dk_nrf5340_cpunet_icbmsg.overlay new file mode 100644 index 000000000000..6247ed812aa8 --- /dev/null +++ b/samples/subsys/ipc/ipc_service/multi_endpoint/remote/boards/nrf5340dk_nrf5340_cpunet_icbmsg.overlay @@ -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"; + }; + }; +}; diff --git a/samples/subsys/ipc/ipc_service/icmsg_me/remote/prj.conf b/samples/subsys/ipc/ipc_service/multi_endpoint/remote/prj.conf similarity index 83% rename from samples/subsys/ipc/ipc_service/icmsg_me/remote/prj.conf rename to samples/subsys/ipc/ipc_service/multi_endpoint/remote/prj.conf index 4c5326d13976..3d2c799c4eb6 100644 --- a/samples/subsys/ipc/ipc_service/icmsg_me/remote/prj.conf +++ b/samples/subsys/ipc/ipc_service/multi_endpoint/remote/prj.conf @@ -1,4 +1,5 @@ CONFIG_PRINTK=y +CONFIG_LOG_PRINTK=n CONFIG_IPC_SERVICE=y CONFIG_MBOX=y diff --git a/samples/subsys/ipc/ipc_service/icmsg_me/remote/src/main.c b/samples/subsys/ipc/ipc_service/multi_endpoint/remote/src/main.c similarity index 100% rename from samples/subsys/ipc/ipc_service/icmsg_me/remote/src/main.c rename to samples/subsys/ipc/ipc_service/multi_endpoint/remote/src/main.c diff --git a/samples/subsys/ipc/ipc_service/multi_endpoint/sample.yaml b/samples/subsys/ipc/ipc_service/multi_endpoint/sample.yaml new file mode 100644 index 000000000000..fdb3c707d8e5 --- /dev/null +++ b/samples/subsys/ipc/ipc_service/multi_endpoint/sample.yaml @@ -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 diff --git a/samples/subsys/ipc/ipc_service/icmsg_me/src/main.c b/samples/subsys/ipc/ipc_service/multi_endpoint/src/main.c similarity index 100% rename from samples/subsys/ipc/ipc_service/icmsg_me/src/main.c rename to samples/subsys/ipc/ipc_service/multi_endpoint/src/main.c diff --git a/samples/subsys/ipc/ipc_service/icmsg_me/sysbuild.cmake b/samples/subsys/ipc/ipc_service/multi_endpoint/sysbuild.cmake similarity index 100% rename from samples/subsys/ipc/ipc_service/icmsg_me/sysbuild.cmake rename to samples/subsys/ipc/ipc_service/multi_endpoint/sysbuild.cmake