diff --git a/tests/benchmarks/multicore/idle_stm/CMakeLists.txt b/tests/benchmarks/multicore/idle_stm/CMakeLists.txt new file mode 100644 index 00000000000..7b9a0bd77aa --- /dev/null +++ b/tests/benchmarks/multicore/idle_stm/CMakeLists.txt @@ -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_stm) + +target_sources(app PRIVATE src/main.c) diff --git a/tests/benchmarks/multicore/idle_stm/Kconfig b/tests/benchmarks/multicore/idle_stm/Kconfig new file mode 100644 index 00000000000..a63b31a208e --- /dev/null +++ b/tests/benchmarks/multicore/idle_stm/Kconfig @@ -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" diff --git a/tests/benchmarks/multicore/idle_stm/boards/nrf54h20dk_nrf54h20_cpuapp.overlay b/tests/benchmarks/multicore/idle_stm/boards/nrf54h20dk_nrf54h20_cpuapp.overlay new file mode 100644 index 00000000000..b2f81c12b86 --- /dev/null +++ b/tests/benchmarks/multicore/idle_stm/boards/nrf54h20dk_nrf54h20_cpuapp.overlay @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +/*&cpuppr_vpr { + status = "okay"; +};*/ + +&cpuppr_ram3x_region { + status = "okay"; +}; diff --git a/tests/benchmarks/multicore/idle_stm/prj.conf b/tests/benchmarks/multicore/idle_stm/prj.conf new file mode 100644 index 00000000000..e8e6ddbd0e1 --- /dev/null +++ b/tests/benchmarks/multicore/idle_stm/prj.conf @@ -0,0 +1,5 @@ +CONFIG_BOOT_BANNER=n +CONFIG_NCS_BOOT_BANNER=n + +CONFIG_LOG=y +CONFIG_ASSERT=y diff --git a/tests/benchmarks/multicore/idle_stm/prj_s2ram.conf b/tests/benchmarks/multicore/idle_stm/prj_s2ram.conf new file mode 100644 index 00000000000..08181e28589 --- /dev/null +++ b/tests/benchmarks/multicore/idle_stm/prj_s2ram.conf @@ -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=y +CONFIG_CONSOLE=n +CONFIG_UART_CONSOLE=n +CONFIG_SERIAL=y + +CONFIG_ASSERT=y diff --git a/tests/benchmarks/multicore/idle_stm/remote/CMakeLists.txt b/tests/benchmarks/multicore/idle_stm/remote/CMakeLists.txt new file mode 100644 index 00000000000..3f79e49afb2 --- /dev/null +++ b/tests/benchmarks/multicore/idle_stm/remote/CMakeLists.txt @@ -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) diff --git a/tests/benchmarks/multicore/idle_stm/remote/Kconfig b/tests/benchmarks/multicore/idle_stm/remote/Kconfig new file mode 100644 index 00000000000..a63b31a208e --- /dev/null +++ b/tests/benchmarks/multicore/idle_stm/remote/Kconfig @@ -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" diff --git a/tests/benchmarks/multicore/idle_stm/remote/prj.conf b/tests/benchmarks/multicore/idle_stm/remote/prj.conf new file mode 100644 index 00000000000..fc699dade6d --- /dev/null +++ b/tests/benchmarks/multicore/idle_stm/remote/prj.conf @@ -0,0 +1,9 @@ +CONFIG_LOG=y +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 diff --git a/tests/benchmarks/multicore/idle_stm/remote/prj_s2ram.conf b/tests/benchmarks/multicore/idle_stm/remote/prj_s2ram.conf new file mode 100644 index 00000000000..403feaa9937 --- /dev/null +++ b/tests/benchmarks/multicore/idle_stm/remote/prj_s2ram.conf @@ -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 diff --git a/tests/benchmarks/multicore/idle_stm/src/main.c b/tests/benchmarks/multicore/idle_stm/src/main.c new file mode 100644 index 00000000000..03da58c695f --- /dev/null +++ b/tests/benchmarks/multicore/idle_stm/src/main.c @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ +#include + +#include +LOG_MODULE_REGISTER(idle_stm, LOG_LEVEL_INF); + +#ifdef CONFIG_LOG_FRONTEND_STMESP +#include +#endif + +#include +#include +#include + +#ifdef CONFIG_SERIAL +static const struct device *const console_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_console)); +#endif + +/* 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_stm 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); + +#ifdef CONFIG_SERIAL + if (IS_ENABLED(CONFIG_PM_DEVICE_RUNTIME)) { + pm_device_runtime_enable(console_dev); + } +#endif + + /* 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; +} diff --git a/tests/benchmarks/multicore/idle_stm/sysbuild.cmake b/tests/benchmarks/multicore/idle_stm/sysbuild.cmake new file mode 100644 index 00000000000..4cdbe445ed5 --- /dev/null +++ b/tests/benchmarks/multicore/idle_stm/sysbuild.cmake @@ -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}/../../power_consumption/common/remote_sleep_forever + 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} +# ) diff --git a/tests/benchmarks/multicore/idle_stm/testcase.yaml b/tests/benchmarks/multicore/idle_stm/testcase.yaml new file mode 100644 index 00000000000..bdd7c0ef4d8 --- /dev/null +++ b/tests/benchmarks/multicore/idle_stm/testcase.yaml @@ -0,0 +1,46 @@ +common: + sysbuild: true + tags: ci_build ci_tests_benchmarks_multicore + platform_allow: + - nrf54h20dk/nrf54h20/cpuapp + integration_platforms: + - nrf54h20dk/nrf54h20/cpuapp + +tests: + benchmarks.multicore.idle_stm.nrf54h20dk_cpuapp_cpurad.no_sleep: + required_snippets: + - nordic-log-stm + harness: console + harness_config: + type: multi_line + ordered: true + regex: + - "Multicore idle_stm test on" + - "rad/idle_stm: Run" + - "ppr/idle_stm: Run" + - "app/idle_stm: Run" + + benchmarks.multicore.idle_stm.nrf54h20dk_cpuapp_cpurad.idle: + tags: ppk_power_measure + required_snippets: + - nordic-log-stm + extra_args: + idle_stm_CONF_FILE=prj_s2ram.conf + idle_stm_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_stm.nrf54h20dk_cpuapp_cpurad.s2ram: + tags: ppk_power_measure + required_snippets: + - nordic-log-stm + extra_args: + idle_stm_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"