From bab53b6d695e1847b98fda8bfc98f2dedc3b3bec Mon Sep 17 00:00:00 2001 From: Bartlomiej Buczek Date: Mon, 18 Nov 2024 12:51:45 +0100 Subject: [PATCH] tests: benchmars: multicore: add comp tests. Add tests for assesing s2ram with (lp)comp power consumption. Signed-off-by: Bartlomiej Buczek --- .../multicore/idle_comp/CMakeLists.txt | 18 ++++++++ .../multicore/idle_comp/Kconfig.sysbuild | 10 +++++ .../multicore/idle_comp/boards/comp.overlay | 16 +++++++ .../multicore/idle_comp/boards/lpcomp.overlay | 12 +++++ .../boards/nrf54h20dk_nrf54h20_cpuapp.overlay | 19 ++++++++ tests/benchmarks/multicore/idle_comp/prj.conf | 19 ++++++++ .../multicore/idle_comp/remote/CMakeLists.txt | 12 +++++ .../multicore/idle_comp/remote/prj.conf | 8 ++++ .../multicore/idle_comp/remote/src/main.c | 14 ++++++ .../benchmarks/multicore/idle_comp/src/main.c | 44 +++++++++++++++++++ .../multicore/idle_comp/sysbuild.cmake | 22 ++++++++++ .../sysbuild/nrf54h20dk_nrf54h20_cpurad.conf | 1 + .../multicore/idle_comp/testcase.yaml | 34 ++++++++++++++ 13 files changed, 229 insertions(+) create mode 100644 tests/benchmarks/multicore/idle_comp/CMakeLists.txt create mode 100644 tests/benchmarks/multicore/idle_comp/Kconfig.sysbuild create mode 100644 tests/benchmarks/multicore/idle_comp/boards/comp.overlay create mode 100644 tests/benchmarks/multicore/idle_comp/boards/lpcomp.overlay create mode 100644 tests/benchmarks/multicore/idle_comp/boards/nrf54h20dk_nrf54h20_cpuapp.overlay create mode 100644 tests/benchmarks/multicore/idle_comp/prj.conf create mode 100644 tests/benchmarks/multicore/idle_comp/remote/CMakeLists.txt create mode 100644 tests/benchmarks/multicore/idle_comp/remote/prj.conf create mode 100644 tests/benchmarks/multicore/idle_comp/remote/src/main.c create mode 100644 tests/benchmarks/multicore/idle_comp/src/main.c create mode 100644 tests/benchmarks/multicore/idle_comp/sysbuild.cmake create mode 100644 tests/benchmarks/multicore/idle_comp/sysbuild/nrf54h20dk_nrf54h20_cpurad.conf create mode 100644 tests/benchmarks/multicore/idle_comp/testcase.yaml diff --git a/tests/benchmarks/multicore/idle_comp/CMakeLists.txt b/tests/benchmarks/multicore/idle_comp/CMakeLists.txt new file mode 100644 index 000000000000..2b73671d8de3 --- /dev/null +++ b/tests/benchmarks/multicore/idle_comp/CMakeLists.txt @@ -0,0 +1,18 @@ +# +# 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_comp) + +target_sources(app PRIVATE src/main.c) diff --git a/tests/benchmarks/multicore/idle_comp/Kconfig.sysbuild b/tests/benchmarks/multicore/idle_comp/Kconfig.sysbuild new file mode 100644 index 000000000000..0898eb292938 --- /dev/null +++ b/tests/benchmarks/multicore/idle_comp/Kconfig.sysbuild @@ -0,0 +1,10 @@ +# +# 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" diff --git a/tests/benchmarks/multicore/idle_comp/boards/comp.overlay b/tests/benchmarks/multicore/idle_comp/boards/comp.overlay new file mode 100644 index 000000000000..4f7d216f579f --- /dev/null +++ b/tests/benchmarks/multicore/idle_comp/boards/comp.overlay @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +&comp { + main-mode = "SE"; + psel = "AIN2"; /* P1.02 */ + refsel = "INT_1V2"; + sp-mode = "HIGH"; + th-up = <63>; + th-down = <59>; + isource = "DISABLED"; + status = "okay"; +}; diff --git a/tests/benchmarks/multicore/idle_comp/boards/lpcomp.overlay b/tests/benchmarks/multicore/idle_comp/boards/lpcomp.overlay new file mode 100644 index 000000000000..328b12b7e453 --- /dev/null +++ b/tests/benchmarks/multicore/idle_comp/boards/lpcomp.overlay @@ -0,0 +1,12 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +&comp { + compatible = "nordic,nrf-lpcomp"; + psel = "AIN2"; /* P1.02 */ + refsel = "VDD_4_8"; + status = "okay"; +}; diff --git a/tests/benchmarks/multicore/idle_comp/boards/nrf54h20dk_nrf54h20_cpuapp.overlay b/tests/benchmarks/multicore/idle_comp/boards/nrf54h20dk_nrf54h20_cpuapp.overlay new file mode 100644 index 000000000000..c77b92b93acd --- /dev/null +++ b/tests/benchmarks/multicore/idle_comp/boards/nrf54h20dk_nrf54h20_cpuapp.overlay @@ -0,0 +1,19 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +/ { + aliases { + test-comp = ∁ + }; + + zephyr,user { + test-gpios = <&gpio1 3 GPIO_ACTIVE_HIGH>; + }; +}; + +&gpio1 { + status = "okay"; +}; diff --git a/tests/benchmarks/multicore/idle_comp/prj.conf b/tests/benchmarks/multicore/idle_comp/prj.conf new file mode 100644 index 000000000000..bc70dd8e6e4b --- /dev/null +++ b/tests/benchmarks/multicore/idle_comp/prj.conf @@ -0,0 +1,19 @@ +CONFIG_COMPARATOR=y +CONFIG_GPIO=y + +CONFIG_PM=y +CONFIG_PM_S2RAM=y +CONFIG_PM_S2RAM_CUSTOM_MARKING=y +CONFIG_PM_DEVICE=y +CONFIG_PM_DEVICE_RUNTIME=y +CONFIG_POWEROFF=y +CONFIG_BOOT_BANNER=n +CONFIG_SOC_NRF54H20_NO_MRAM_LATENCY=n +CONFIG_ASSERT=y + +# Enable for debugging purposes only +CONFIG_PRINTK=n +CONFIG_LOG=n +CONFIG_CONSOLE=n +CONFIG_UART_CONSOLE=n +CONFIG_SERIAL=n diff --git a/tests/benchmarks/multicore/idle_comp/remote/CMakeLists.txt b/tests/benchmarks/multicore/idle_comp/remote/CMakeLists.txt new file mode 100644 index 000000000000..97caab4871c3 --- /dev/null +++ b/tests/benchmarks/multicore/idle_comp/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_comp/remote/prj.conf b/tests/benchmarks/multicore/idle_comp/remote/prj.conf new file mode 100644 index 000000000000..e4da5b48a646 --- /dev/null +++ b/tests/benchmarks/multicore/idle_comp/remote/prj.conf @@ -0,0 +1,8 @@ +CONFIG_PM=y +CONFIG_POWEROFF=y +CONFIG_CONSOLE=n +CONFIG_UART_CONSOLE=n +CONFIG_SERIAL=n +CONFIG_GPIO=n +CONFIG_BOOT_BANNER=n +CONFIG_SOC_NRF54H20_NO_MRAM_LATENCY=n diff --git a/tests/benchmarks/multicore/idle_comp/remote/src/main.c b/tests/benchmarks/multicore/idle_comp/remote/src/main.c new file mode 100644 index 000000000000..61b5b084a585 --- /dev/null +++ b/tests/benchmarks/multicore/idle_comp/remote/src/main.c @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +#include + +int main(void) +{ + k_sleep(K_FOREVER); + + return 0; +} diff --git a/tests/benchmarks/multicore/idle_comp/src/main.c b/tests/benchmarks/multicore/idle_comp/src/main.c new file mode 100644 index 000000000000..04de05bcd894 --- /dev/null +++ b/tests/benchmarks/multicore/idle_comp/src/main.c @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +#include +#include +#include + +static const struct device *test_dev = DEVICE_DT_GET(DT_ALIAS(test_comp)); +static const struct gpio_dt_spec test_pin = GPIO_DT_SPEC_GET(DT_PATH(zephyr_user), test_gpios); + +volatile int counter; +static void test_callback(const struct device *dev, void *user_data) +{ + counter++; +} + +int main(void) +{ + + int rc; + + gpio_pin_configure_dt(&test_pin, GPIO_OUTPUT_INACTIVE); + + rc = comparator_set_trigger_callback(test_dev, test_callback, NULL); + __ASSERT_NO_MSG(rc == 0); + + rc = comparator_set_trigger(test_dev, COMPARATOR_TRIGGER_BOTH_EDGES); + __ASSERT_NO_MSG(rc == 0); + k_msleep(1000); + + while (1) { + counter = 0; + gpio_pin_set_dt(&test_pin, 1); + k_msleep(1000); + __ASSERT_NO_MSG(counter == 1); + gpio_pin_set_dt(&test_pin, 0); + k_msleep(1000); + __ASSERT_NO_MSG(counter == 2); + } + return 0; +} diff --git a/tests/benchmarks/multicore/idle_comp/sysbuild.cmake b/tests/benchmarks/multicore/idle_comp/sysbuild.cmake new file mode 100644 index 000000000000..b4c9bf113231 --- /dev/null +++ b/tests/benchmarks/multicore/idle_comp/sysbuild.cmake @@ -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_comp remote) +# Add dependency so that the remote image is flashed first. +sysbuild_add_dependencies(FLASH idle_comp remote) diff --git a/tests/benchmarks/multicore/idle_comp/sysbuild/nrf54h20dk_nrf54h20_cpurad.conf b/tests/benchmarks/multicore/idle_comp/sysbuild/nrf54h20dk_nrf54h20_cpurad.conf new file mode 100644 index 000000000000..dd863e78d993 --- /dev/null +++ b/tests/benchmarks/multicore/idle_comp/sysbuild/nrf54h20dk_nrf54h20_cpurad.conf @@ -0,0 +1 @@ +SB_CONFIG_REMOTE_BOARD="nrf54h20dk/nrf54h20/cpurad" diff --git a/tests/benchmarks/multicore/idle_comp/testcase.yaml b/tests/benchmarks/multicore/idle_comp/testcase.yaml new file mode 100644 index 000000000000..309ca98387e8 --- /dev/null +++ b/tests/benchmarks/multicore/idle_comp/testcase.yaml @@ -0,0 +1,34 @@ +common: + sysbuild: true + tags: ci_build ci_tests_benchmarks_multicore ppk_power_measure + +tests: + benchmarks.multicore.idle_comp.nrf54h20dk_cpuapp_cpurad.s2ram: + harness: pytest + platform_allow: + - nrf54h20dk/nrf54h20/cpuapp + integration_platforms: + - nrf54h20dk/nrf54h20/cpuapp + extra_args: + - FILE_SUFFIX=s2ram + - SB_CONF_FILE=sysbuild/nrf54h20dk_nrf54h20_cpurad.conf + - EXTRA_DTC_OVERLAY_FILE="boards/comp.overlay" + harness_config: + fixture: gpio_loopback + pytest_root: + - "${CUSTOM_ROOT_TEST_DIR}/test_measure_power_consumption.py::test_measure_and_data_dump_power_consumption_comp" + + benchmarks.multicore.idle_lpcomp.nrf54h20dk_cpuapp_cpurad.s2ram: + harness: pytest + platform_allow: + - nrf54h20dk/nrf54h20/cpuapp + integration_platforms: + - nrf54h20dk/nrf54h20/cpuapp + extra_args: + - FILE_SUFFIX=s2ram + - SB_CONF_FILE=sysbuild/nrf54h20dk_nrf54h20_cpurad.conf + - EXTRA_DTC_OVERLAY_FILE="boards/lpcomp.overlay" + harness_config: + fixture: gpio_loopback + pytest_root: + - "${CUSTOM_ROOT_TEST_DIR}/test_measure_power_consumption.py::test_measure_and_data_dump_power_consumption_lpcomp"