forked from nrfconnect/sdk-nrf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: benchmarks: multicore: Start testing IPC with s2ram
Run IPC benchmark with s2ram Signed-off-by: Bartosz Miller <[email protected]>
- Loading branch information
1 parent
7551722
commit a8d9fa1
Showing
12 changed files
with
329 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# | ||
# Copyright (c) 2024 Nordic Semiconductor ASA | ||
# | ||
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
# | ||
|
||
config APP_IPC_SERVICE_MESSAGE_LEN | ||
int "Length of single IPC message in bytes" | ||
default 100 | ||
|
||
config TEST_START_DELAY_MS | ||
int "Delay for test startup [ms]" | ||
default 0 | ||
|
||
config SLEEP_TIME_MS | ||
int "Core sleep time [ms]" | ||
default 2000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# | ||
# Copyright (c) 2024 Nordic Semiconductor ASA | ||
# | ||
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
# | ||
|
||
source "${ZEPHYR_BASE}/share/sysbuild/Kconfig" | ||
|
||
config REMOTE_BOARD | ||
string | ||
default "$(BOARD)/nrf54h20/cpurad" if SOC_NRF54H20_CPUAPP |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
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 | ||
|
||
CONFIG_ASSERT=y | ||
|
||
CONFIG_PRINTK=y | ||
CONFIG_LOG=y | ||
CONFIG_CONSOLE=y | ||
CONFIG_UART_CONSOLE=y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
8 changes: 8 additions & 0 deletions
8
tests/benchmarks/multicore/idle_ipc/remote/boards/nrf54h20dk_nrf54h20_cpurad.overlay
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
|
||
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 | ||
|
||
CONFIG_ASSERT=y | ||
|
||
# Enable for debugging pruposes only | ||
CONFIG_PRINTK=y | ||
CONFIG_LOG=y | ||
CONFIG_CONSOLE=y | ||
CONFIG_UART_CONSOLE=y |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
/* | ||
* Copyright (c) 2024 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 | ||
#define NUMBER_OF_MESSAGES_TO_SEND 20 | ||
#define IPC_SEND_DEAD_TIME_MS 1 | ||
#define IPC_BOUND_TIMEOUT_MS 5000 | ||
|
||
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); | ||
printk("Test should not enter here\n"); | ||
__ASSERT_NO_MSG(1 == 0); | ||
} | ||
|
||
expected_val++; | ||
} | ||
|
||
static struct ipc_ept_cfg ep_cfg = { | ||
.name = "ep0", | ||
.cb = { | ||
.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"); | ||
__ASSERT_NO_MSG(1 == 0); | ||
} | ||
|
||
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); | ||
__ASSERT_NO_MSG(ret == 0); | ||
} | ||
|
||
ret = ipc_service_register_endpoint(ipc0_instance, &ep, &ep_cfg); | ||
if (ret < 0) { | ||
printf("ipc_service_register_endpoint() failure (%d)", ret); | ||
__ASSERT_NO_MSG(ret == 0); | ||
} | ||
|
||
if (IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME)) { | ||
pm_device_runtime_enable(console_dev); | ||
pm_device_runtime_enable(ipc0_instance); | ||
} | ||
|
||
ret = k_sem_take(&bound_sem, K_MSEC(IPC_BOUND_TIMEOUT_MS)); | ||
if (ret < 0) { | ||
printf("k_sem_take() failure (%d)", ret); | ||
__ASSERT_NO_MSG(ret == 0); | ||
} | ||
k_msleep(CONFIG_TEST_START_DELAY_MS); | ||
|
||
while (true) { | ||
|
||
printk("Hello\n"); | ||
printk("Send data over IPC\n"); | ||
|
||
for (int counter = 0; counter < NUMBER_OF_MESSAGES_TO_SEND; 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); | ||
__ASSERT_NO_MSG(ret == 0); | ||
} | ||
k_msleep(IPC_SEND_DEAD_TIME_MS); | ||
|
||
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(CONFIG_SLEEP_TIME_MS); | ||
} | ||
|
||
return 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# | ||
# Copyright (c) 2024 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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
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 | ||
harness_config: | ||
fixture: ppk_power_measure | ||
pytest_root: | ||
- "${CUSTOM_ROOT_TEST_DIR}/test_measure_power_consumption.py::test_measure_and_data_dump_power_consumption_ipc" | ||
|
||
benchmarks.multicore.idle_ipc.shifted.nrf54h20dk_cpuapp_cpurad.s2ram: | ||
harness: pytest | ||
platform_allow: | ||
- nrf54h20dk/nrf54h20/cpuapp | ||
integration_platforms: | ||
- nrf54h20dk/nrf54h20/cpuapp | ||
extra_args: | ||
- remote_TEST_START_DELAY_MS=1000 | ||
harness_config: | ||
fixture: ppk_power_measure | ||
pytest_root: | ||
- "${CUSTOM_ROOT_TEST_DIR}/test_measure_power_consumption.py::test_measure_and_data_dump_power_consumption_ipc" |