Skip to content

Commit

Permalink
tests: benchmarks: multicore: Add test for S2RAM and PPR
Browse files Browse the repository at this point in the history
Add non-functional check (current consumption) for sample
application that:
- runs on cpuapp, cpurad and cpuppr;
- enters low power state.

Confirm that when PPR core is used:
- SOC may enter low power states like IDLE or S2RAM.

Signed-off-by: Sebastian Głąb <[email protected]>
  • Loading branch information
nordic-segl committed Nov 12, 2024
1 parent db0b80c commit 9d04949
Show file tree
Hide file tree
Showing 12 changed files with 237 additions and 0 deletions.
19 changes: 19 additions & 0 deletions tests/benchmarks/multicore/idle_ppr/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_ppr)

target_sources(app PRIVATE src/main.c)
15 changes: 15 additions & 0 deletions tests/benchmarks/multicore/idle_ppr/Kconfig
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
#

config TEST_SLEEP_DURATION_MS
int "Amount of time (in miliseconds) the core is sleeping"
default 1000
help
Set sleep duration to TEST_SLEEP_DURATION_MS miliseconds.
Based on the value of 'min-residency-us' specified for each power state defined in the DTS,
core enters the lowest possible power state.

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

/* &cpuppr_vpr {
* status = "okay";
* };
*/

&cpuppr_ram3x_region {
status = "okay";
};
5 changes: 5 additions & 0 deletions tests/benchmarks/multicore/idle_ppr/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
CONFIG_BOOT_BANNER=n
CONFIG_NCS_BOOT_BANNER=n

CONFIG_LOG=y
CONFIG_ASSERT=y
18 changes: 18 additions & 0 deletions tests/benchmarks/multicore/idle_ppr/prj_s2ram.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
CONFIG_PM=y
CONFIG_PM_S2RAM=y
CONFIG_PM_S2RAM_CUSTOM_MARKING=y
CONFIG_POWEROFF=y
CONFIG_SOC_NRF54H20_NO_MRAM_LATENCY=n

CONFIG_PM_DEVICE=y
CONFIG_PM_DEVICE_RUNTIME=y

CONFIG_BOOT_BANNER=n
CONFIG_NCS_BOOT_BANNER=n
CONFIG_PRINTK=n
CONFIG_LOG=n
CONFIG_CONSOLE=n
CONFIG_UART_CONSOLE=n
CONFIG_SERIAL=n

CONFIG_ASSERT=y
12 changes: 12 additions & 0 deletions tests/benchmarks/multicore/idle_ppr/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)
15 changes: 15 additions & 0 deletions tests/benchmarks/multicore/idle_ppr/remote/Kconfig
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
#

config TEST_SLEEP_DURATION_MS
int "Amount of time (in miliseconds) the core is sleeping"
default 1000
help
Set sleep duration to TEST_SLEEP_DURATION_MS miliseconds.
Based on the value of 'min-residency-us' specified for each power state defined in the DTS,
core enters the lowest possible power state.

source "Kconfig.zephyr"
9 changes: 9 additions & 0 deletions tests/benchmarks/multicore/idle_ppr/remote/prj.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CONFIG_LOG=n
CONFIG_CONSOLE=n
CONFIG_UART_CONSOLE=n
CONFIG_SERIAL=n
CONFIG_BOOT_BANNER=n
CONFIG_NCS_BOOT_BANNER=n
CONFIG_PRINTK=n

CONFIG_ASSERT=y
12 changes: 12 additions & 0 deletions tests/benchmarks/multicore/idle_ppr/remote/prj_s2ram.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
CONFIG_PM=y
CONFIG_POWEROFF=y

CONFIG_PM_DEVICE=y
CONFIG_PM_DEVICE_RUNTIME=y

CONFIG_CONSOLE=n
CONFIG_UART_CONSOLE=n
CONFIG_SERIAL=n
CONFIG_BOOT_BANNER=n
CONFIG_NCS_BOOT_BANNER=n
CONFIG_SOC_NRF54H20_NO_MRAM_LATENCY=n
53 changes: 53 additions & 0 deletions tests/benchmarks/multicore/idle_ppr/src/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* Copyright (c) 2024 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/
#include <zephyr/kernel.h>

#include <zephyr/logging/log.h>
LOG_MODULE_REGISTER(idle_ppr, LOG_LEVEL_INF);

/* Variables used to make CPU active for ~1 second */
static struct k_timer my_timer;
static bool timer_expired;

void my_timer_handler(struct k_timer *dummy)
{
timer_expired = true;
}

int main(void)
{
int counter = 0;

LOG_INF("Multicore idle_ppr test on %s", CONFIG_BOARD_TARGET);
LOG_INF("Main sleeps for %d ms", CONFIG_TEST_SLEEP_DURATION_MS);

k_timer_init(&my_timer, my_timer_handler, NULL);

/* Run test forever */
while (1) {
timer_expired = false;

/* start a one-shot timer that expires after 1 second */
k_timer_start(&my_timer, K_MSEC(1000), K_NO_WAIT);

/* Keep CPU active for ~ 1 second */
while (!timer_expired) {
k_busy_wait(10000);
k_yield();
}

LOG_INF("Run %d", counter);
counter++;

/* Sleep / enter low power state
* Watchdog was started with option WDT_OPT_PAUSE_IN_SLEEP thus
* it shall not reset the core during sleep.
*/
k_msleep(CONFIG_TEST_SLEEP_DURATION_MS);
}

return 0;
}
20 changes: 20 additions & 0 deletions tests/benchmarks/multicore/idle_ppr/sysbuild.cmake
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
#

# Add remote project
ExternalZephyrProject_Add(
APPLICATION remote_rad
SOURCE_DIR ${APP_DIR}/remote
BOARD ${SB_CONFIG_BOARD}/${SB_CONFIG_SOC}/cpurad
BOARD_REVISION ${BOARD_REVISION}
)

# ExternalZephyrProject_Add(
# APPLICATION remote_ppr
# SOURCE_DIR ${APP_DIR}/remote
# BOARD ${SB_CONFIG_BOARD}/${SB_CONFIG_SOC}/cpuppr
# BOARD_REVISION ${BOARD_REVISION}
# )
45 changes: 45 additions & 0 deletions tests/benchmarks/multicore/idle_ppr/testcase.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
common:
sysbuild: true
tags: ci_build ci_tests_benchmarks_multicore
platform_allow:
- nrf54h20dk/nrf54h20/cpuapp
integration_platforms:
- nrf54h20dk/nrf54h20/cpuapp

tests:
benchmarks.multicore.idle_ppr.no_sleep:
harness: console
harness_config:
type: multi_line
ordered: true
regex:
- "Multicore idle_ppr test on"
- "idle_ppr: Run 0"
- "idle_ppr: Run 1"

benchmarks.multicore.idle_ppr.idle:
tags: ppk_power_measure
extra_args:
idle_ppr_CONF_FILE=prj_s2ram.conf
remote_rad_CONF_FILE=prj_s2ram.conf
remote_ppr_CONF_FILE=prj_s2ram.conf
idle_ppr_CONFIG_TEST_SLEEP_DURATION_MS=500
remote_rad_CONFIG_TEST_SLEEP_DURATION_MS=500
remote_ppr_CONFIG_TEST_SLEEP_DURATION_MS=500
harness: pytest
harness_config:
fixture: ppk_power_measure
pytest_root:
- "${CUSTOM_ROOT_TEST_DIR}/test_measure_power_consumption.py::test_measure_and_data_dump_pwm_and_idle"

benchmarks.multicore.idle_ppr.s2ram:
tags: ppk_power_measure
extra_args:
idle_ppr_CONF_FILE=prj_s2ram.conf
remote_rad_CONF_FILE=prj_s2ram.conf
remote_ppr_CONF_FILE=prj_s2ram.conf
harness: pytest
harness_config:
fixture: ppk_power_measure
pytest_root:
- "${CUSTOM_ROOT_TEST_DIR}/test_measure_power_consumption.py::test_measure_and_data_dump_pwm_and_idle"

0 comments on commit 9d04949

Please sign in to comment.