Skip to content

Commit

Permalink
tests: benchmarks: multicore: Remote GDF switching
Browse files Browse the repository at this point in the history
Add test cases for fast pwm, spim, uarte instances
where global domain frequency is changed from
remote application

Signed-off-by: Piotr Krzyzanowski <[email protected]>
  • Loading branch information
nordic-pikr committed Feb 26, 2025
1 parent ed34c4a commit cd63074
Show file tree
Hide file tree
Showing 14 changed files with 217 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#
# Copyright (c) 2025 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_sleep_forever)

target_sources(app PRIVATE src/main.c)
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright (c) 2025 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/

/ {
aliases {
led = &led1;
};

leds {
compatible = "gpio-leds";
led1: led_1 {
gpios = <&gpio9 1 GPIO_ACTIVE_HIGH>;
label = "Green LED 1";
};
};
};

&gpio9 {
status = "okay";
};

&gpiote130 {
status = "okay";
};

&uart135 {
status = "disabled";
/delete-property/memory-regions;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
CONFIG_CLOCK_CONTROL=y

CONFIG_PM=y
CONFIG_POWEROFF=y
CONFIG_CONSOLE=n
CONFIG_UART_CONSOLE=n
CONFIG_SERIAL=n
CONFIG_GPIO=y
CONFIG_BOOT_BANNER=n
54 changes: 54 additions & 0 deletions tests/benchmarks/multicore/common/remote_gdf_switching/src/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright (c) 2025 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/
#include <zephyr/kernel.h>
#include <zephyr/drivers/gpio.h>
#include <zephyr/devicetree/clocks.h>
#include <zephyr/drivers/clock_control/nrf_clock_control.h>

static const struct gpio_dt_spec led = GPIO_DT_SPEC_GET(DT_ALIAS(led), gpios);

const uint32_t freq[] = {320, 256, 128, 64};

/*
* Set Global Domain frequency (HSFLL120)
*/
void set_global_domain_frequency(uint32_t freq)
{
int err;
int res;
struct onoff_client cli;
const struct device *hsfll_dev = DEVICE_DT_GET(DT_NODELABEL(hsfll120));
const struct nrf_clock_spec clk_spec_global_hsfll = {.frequency = MHZ(freq)};

printk("Requested frequency [Hz]: %d\n", clk_spec_global_hsfll.frequency);
sys_notify_init_spinwait(&cli.notify);
err = nrf_clock_control_request(hsfll_dev, &clk_spec_global_hsfll, &cli);
__ASSERT((err >= 0 && err < 3), "Wrong nrf_clock_control_request return code");
do {
err = sys_notify_fetch_result(&cli.notify, &res);
k_yield();
} while (err == -EAGAIN);
__ASSERT(err == 0, "Wrong clock control request return code");
__ASSERT(res == 0, "Wrong clock control request response");
}

int main(void)
{
uint32_t counter = 0;

gpio_pin_configure_dt(&led, GPIO_OUTPUT_INACTIVE);
k_msleep(300);

while (1) {
gpio_pin_set_dt(&led, 1);
set_global_domain_frequency(freq[counter++ % ARRAY_SIZE(freq)]);
k_busy_wait(1000);
gpio_pin_set_dt(&led, 0);
k_msleep(2000);
}

return 0;
}
7 changes: 3 additions & 4 deletions tests/benchmarks/multicore/idle_pwm_loopback/Kconfig.sysbuild
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#
# Copyright (c) 2024 Nordic Semiconductor ASA
# Copyright (c) 2025 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
config REMOTE_GLOBAL_DOMAIN_CLOCK_FREQUENCY_SWITCHING
bool "Enable global domain frequency changing from remote"
3 changes: 1 addition & 2 deletions tests/benchmarks/multicore/idle_pwm_loopback/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,7 @@ int main(void)
/* Keep PWM active for ~ 1 second */
while (!timer_expired) {
/* GPIOTE shall count edges here */
k_msleep(10);
k_yield();
k_busy_wait(10000);
}

/* Disable PWM */
Expand Down
20 changes: 12 additions & 8 deletions tests/benchmarks/multicore/idle_pwm_loopback/sysbuild.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,18 @@
# 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()
if(SB_CONFIG_SOC_NRF54H20)
if(SB_CONFIG_REMOTE_GLOBAL_DOMAIN_CLOCK_FREQUENCY_SWITCHING)
set(REMOTE_SOURCE_DIR ${ZEPHYR_NRF_MODULE_DIR}/tests/benchmarks/multicore/common/remote_gdf_switching)
else()
set(REMOTE_SOURCE_DIR ${APP_DIR}/remote)
endif()

# Add remote project
ExternalZephyrProject_Add(
# Add remote project
ExternalZephyrProject_Add(
APPLICATION remote
SOURCE_DIR ${APP_DIR}/remote
BOARD ${SB_CONFIG_REMOTE_BOARD}
SOURCE_DIR ${REMOTE_SOURCE_DIR}
BOARD ${SB_CONFIG_BOARD}/${SB_CONFIG_SOC}/cpurad
BOARD_REVISION ${BOARD_REVISION}
)
)
endif()
13 changes: 13 additions & 0 deletions tests/benchmarks/multicore/idle_pwm_loopback/testcase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,19 @@ tests:
pytest_root:
- "${CUSTOM_ROOT_TEST_DIR}/test_measure_power_consumption.py::test_measure_and_data_dump_pwm_and_s2ram"

benchmarks.multicore.idle_pwm_loopback.nrf54h20dk_cpuapp_cpurad.s2ram_fast.remote_gd_freq_switching:
filter: not CONFIG_COVERAGE
tags: ppk_power_measure
extra_args:
- idle_pwm_loopback_CONF_FILE=prj_s2ram.conf
- idle_pwm_loopback_DTC_OVERLAY_FILE="boards/nrf54h20dk_nrf54h20_cpuapp_fast_p7_1.overlay"
- SB_CONFIG_REMOTE_GLOBAL_DOMAIN_CLOCK_FREQUENCY_SWITCHING=y
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_pwm_loopback.nrf54h20dk_cpuapp_cpurad.s2ram_fast.gd_freq_320MHz:
filter: not CONFIG_COVERAGE
tags: ppk_power_measure
Expand Down
10 changes: 10 additions & 0 deletions tests/benchmarks/multicore/idle_spim_loopback/Kconfig.sysbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#
# Copyright (c) 2025 Nordic Semiconductor ASA
#
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
#

source "${ZEPHYR_BASE}/share/sysbuild/Kconfig"

config REMOTE_GLOBAL_DOMAIN_CLOCK_FREQUENCY_SWITCHING
bool "Enable global domain frequency changing from remote"
8 changes: 7 additions & 1 deletion tests/benchmarks/multicore/idle_spim_loopback/sysbuild.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,16 @@
#

if(SB_CONFIG_SOC_NRF54H20)
if(SB_CONFIG_REMOTE_GLOBAL_DOMAIN_CLOCK_FREQUENCY_SWITCHING)
set(REMOTE_SOURCE_DIR ${ZEPHYR_NRF_MODULE_DIR}/tests/benchmarks/multicore/common/remote_gdf_switching)
else()
set(REMOTE_SOURCE_DIR ${ZEPHYR_NRF_MODULE_DIR}/tests/benchmarks/power_consumption/common/remote_sleep_forever)
endif()

# Add remote project
ExternalZephyrProject_Add(
APPLICATION remote
SOURCE_DIR ${ZEPHYR_NRF_MODULE_DIR}/tests/benchmarks/power_consumption/common/remote_sleep_forever
SOURCE_DIR ${REMOTE_SOURCE_DIR}
BOARD ${SB_CONFIG_BOARD}/${SB_CONFIG_SOC}/cpurad
BOARD_REVISION ${BOARD_REVISION}
)
Expand Down
28 changes: 28 additions & 0 deletions tests/benchmarks/multicore/idle_spim_loopback/testcase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,20 @@ tests:
pytest_root:
- "${CUSTOM_ROOT_TEST_DIR}/test_measure_power_consumption.py::test_measure_and_data_dump_spim_and_s2ram"

benchmarks.multicore.idle_spim_loopback.4_bytes.s2ram_fast.remote_gd_freq_switching:
filter: not CONFIG_COVERAGE
tags: ppk_power_measure
extra_args:
- 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=4
- SB_CONFIG_REMOTE_GLOBAL_DOMAIN_CLOCK_FREQUENCY_SWITCHING=y
harness: pytest
harness_config:
fixture: spi_loopback
pytest_root:
- "${CUSTOM_ROOT_TEST_DIR}/test_measure_power_consumption.py::test_measure_and_data_dump_spim_and_s2ram"

benchmarks.multicore.idle_spim_loopback.4_bytes.gd_freq_64MHz.s2ram_fast:
filter: not CONFIG_COVERAGE
tags: ppk_power_measure
Expand Down Expand Up @@ -222,6 +236,20 @@ tests:
pytest_root:
- "${CUSTOM_ROOT_TEST_DIR}/test_measure_power_consumption.py::test_measure_and_data_dump_spim_and_s2ram"

benchmarks.multicore.idle_spim_loopback.16_bytes.s2ram_fast.remote_gd_freq_switching:
filter: not CONFIG_COVERAGE
tags: ppk_power_measure
extra_args:
- 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
- SB_CONFIG_REMOTE_GLOBAL_DOMAIN_CLOCK_FREQUENCY_SWITCHING=y
harness: pytest
harness_config:
fixture: spi_loopback
pytest_root:
- "${CUSTOM_ROOT_TEST_DIR}/test_measure_power_consumption.py::test_measure_and_data_dump_spim_and_s2ram"

benchmarks.multicore.idle_spim_loopback.16_bytes.gd_freq_256MHz.s2ram_fast:
filter: not CONFIG_COVERAGE
tags: ppk_power_measure
Expand Down
7 changes: 3 additions & 4 deletions tests/benchmarks/multicore/idle_uarte/Kconfig.sysbuild
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#
# Copyright (c) 2024 Nordic Semiconductor ASA
# Copyright (c) 2025 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
config REMOTE_GLOBAL_DOMAIN_CLOCK_FREQUENCY_SWITCHING
bool "Enable global domain frequency changing from remote"
25 changes: 12 additions & 13 deletions tests/benchmarks/multicore/idle_uarte/sysbuild.cmake
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
#
# Copyright (c) 2023 Nordic Semiconductor ASA
# 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()
if(SB_CONFIG_SOC_NRF54H20)
if(SB_CONFIG_REMOTE_GLOBAL_DOMAIN_CLOCK_FREQUENCY_SWITCHING)
set(REMOTE_SOURCE_DIR ${ZEPHYR_NRF_MODULE_DIR}/tests/benchmarks/multicore/common/remote_gdf_switching)
else()
set(REMOTE_SOURCE_DIR ${ZEPHYR_NRF_MODULE_DIR}/tests/benchmarks/power_consumption/common/remote_sleep_forever)
endif()

# Add remote project
ExternalZephyrProject_Add(
# Add remote project
ExternalZephyrProject_Add(
APPLICATION remote
SOURCE_DIR ${ZEPHYR_NRF_MODULE_DIR}/tests/benchmarks/power_consumption/common/remote_sleep_forever
BOARD ${SB_CONFIG_REMOTE_BOARD}
SOURCE_DIR ${REMOTE_SOURCE_DIR}
BOARD ${SB_CONFIG_BOARD}/${SB_CONFIG_SOC}/cpurad
BOARD_REVISION ${BOARD_REVISION}
)

# Add a dependency so that the remote image will be built and flashed first
add_dependencies(idle_uarte remote)
# Add dependency so that the remote image is flashed first.
sysbuild_add_dependencies(FLASH idle_uarte remote)
endif()
21 changes: 21 additions & 0 deletions tests/benchmarks/multicore/idle_uarte/testcase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,27 @@ tests:
pytest_root:
- "${CUSTOM_ROOT_TEST_DIR}/test_measure_power_consumption.py::test_measure_and_data_dump_power_consumption_gated_uarte"

benchmarks.multicore.idle_uarte.fast.nrf54h20dk_cpuapp_cpurad.s2ram.remote_gd_freq_switching:
tags:
- ci_build
- ci_tests_benchmarks_multicore
- uarte
- ppk_power_measure
filter: not CONFIG_COVERAGE
harness: pytest
platform_allow:
- nrf54h20dk/nrf54h20/cpuapp
integration_platforms:
- nrf54h20dk/nrf54h20/cpuapp
extra_args:
- DTC_OVERLAY_FILE="boards/nrf54h20dk_nrf54h20_cpuapp_fast.overlay"
- SB_CONFIG_REMOTE_GLOBAL_DOMAIN_CLOCK_FREQUENCY_SWITCHING=y
harness_config:
fixture: gpio_loopback
pytest_root:
- "${CUSTOM_ROOT_TEST_DIR}/test_measure_power_consumption.py::test_measure_and_data_dump_power_consumption_gated_uarte"


benchmarks.multicore.idle_uarte.fast.gd_freq_256MHz.nrf54h20dk_cpuapp_cpurad.s2ram:
tags:
- ci_build
Expand Down

0 comments on commit cd63074

Please sign in to comment.