Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: benchmarks: multicore: Start testing IPC with s2ram #18897

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions tests/benchmarks/multicore/idle_ipc/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#
# 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})

if(NOT SYSBUILD)
message(FATAL_ERROR
" This is a multi-image application that should be built using sysbuild.\n"
" Add --sysbuild argument to west build command to prepare all the images.")
endif()

project(idle_ipc)

target_sources(app PRIVATE src/main.c)
8 changes: 8 additions & 0 deletions tests/benchmarks/multicore/idle_ipc/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#
# Copyright (c) 2024 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

source "Kconfig.zephyr"
rsource "Kconfig.common"
18 changes: 18 additions & 0 deletions tests/benchmarks/multicore/idle_ipc/Kconfig.common
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# Copyright (c) 2024 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

config APP_IPC_SERVICE_SEND_INTERVAL
int "Ipc service sending interval [us]"
default 70
help
Time in micro seconds between sending subsequent data packages over
IPC service. Since kernel timeout has 1 ms resolution, the value is
rounded down. If value of this option is lower than 1000 us, busy
wait is used instead of sleep.

config APP_IPC_SERVICE_MESSAGE_LEN
int "Length of single IPC message in bytes"
default 100
10 changes: 10 additions & 0 deletions tests/benchmarks/multicore/idle_ipc/Kconfig.sysbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#
# Copyright (c) 2023 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"
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Copyright (c) 2024 Nordic Semiconductor ASA
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause

CONFIG_APP_IPC_SERVICE_SEND_INTERVAL=900
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* 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";
};

&cpuppr_vevif {
status = "okay";
};

&cpuapp_bellboard {
status = "okay";
};

/ {
chosen {
/delete-property/ zephyr,bt-hci;
};
};
25 changes: 25 additions & 0 deletions tests/benchmarks/multicore/idle_ipc/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright (c) 2024 Nordic Semiconductor ASA
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause

CONFIG_LOG_PROCESS_THREAD_PRIORITY=-15
CONFIG_LOG_PROCESS_THREAD_CUSTOM_PRIORITY=y

CONFIG_HEAP_MEM_POOL_SIZE=4096

CONFIG_MBOX=y

CONFIG_IPC_SERVICE=y
CONFIG_IPC_SERVICE_LOG_LEVEL_INF=y

CONFIG_PM=y
CONFIG_PM_S2RAM=y
CONFIG_PM_S2RAM_CUSTOM_MARKING=y
CONFIG_PM_DEVICE=y
CONFIG_POWEROFF=y
CONFIG_PM_DEVICE_RUNTIME=y

# Enable for debugging pruposes only
CONFIG_PRINTK=y
CONFIG_LOG=y
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y
12 changes: 12 additions & 0 deletions tests/benchmarks/multicore/idle_ipc/remote/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#
# 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)

target_sources(app PRIVATE ../src/main.c)
8 changes: 8 additions & 0 deletions tests/benchmarks/multicore/idle_ipc/remote/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#
# Copyright (c) 2024 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

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

CONFIG_APP_IPC_SERVICE_SEND_INTERVAL=900
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
* Copyright (c) 2024 Nordic Semiconductor ASA
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

&uart135 {
/delete-property/ hw-flow-control;
};
24 changes: 24 additions & 0 deletions tests/benchmarks/multicore/idle_ipc/remote/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Copyright (c) 2024 Nordic Semiconductor ASA
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause


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_PM=y
CONFIG_PM_DEVICE=y
CONFIG_POWEROFF=y
CONFIG_PM_DEVICE_RUNTIME=y

# Enable for debugging pruposes only
CONFIG_PRINTK=y
CONFIG_LOG=y
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y
135 changes: 135 additions & 0 deletions tests/benchmarks/multicore/idle_ipc/src/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
/*
* Copyright (c) 2022 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/pm/device.h>
#include <zephyr/pm/device_runtime.h>
#include <string.h>
#include <zephyr/logging/log.h>
#include <zephyr/ipc/ipc_service.h>

#ifdef CONFIG_TEST_EXTRA_STACK_SIZE
#define STACKSIZE (1024 + CONFIG_TEST_EXTRA_STACK_SIZE)
#else
#define STACKSIZE (1024)
#endif

K_THREAD_STACK_DEFINE(ipc0_stack, STACKSIZE);

LOG_MODULE_REGISTER(host, LOG_LEVEL_INF);

static const struct device *const console_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_console));

struct payload {
unsigned long cnt;
unsigned long size;
uint8_t data[];
};

struct payload *p_payload;

static K_SEM_DEFINE(bound_sem, 0, 1);

static void ep_bound(void *priv)
{
k_sem_give(&bound_sem);
}

static void ep_recv(const void *data, size_t len, void *priv)
{
uint8_t received_val = *((uint8_t *)data);
static uint8_t expected_val;

if ((received_val != expected_val) || (len != CONFIG_APP_IPC_SERVICE_MESSAGE_LEN)) {
printk("Unexpected message received_val: %d , expected_val: %d\n", received_val,
expected_val);
}

expected_val++;
}

static struct ipc_ept_cfg ep_cfg = {
.name = "ep0",
.cb =
{

Check failure on line 58 in tests/benchmarks/multicore/idle_ipc/src/main.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

OPEN_BRACE

tests/benchmarks/multicore/idle_ipc/src/main.c:58 that open brace { should be on the previous line
.bound = ep_bound,
.received = ep_recv,
},
};

int main(void)
{
const struct device *ipc0_instance;
struct ipc_ept ep;
int ret;
unsigned long last_cnt = 0;
unsigned long delta = 0;

p_payload = (struct payload *)k_malloc(CONFIG_APP_IPC_SERVICE_MESSAGE_LEN);
if (!p_payload) {
printk("k_malloc() failure\n");
return -ENOMEM;
}

memset(p_payload->data, 0xA5, CONFIG_APP_IPC_SERVICE_MESSAGE_LEN - sizeof(struct payload));

p_payload->size = CONFIG_APP_IPC_SERVICE_MESSAGE_LEN;
p_payload->cnt = 0;

printk("IPC-service %s demo started\n", CONFIG_BOARD_TARGET);

ipc0_instance = DEVICE_DT_GET(DT_NODELABEL(ipc0));

ret = ipc_service_open_instance(ipc0_instance);
if ((ret < 0) && (ret != -EALREADY)) {
LOG_INF("ipc_service_open_instance() failure (%d)", ret);
return ret;
}

ret = ipc_service_register_endpoint(ipc0_instance, &ep, &ep_cfg);
if (ret < 0) {
printf("ipc_service_register_endpoint() failure (%d)", ret);
return ret;
}

if (IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME)) {
pm_device_runtime_enable(console_dev);
pm_device_runtime_enable(ipc0_instance);
}

// k_sem_take(&bound_sem, K_FOREVER);

Check failure on line 104 in tests/benchmarks/multicore/idle_ipc/src/main.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

C99_COMMENTS

tests/benchmarks/multicore/idle_ipc/src/main.c:104 do not use C99 // comments

while (true) {

printk("Hello\n");
printk("Send data over IPC\n");

for (int counter = 0; counter < 10; counter++) {
ret = ipc_service_send(&ep, p_payload, CONFIG_APP_IPC_SERVICE_MESSAGE_LEN);
if (ret == -ENOMEM) {
/* No space in the buffer. Retry. */
continue;
} else if (ret < 0) {
printk("send_message(%ld) failed with ret %d\n", p_payload->cnt,
ret);
break;
}
k_msleep(100);

delta = p_payload->cnt - last_cnt;
printk("Δpkt: %ld (%ld B/pkt) | throughput: %ld bit/s\n", delta,
p_payload->size, delta * CONFIG_APP_IPC_SERVICE_MESSAGE_LEN * 8);
last_cnt = p_payload->cnt;
p_payload->cnt++;
}

printk("Go to sleep (s2ram)\n");
k_msleep(2000);
}

return 0;
}
22 changes: 22 additions & 0 deletions tests/benchmarks/multicore/idle_ipc/sysbuild.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#
# Copyright (c) 2023 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

if("${SB_CONFIG_REMOTE_BOARD}" STREQUAL "")
message(FATAL_ERROR "REMOTE_BOARD must be set to a valid board name")
endif()

# Add remote project
ExternalZephyrProject_Add(
APPLICATION remote
SOURCE_DIR ${APP_DIR}/remote
BOARD ${SB_CONFIG_REMOTE_BOARD}
BOARD_REVISION ${BOARD_REVISION}
)

# Add a dependency so that the remote image will be built and flashed first
add_dependencies(idle_ipc remote)
# Add dependency so that the remote image is flashed first.
sysbuild_add_dependencies(FLASH idle_ipc remote)
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
SB_CONFIG_REMOTE_BOARD="nrf54h20dk/nrf54h20/cpurad"
18 changes: 18 additions & 0 deletions tests/benchmarks/multicore/idle_ipc/testcase.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
common:
sysbuild: true
tags: ci_build ci_tests_benchmarks_multicore ipc ppk_power_measure

tests:
benchmarks.multicore.idle_ipc.nrf54h20dk_cpuapp_cpurad.s2ram:
# harness: pytest
platform_allow:
- nrf54h20dk/nrf54h20/cpuapp
integration_platforms:
- nrf54h20dk/nrf54h20/cpuapp
extra_args:
- SB_CONF_FILE=sysbuild/nrf54h20dk_nrf54h20_cpurad.conf
# harness_config:

Check warning on line 14 in tests/benchmarks/multicore/idle_ipc/testcase.yaml

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

YAMLLint (comments-indentation)

tests/benchmarks/multicore/idle_ipc/testcase.yaml:14 comment not indented like content
# fixture: ppk_power_measure
# pytest_root:
# - "${CUSTOM_ROOT_TEST_DIR}/test_measure_power_consumption.py::test_measure_and_data_dump_power_consumption_uarte"

Check warning on line 17 in tests/benchmarks/multicore/idle_ipc/testcase.yaml

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

YAMLLint (line-length)

tests/benchmarks/multicore/idle_ipc/testcase.yaml:17 line too long (123 > 100 characters)

Check warning on line 18 in tests/benchmarks/multicore/idle_ipc/testcase.yaml

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

YAMLLint (empty-lines)

tests/benchmarks/multicore/idle_ipc/testcase.yaml:18 too many blank lines (1 > 0)
Loading