From b5841f028d2d360899310831a6ee8ce9822d96cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20G=C5=82=C4=85b?= Date: Tue, 5 Nov 2024 12:26:54 +0100 Subject: [PATCH 1/2] tests: benchmarks: multicore: idle_spim_loopback: Add test for SPIM120 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add test that combinest functional check (whether SPIM transmits data) with non-functional check (current consumption). Confirm that slow SPIM130 / fast SPIM120: - doesn't block entering low power states like IDLE or S2RAM; - work correclty after leaving low power state. Signed-off-by: Sebastian Głąb --- .../idle_spim_loopback/CMakeLists.txt | 19 ++ .../multicore/idle_spim_loopback/Kconfig | 22 +++ .../idle_spim_loopback/Kconfig.sysbuild | 10 + .../boards/nrf54h20dk_nrf54h20_cpuapp.overlay | 44 +++++ .../nrf54h20dk_nrf54h20_cpuapp_fast.overlay | 49 +++++ .../multicore/idle_spim_loopback/prj.conf | 5 + .../idle_spim_loopback/prj_s2ram.conf | 20 ++ .../multicore/idle_spim_loopback/src/main.c | 127 +++++++++++++ .../idle_spim_loopback/sysbuild.cmake | 22 +++ .../sysbuild/nrf54h20dk_nrf54h20_cpurad.conf | 1 + .../idle_spim_loopback/testcase.yaml | 177 ++++++++++++++++++ 11 files changed, 496 insertions(+) create mode 100644 tests/benchmarks/multicore/idle_spim_loopback/CMakeLists.txt create mode 100644 tests/benchmarks/multicore/idle_spim_loopback/Kconfig create mode 100644 tests/benchmarks/multicore/idle_spim_loopback/Kconfig.sysbuild create mode 100644 tests/benchmarks/multicore/idle_spim_loopback/boards/nrf54h20dk_nrf54h20_cpuapp.overlay create mode 100644 tests/benchmarks/multicore/idle_spim_loopback/boards/nrf54h20dk_nrf54h20_cpuapp_fast.overlay create mode 100644 tests/benchmarks/multicore/idle_spim_loopback/prj.conf create mode 100644 tests/benchmarks/multicore/idle_spim_loopback/prj_s2ram.conf create mode 100644 tests/benchmarks/multicore/idle_spim_loopback/src/main.c create mode 100644 tests/benchmarks/multicore/idle_spim_loopback/sysbuild.cmake create mode 100644 tests/benchmarks/multicore/idle_spim_loopback/sysbuild/nrf54h20dk_nrf54h20_cpurad.conf create mode 100644 tests/benchmarks/multicore/idle_spim_loopback/testcase.yaml diff --git a/tests/benchmarks/multicore/idle_spim_loopback/CMakeLists.txt b/tests/benchmarks/multicore/idle_spim_loopback/CMakeLists.txt new file mode 100644 index 00000000000..e9e46e9eb54 --- /dev/null +++ b/tests/benchmarks/multicore/idle_spim_loopback/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_spim_loopback) + +target_sources(app PRIVATE src/main.c) diff --git a/tests/benchmarks/multicore/idle_spim_loopback/Kconfig b/tests/benchmarks/multicore/idle_spim_loopback/Kconfig new file mode 100644 index 00000000000..4dbc860aa4f --- /dev/null +++ b/tests/benchmarks/multicore/idle_spim_loopback/Kconfig @@ -0,0 +1,22 @@ +# +# 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. + +config DATA_FIELD + int "Number of bytes exchanged in single SPI transceive operation" + default 4 + help + Set number of bytes exchanged in single spi_transceive() operation. + Values from 1 to 16 bytes are confirmed to work correctly. + +source "Kconfig.zephyr" diff --git a/tests/benchmarks/multicore/idle_spim_loopback/Kconfig.sysbuild b/tests/benchmarks/multicore/idle_spim_loopback/Kconfig.sysbuild new file mode 100644 index 00000000000..0898eb29293 --- /dev/null +++ b/tests/benchmarks/multicore/idle_spim_loopback/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_spim_loopback/boards/nrf54h20dk_nrf54h20_cpuapp.overlay b/tests/benchmarks/multicore/idle_spim_loopback/boards/nrf54h20dk_nrf54h20_cpuapp.overlay new file mode 100644 index 00000000000..07b8abd49ab --- /dev/null +++ b/tests/benchmarks/multicore/idle_spim_loopback/boards/nrf54h20dk_nrf54h20_cpuapp.overlay @@ -0,0 +1,44 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +&pinctrl { + spi130_default_alt: spi130_default_alt { + group1 { + psels = , + , + ; + }; + }; + + spi130_sleep_alt: spi130_sleep_alt { + group1 { + psels = , + , + ; + low-power-enable; + }; + }; +}; + +&spi130 { + compatible = "nordic,nrf-spim"; + status = "okay"; + pinctrl-0 = <&spi130_default_alt>; + pinctrl-1 = <&spi130_sleep_alt>; + pinctrl-names = "default", "sleep"; + overrun-character = <0x00>; + memory-regions = <&cpuapp_dma_region>; + zephyr,pm-device-runtime-auto; + dut_spi_dt: test-spi-dev@0 { + compatible = "vnd,spi-device"; + reg = <0>; + spi-max-frequency = ; + }; +}; + +&exmif { + status = "disabled"; +}; diff --git a/tests/benchmarks/multicore/idle_spim_loopback/boards/nrf54h20dk_nrf54h20_cpuapp_fast.overlay b/tests/benchmarks/multicore/idle_spim_loopback/boards/nrf54h20dk_nrf54h20_cpuapp_fast.overlay new file mode 100644 index 00000000000..7ed2e7d12eb --- /dev/null +++ b/tests/benchmarks/multicore/idle_spim_loopback/boards/nrf54h20dk_nrf54h20_cpuapp_fast.overlay @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +&pinctrl { + spi120_default: spi120_default { + group1 { + psels = , + , + ; + }; + }; + + spi120_sleep: spi120_sleep { + group1 { + psels = , + , + ; + low-power-enable; + }; + }; +}; + +&spi130 { + status = "disabled"; + /delete-property/ dut_spi_dt; +}; + +&spi120 { + compatible = "nordic,nrf-spim"; + status = "okay"; + pinctrl-0 = <&spi120_default>; + pinctrl-1 = <&spi120_sleep>; + pinctrl-names = "default", "sleep"; + overrun-character = <0x00>; + memory-regions = <&dma_fast_region>; + zephyr,pm-device-runtime-auto; + dut_spi_dt: test-spi-dev@0 { + compatible = "vnd,spi-device"; + reg = <0>; + spi-max-frequency = ; + }; +}; + +&exmif { + status = "disabled"; +}; diff --git a/tests/benchmarks/multicore/idle_spim_loopback/prj.conf b/tests/benchmarks/multicore/idle_spim_loopback/prj.conf new file mode 100644 index 00000000000..d4810cc9657 --- /dev/null +++ b/tests/benchmarks/multicore/idle_spim_loopback/prj.conf @@ -0,0 +1,5 @@ +CONFIG_PRINTK=y +CONFIG_LOG=y +CONFIG_SPI=y + +CONFIG_NRF_REGTOOL_VERBOSITY=1 diff --git a/tests/benchmarks/multicore/idle_spim_loopback/prj_s2ram.conf b/tests/benchmarks/multicore/idle_spim_loopback/prj_s2ram.conf new file mode 100644 index 00000000000..85c58943a65 --- /dev/null +++ b/tests/benchmarks/multicore/idle_spim_loopback/prj_s2ram.conf @@ -0,0 +1,20 @@ +CONFIG_PM=y +CONFIG_PM_S2RAM=y +CONFIG_PM_S2RAM_CUSTOM_MARKING=y +CONFIG_POWEROFF=y +CONFIG_NRFS_MRAM_SERVICE_ENABLED=n + +CONFIG_PM_DEVICE=y +CONFIG_PM_DEVICE_RUNTIME=y + +# Enable for debugging purposes only +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_SPI=y +CONFIG_ASSERT=y diff --git a/tests/benchmarks/multicore/idle_spim_loopback/src/main.c b/tests/benchmarks/multicore/idle_spim_loopback/src/main.c new file mode 100644 index 00000000000..597f827525f --- /dev/null +++ b/tests/benchmarks/multicore/idle_spim_loopback/src/main.c @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2024 Nordic Semiconductor ASA + * + * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause + */ + +#include +LOG_MODULE_REGISTER(idle_spim_loopback, LOG_LEVEL_INF); + +#include +#include +#include +#include + +#define DELTA (1) + +#define SPI_MODE (SPI_OP_MODE_MASTER | SPI_WORD_SET(8) | SPI_LINES_SINGLE | SPI_TRANSFER_MSB \ + | SPI_MODE_CPHA | SPI_MODE_CPOL) + +static struct spi_dt_spec spim_spec = SPI_DT_SPEC_GET(DT_NODELABEL(dut_spi_dt), SPI_MODE, 0); + +#define MEMORY_SECTION(node) \ + COND_CODE_1(DT_NODE_HAS_PROP(node, memory_regions), \ + (__attribute__((__section__( \ + LINKER_DT_NODE_REGION_NAME(DT_PHANDLE(node, memory_regions)))))), \ + ()) + +static uint8_t spim_buffer[2 * CONFIG_DATA_FIELD] + MEMORY_SECTION(DT_BUS(DT_NODELABEL(dut_spi_dt))); + +/* Variables used to make SPI 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 ret; + int counter = 0; + uint8_t acc = 0; + bool test_pass; + + /* SPI buffer sets */ + struct spi_buf tx_spi_buf = { + .buf = &spim_buffer[0], + .len = CONFIG_DATA_FIELD + }; + struct spi_buf_set tx_spi_buf_set = { + .buffers = &tx_spi_buf, + .count = 1 + }; + + struct spi_buf rx_spi_buf = { + .buf = &spim_buffer[CONFIG_DATA_FIELD], + .len = CONFIG_DATA_FIELD + }; + struct spi_buf_set rx_spi_buf_set = { + .buffers = &rx_spi_buf, + .count = 1 + }; + + LOG_INF("%s runs as a SPI HOST", CONFIG_BOARD_TARGET); + LOG_INF("%d bytes of data exchanged at once", CONFIG_DATA_FIELD); + + ret = spi_is_ready_dt(&spim_spec); + if (!ret) { + LOG_ERR("Error: SPI device is not ready"); + } + __ASSERT(ret, "Error: SPI device is not ready\n"); + + k_timer_init(&my_timer, my_timer_handler, NULL); + + /* Run test forever */ + while (1) { + test_pass = true; + timer_expired = false; + + /* start a one-shot timer that expires after 1 second */ + k_timer_start(&my_timer, K_MSEC(1000), K_NO_WAIT); + + /* SPI active transmissions for ~ 1 second */ + while (!timer_expired) { + /* Generate pseudo random tx_data for current test */ + for (int i = 0; i < CONFIG_DATA_FIELD; i++) { + *((uint8_t *) tx_spi_buf.buf + i) = acc; + acc += DELTA; + } + + /* Transmit data */ + ret = spi_transceive_dt(&spim_spec, &tx_spi_buf_set, &rx_spi_buf_set); + if (ret != 0) { + LOG_ERR("spi_transceive_dt, err: %d", ret); + } + __ASSERT(ret == 0, "Error: spi_transceive_dt, err: %d\n", ret); + + /* Check if the received data is consistent with the data sent */ + for (int i = 0; i < CONFIG_DATA_FIELD; i++) { + uint8_t received = *((uint8_t *) rx_spi_buf.buf + i); + uint8_t transmitted = *((uint8_t *) tx_spi_buf.buf + i); + + if (received != transmitted) { + LOG_ERR("FAIL: rx[%d] = %d, expected %d", + i, received, transmitted); + test_pass = false; + __ASSERT(false, "Run %d - FAILED\n", counter); + } + } + } /* while (!timer_expired) */ + + /* Report if communication was successful */ + if (test_pass) { + LOG_INF("Run %d - PASS", counter); + } else { + LOG_INF("Run %d - FAILED", counter); + } + counter++; + + /* Sleep / enter low power state */ + k_msleep(CONFIG_TEST_SLEEP_DURATION_MS); + } + + return 0; +} diff --git a/tests/benchmarks/multicore/idle_spim_loopback/sysbuild.cmake b/tests/benchmarks/multicore/idle_spim_loopback/sysbuild.cmake new file mode 100644 index 00000000000..731722ace53 --- /dev/null +++ b/tests/benchmarks/multicore/idle_spim_loopback/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}/../../power_consumption/common/remote_sleep_forever + 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_spim_loopback remote) +# Add dependency so that the remote image is flashed first. +sysbuild_add_dependencies(FLASH idle_spim_loopback remote) diff --git a/tests/benchmarks/multicore/idle_spim_loopback/sysbuild/nrf54h20dk_nrf54h20_cpurad.conf b/tests/benchmarks/multicore/idle_spim_loopback/sysbuild/nrf54h20dk_nrf54h20_cpurad.conf new file mode 100644 index 00000000000..dd863e78d99 --- /dev/null +++ b/tests/benchmarks/multicore/idle_spim_loopback/sysbuild/nrf54h20dk_nrf54h20_cpurad.conf @@ -0,0 +1 @@ +SB_CONFIG_REMOTE_BOARD="nrf54h20dk/nrf54h20/cpurad" diff --git a/tests/benchmarks/multicore/idle_spim_loopback/testcase.yaml b/tests/benchmarks/multicore/idle_spim_loopback/testcase.yaml new file mode 100644 index 00000000000..c5e43cbd2aa --- /dev/null +++ b/tests/benchmarks/multicore/idle_spim_loopback/testcase.yaml @@ -0,0 +1,177 @@ +common: + sysbuild: true + tags: ci_build ci_tests_benchmarks_multicore spim + platform_allow: + - nrf54h20dk/nrf54h20/cpuapp + integration_platforms: + - nrf54h20dk/nrf54h20/cpuapp + +tests: + + # + # 4 Bytes of data + # + + benchmarks.multicore.idle_spim_loopback.4_bytes.no_sleep: + extra_args: + SB_CONF_FILE=sysbuild/nrf54h20dk_nrf54h20_cpurad.conf + harness: console + harness_config: + fixture: spi_loopback + type: multi_line + ordered: true + regex: + - ".*runs as a SPI HOST" + - "4 bytes of data exchanged at once" + - ".*Run 0 - PASS" + - ".*Run 1 - PASS" + + benchmarks.multicore.idle_spim_loopback.4_bytes.idle: + tags: ppk_power_measure + extra_args: + SB_CONF_FILE=sysbuild/nrf54h20dk_nrf54h20_cpurad.conf + idle_spim_loopback_CONF_FILE=prj_s2ram.conf + idle_spim_loopback_CONFIG_TEST_SLEEP_DURATION_MS=500 + harness: pytest + harness_config: + fixture: spi_loopback + pytest_root: + - "${CUSTOM_ROOT_TEST_DIR}/test_measure_power_consumption.py::test_measure_and_data_dump_pwm_and_idle" + + benchmarks.multicore.idle_spim_loopback.4_bytes.s2ram: + tags: ppk_power_measure + extra_args: + SB_CONF_FILE=sysbuild/nrf54h20dk_nrf54h20_cpurad.conf + idle_spim_loopback_CONF_FILE=prj_s2ram.conf + harness: pytest + harness_config: + fixture: spi_loopback + pytest_root: + - "${CUSTOM_ROOT_TEST_DIR}/test_measure_power_consumption.py::test_measure_and_data_dump_pwm_and_s2ram" + + benchmarks.multicore.idle_spim_loopback.4_bytes.no_sleep_fast: + extra_args: + SB_CONF_FILE=sysbuild/nrf54h20dk_nrf54h20_cpurad.conf + idle_spim_loopback_DTC_OVERLAY_FILE="boards/nrf54h20dk_nrf54h20_cpuapp_fast.overlay" + harness: console + harness_config: + fixture: spi_loopback + type: multi_line + ordered: true + regex: + - ".*runs as a SPI HOST" + - "4 bytes of data exchanged at once" + - ".*Run 0 - PASS" + - ".*Run 1 - PASS" + + benchmarks.multicore.idle_spim_loopback.4_bytes.idle_fast: + tags: ppk_power_measure + extra_args: + SB_CONF_FILE=sysbuild/nrf54h20dk_nrf54h20_cpurad.conf + idle_spim_loopback_CONF_FILE=prj_s2ram.conf + idle_spim_loopback_CONFIG_TEST_SLEEP_DURATION_MS=500 + idle_spim_loopback_DTC_OVERLAY_FILE="boards/nrf54h20dk_nrf54h20_cpuapp_fast.overlay" + harness: pytest + harness_config: + fixture: spi_loopback + pytest_root: + - "${CUSTOM_ROOT_TEST_DIR}/test_measure_power_consumption.py::test_measure_and_data_dump_pwm_and_idle" + + benchmarks.multicore.idle_spim_loopback.4_bytes.s2ram_fast: + tags: ppk_power_measure + extra_args: + SB_CONF_FILE=sysbuild/nrf54h20dk_nrf54h20_cpurad.conf + idle_spim_loopback_CONF_FILE=prj_s2ram.conf + idle_spim_loopback_DTC_OVERLAY_FILE="boards/nrf54h20dk_nrf54h20_cpuapp_fast.overlay" + harness: pytest + harness_config: + fixture: spi_loopback + pytest_root: + - "${CUSTOM_ROOT_TEST_DIR}/test_measure_power_consumption.py::test_measure_and_data_dump_pwm_and_s2ram" + + # + # 16 Bytes of data + # + + benchmarks.multicore.idle_spim_loopback.16_bytes.no_sleep: + extra_args: + SB_CONF_FILE=sysbuild/nrf54h20dk_nrf54h20_cpurad.conf + idle_spim_loopback_CONFIG_DATA_FIELD=16 + harness: console + harness_config: + fixture: spi_loopback + type: multi_line + ordered: true + regex: + - ".*runs as a SPI HOST" + - "16 bytes of data exchanged at once" + - ".*Run 0 - PASS" + - ".*Run 1 - PASS" + + benchmarks.multicore.idle_spim_loopback.16_bytes.idle: + tags: ppk_power_measure + extra_args: + SB_CONF_FILE=sysbuild/nrf54h20dk_nrf54h20_cpurad.conf + idle_spim_loopback_CONF_FILE=prj_s2ram.conf + idle_spim_loopback_CONFIG_TEST_SLEEP_DURATION_MS=500 + idle_spim_loopback_CONFIG_DATA_FIELD=16 + harness: pytest + harness_config: + fixture: spi_loopback + pytest_root: + - "${CUSTOM_ROOT_TEST_DIR}/test_measure_power_consumption.py::test_measure_and_data_dump_pwm_and_idle" + + benchmarks.multicore.idle_spim_loopback.16_bytes.s2ram: + tags: ppk_power_measure + extra_args: + SB_CONF_FILE=sysbuild/nrf54h20dk_nrf54h20_cpurad.conf + idle_spim_loopback_CONF_FILE=prj_s2ram.conf + idle_spim_loopback_CONFIG_DATA_FIELD=16 + harness: pytest + harness_config: + fixture: spi_loopback + pytest_root: + - "${CUSTOM_ROOT_TEST_DIR}/test_measure_power_consumption.py::test_measure_and_data_dump_pwm_and_s2ram" + + benchmarks.multicore.idle_spim_loopback.16_bytes.no_sleep_fast: + extra_args: + SB_CONF_FILE=sysbuild/nrf54h20dk_nrf54h20_cpurad.conf + idle_spim_loopback_DTC_OVERLAY_FILE="boards/nrf54h20dk_nrf54h20_cpuapp_fast.overlay" + idle_spim_loopback_CONFIG_DATA_FIELD=16 + harness: console + harness_config: + fixture: spi_loopback + type: multi_line + ordered: true + regex: + - ".*runs as a SPI HOST" + - "16 bytes of data exchanged at once" + - ".*Run 0 - PASS" + - ".*Run 1 - PASS" + + benchmarks.multicore.idle_spim_loopback.16_bytes.idle_fast: + tags: ppk_power_measure + extra_args: + SB_CONF_FILE=sysbuild/nrf54h20dk_nrf54h20_cpurad.conf + idle_spim_loopback_CONF_FILE=prj_s2ram.conf + idle_spim_loopback_CONFIG_TEST_SLEEP_DURATION_MS=500 + idle_spim_loopback_DTC_OVERLAY_FILE="boards/nrf54h20dk_nrf54h20_cpuapp_fast.overlay" + idle_spim_loopback_CONFIG_DATA_FIELD=16 + harness: pytest + harness_config: + fixture: spi_loopback + pytest_root: + - "${CUSTOM_ROOT_TEST_DIR}/test_measure_power_consumption.py::test_measure_and_data_dump_pwm_and_idle" + + benchmarks.multicore.idle_spim_loopback.16_bytes.s2ram_fast: + tags: ppk_power_measure + extra_args: + SB_CONF_FILE=sysbuild/nrf54h20dk_nrf54h20_cpurad.conf + idle_spim_loopback_CONF_FILE=prj_s2ram.conf + idle_spim_loopback_DTC_OVERLAY_FILE="boards/nrf54h20dk_nrf54h20_cpuapp_fast.overlay" + idle_spim_loopback_CONFIG_DATA_FIELD=16 + harness: pytest + harness_config: + fixture: spi_loopback + pytest_root: + - "${CUSTOM_ROOT_TEST_DIR}/test_measure_power_consumption.py::test_measure_and_data_dump_pwm_and_s2ram" From 2d55d29627061ef8859fba426c0da65b0805dad7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20G=C5=82=C4=85b?= Date: Tue, 5 Nov 2024 13:06:38 +0100 Subject: [PATCH 2/2] tests: benchmarks: multicore: idle_spim_loopback: Disable GD2 and GD3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This commit shall be dropped when GD handling is implemented in sdk-zephyr. Signed-off-by: Sebastian Głąb --- .../idle_spim_loopback/prj_s2ram.conf | 1 + .../multicore/idle_spim_loopback/src/main.c | 53 +++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/tests/benchmarks/multicore/idle_spim_loopback/prj_s2ram.conf b/tests/benchmarks/multicore/idle_spim_loopback/prj_s2ram.conf index 85c58943a65..0107350c6ed 100644 --- a/tests/benchmarks/multicore/idle_spim_loopback/prj_s2ram.conf +++ b/tests/benchmarks/multicore/idle_spim_loopback/prj_s2ram.conf @@ -18,3 +18,4 @@ CONFIG_SERIAL=n CONFIG_SPI=y CONFIG_ASSERT=y +CONFIG_NRFS=y diff --git a/tests/benchmarks/multicore/idle_spim_loopback/src/main.c b/tests/benchmarks/multicore/idle_spim_loopback/src/main.c index 597f827525f..f83bafff98c 100644 --- a/tests/benchmarks/multicore/idle_spim_loopback/src/main.c +++ b/tests/benchmarks/multicore/idle_spim_loopback/src/main.c @@ -12,6 +12,9 @@ LOG_MODULE_REGISTER(idle_spim_loopback, LOG_LEVEL_INF); #include #include +#include +#include + #define DELTA (1) #define SPI_MODE (SPI_OP_MODE_MASTER | SPI_WORD_SET(8) | SPI_LINES_SINGLE | SPI_TRANSFER_MSB \ @@ -37,6 +40,53 @@ void my_timer_handler(struct k_timer *dummy) timer_expired = true; } +/* Required to power off the GD2 and GD3 domains + * Will be removed when GD handling + * is implemented in sdk-zephyr + */ +static void gdpwr_handler(nrfs_gdpwr_evt_t const *p_evt, void *context) +{ + switch (p_evt->type) { + case NRFS_GDPWR_REQ_APPLIED: + printk("GDPWR handler - response received: 0x%x, CTX=%d\n", p_evt->type, + (uint32_t)context); + break; + case NRFS_GDPWR_REQ_REJECTED: + printk("GDPWR handler - request rejected: 0x%x, CTX=%d\n", p_evt->type, + (uint32_t)context); + break; + default: + printk("GDPWR handler - unexpected event: 0x%x, CTX=%d\n", p_evt->type, + (uint32_t)context); + break; + } +} + +/* Required to power off the GD2 and GD3 domains + * Will be removed when GD handling + * is implemented in sdk-zephyr + */ +static void clear_global_power_domains_requests(void) +{ + int service_status; + int tst_ctx = 1; + + service_status = nrfs_gdpwr_init(gdpwr_handler); + printk("Response: %d\n", service_status); + printk("Sending GDPWR DISABLE request for: GDPWR_POWER_DOMAIN_ACTIVE_SLOW\n"); + service_status = nrfs_gdpwr_power_request(GDPWR_POWER_DOMAIN_ACTIVE_SLOW, + GDPWR_POWER_REQUEST_CLEAR, (void *)tst_ctx++); + printk("Response: %d\n", service_status); + printk("Sending GDPWR DISABLE request for: GDPWR_POWER_DOMAIN_ACTIVE_FAST\n"); + service_status = nrfs_gdpwr_power_request(GDPWR_POWER_DOMAIN_ACTIVE_FAST, + GDPWR_POWER_REQUEST_CLEAR, (void *)tst_ctx++); + printk("Response: %d\n", service_status); + printk("Sending GDPWR DISABLE request for: GDPWR_POWER_DOMAIN_MAIN_SLOW\n"); + service_status = nrfs_gdpwr_power_request(GDPWR_POWER_DOMAIN_MAIN_SLOW, + GDPWR_POWER_REQUEST_CLEAR, (void *)tst_ctx); + printk("Response: %d\n", service_status); +} + int main(void) { int ret; @@ -63,6 +113,9 @@ int main(void) .count = 1 }; + nrfs_backend_wait_for_connection(K_FOREVER); + clear_global_power_domains_requests(); + LOG_INF("%s runs as a SPI HOST", CONFIG_BOARD_TARGET); LOG_INF("%d bytes of data exchanged at once", CONFIG_DATA_FIELD);