Skip to content

Commit

Permalink
tests: ipc: ipc_sessions: Implementation
Browse files Browse the repository at this point in the history
Implementation of the test that focuses on session management in IPC.
Mainly restoring connections after disconnection.

Signed-off-by: Radoslaw Koppel <[email protected]>
  • Loading branch information
rakons committed Nov 28, 2024
1 parent 313531d commit 670f345
Show file tree
Hide file tree
Showing 20 changed files with 987 additions and 0 deletions.
12 changes: 12 additions & 0 deletions tests/subsys/ipc/ipc_sessions/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Copyright 2021 Google LLC
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.20.0)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(ipc_service)

zephyr_include_directories(./common)

FILE(GLOB app_sources src/*.c)
target_sources(app PRIVATE ${app_sources})
16 changes: 16 additions & 0 deletions tests/subsys/ipc/ipc_sessions/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#
# Copyright (c) 2024 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

menu "Zephyr"
source "Kconfig.zephyr"
endmenu

config IPC_TEST_MSG_HEAP_SIZE
int "The heap to copy processed messages"
default 512
help
Internal heap where all the message data would be copied to be processed
linearry in tests.
13 changes: 13 additions & 0 deletions tests/subsys/ipc/ipc_sessions/Kconfig.sysbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#
# Copyright (c) 2024 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

source "${ZEPHYR_BASE}/share/sysbuild/Kconfig"

config REMOTE_BOARD
string "The board used for remote target"
default "nrf5340dk/nrf5340/cpunet" if BOARD_NRF5340DK_NRF5340_CPUAPP
default "nrf5340dk/nrf5340/cpunet" if BOARD_NRF5340DK_NRF5340_CPUAPP_NS
default "nrf54h20dk/nrf54h20/cpuppr" if BOARD_NRF54H20DK_NRF54H20_CPUAPP
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#
# Copyright (c) 2024 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

CONFIG_SOC_NRF53_CPUNET_ENABLE=y
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2022 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

/delete-node/ &ipc0;

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

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

sram_tx: memory@20070000 {
reg = <0x20070000 0x8000>;
};

sram_rx: memory@20078000 {
reg = <0x20078000 0x8000>;
};
};

ipc0: ipc0 {
compatible = "zephyr,ipc-icmsg";
tx-region = <&sram_tx>;
rx-region = <&sram_rx>;
mboxes = <&mbox 0>, <&mbox 1>;
mbox-names = "tx", "rx";
dcache-alignment = <8>;
unbound = "detect";
status = "okay";
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (c) 2024 Nordic Semiconductor ASA
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

/* Replace default ipc0 instance */
/delete-node/ &ipc0;

ipc0: &cpuapp_cpuppr_ipc {
status = "okay";
unbound = "detect";
};

&cpuppr_vevif {
status = "okay";
};

&cpuapp_bellboard {
status = "okay";
};

/ {
chosen {
/delete-property/ zephyr,bt-hci;
};
};
46 changes: 46 additions & 0 deletions tests/subsys/ipc/ipc_sessions/common/test_commands.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright (c) 2024 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef TEST_COMMANDS_H
#include <stdint.h>

/**
* @brief Test commands executable by remote
*/
enum ipc_test_commands {
IPC_TEST_CMD_NONE, /**< Command to be ingored */
IPC_TEST_CMD_PING, /**< Respond with the @ref IPC_TEST_CMD_PONG message */
IPC_TEST_CMD_PONG, /**< Expected response to IPC_TEST_CMD_PING */
IPC_TEST_CMD_ECHO, /**< Respond with the same data */
IPC_TEST_CMD_ECHO_RSP, /**< Echo respond */
IPC_TEST_CMD_REBOND, /**< Unbond and rebond back whole interface */
IPC_TEST_CMD_REBOOT, /**< Restart remote CPU after a given delay */
};

/**
* @brief Base command structure
*/
struct ipc_test_cmd {
uint32_t cmd; /**< The command of @ref ipc_test_command type */
uint8_t data[]; /**< Command data depending on the command itself */
};

/**
* @brief Rebond command structure
*/
struct ipc_test_cmd_rebond {
struct ipc_test_cmd base;
uint32_t timeout_ms;
};

/**
* @brief Reboot command structure
*/
struct ipc_test_cmd_reboot {
struct ipc_test_cmd base;
uint32_t timeout_ms;
};

#endif /* TEST_COMMANDS_H */
7 changes: 7 additions & 0 deletions tests/subsys/ipc/ipc_sessions/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Copyright 2021 Carlo Caione <[email protected]>
# SPDX-License-Identifier: Apache-2.0

CONFIG_ZTEST=y
CONFIG_MMU=y
CONFIG_IPC_SERVICE=y
CONFIG_MBOX=y
15 changes: 15 additions & 0 deletions tests/subsys/ipc/ipc_sessions/remote/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#
# Copyright (c) 2024 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

cmake_minimum_required(VERSION 3.20.0)

find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(remote_icmsg)

zephyr_include_directories(../common)

FILE(GLOB remote_sources src/*.c)
target_sources(app PRIVATE ${remote_sources})
7 changes: 7 additions & 0 deletions tests/subsys/ipc/ipc_sessions/remote/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#
# Copyright (c) 2024 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

source "Kconfig.zephyr"
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (c) 2024 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

/delete-node/ &ipc0;

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

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

sram_rx: memory@20070000 {
reg = <0x20070000 0x8000>;
};

sram_tx: memory@20078000 {
reg = <0x20078000 0x8000>;
};
};

ipc0: ipc0 {
compatible = "zephyr,ipc-icmsg";
tx-region = <&sram_tx>;
rx-region = <&sram_rx>;
mboxes = <&mbox 0>, <&mbox 1>;
mbox-names = "rx", "tx";
dcache-alignment = <8>;
unbound = "detect";
status = "okay";
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CONFIG_WATCHDOG=y
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (c) 2024 Nordic Semiconductor ASA
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

ipc0: &cpuapp_cpuppr_ipc {
status = "okay";
unbound = "detect";
};

&cpuppr_vevif {
status = "okay";
};

&cpuapp_bellboard {
status = "okay";
};

&wdt131 {
status = "okay";
};

/ {
chosen {
/delete-property/ zephyr,bt-hci;
};

aliases {
watchdog0 = &wdt131;
};
};
20 changes: 20 additions & 0 deletions tests/subsys/ipc/ipc_sessions/remote/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright (c) 2024 Nordic Semiconductor ASA
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause

CONFIG_PRINTK=y
CONFIG_EVENTS=y

CONFIG_LOG=y
CONFIG_LOG_ALWAYS_RUNTIME=y
CONFIG_LOG_MODE_MINIMAL=y
#CONFIG_LOG_PROCESS_THREAD_PRIORITY=-15
#CONFIG_LOG_PROCESS_THREAD_CUSTOM_PRIORITY=y

CONFIG_HEAP_MEM_POOL_SIZE=2048

CONFIG_IPC_SERVICE=y
CONFIG_IPC_SERVICE_LOG_LEVEL_INF=y

CONFIG_MBOX=y

CONFIG_REBOOT=y
Loading

0 comments on commit 670f345

Please sign in to comment.