Skip to content

Commit

Permalink
tests: benchmarks: Verify fast SPI with different GD frequencies
Browse files Browse the repository at this point in the history
Verify fast SPI with 256MHz, 128MHz and 64MHz
Global Domain frequencies.

Signed-off-by: Bartosz Miller <[email protected]>
(cherry picked from commit 9fbeaf3)
  • Loading branch information
nordic-bami authored and bjarki-andreasen committed Jan 8, 2025
1 parent 5459843 commit 4970484
Show file tree
Hide file tree
Showing 3 changed files with 145 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/benchmarks/multicore/idle_spim_loopback/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,29 @@ config TEST_SPI_RELEASE_BEFORE_SLEEP
first test iteration will see SPI CS signal activation. Next test iterations
will NOT observe changes on SPI CS signal.

choice GLOBAL_DOMAIN_CLOCK_FREQUENCY_OPTION
prompt "Global domain clock frequency"
default GLOBAL_DOMAIN_CLOCK_FREQUENCY_OPTION_320MHZ

config GLOBAL_DOMAIN_CLOCK_FREQUENCY_OPTION_320MHZ
bool "320MHz"

config GLOBAL_DOMAIN_CLOCK_FREQUENCY_OPTION_256MHZ
bool "256MHz"

config GLOBAL_DOMAIN_CLOCK_FREQUENCY_OPTION_128MHZ
bool "128MHz"

config GLOBAL_DOMAIN_CLOCK_FREQUENCY_OPTION_64MHZ
bool "64MHz"

endchoice

config GLOBAL_DOMAIN_CLOCK_FREQUENCY_MHZ
int
default 320 if GLOBAL_DOMAIN_CLOCK_FREQUENCY_OPTION_320MHZ
default 256 if GLOBAL_DOMAIN_CLOCK_FREQUENCY_OPTION_256MHZ
default 128 if GLOBAL_DOMAIN_CLOCK_FREQUENCY_OPTION_128MHZ
default 64 if GLOBAL_DOMAIN_CLOCK_FREQUENCY_OPTION_64MHZ

source "Kconfig.zephyr"
40 changes: 40 additions & 0 deletions tests/benchmarks/multicore/idle_spim_loopback/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ LOG_MODULE_REGISTER(idle_spim_loopback, LOG_LEVEL_INF);
#include <zephyr/drivers/spi.h>
#include <zephyr/linker/devicetree_regions.h>
#include <zephyr/pm/device_runtime.h>
#include <zephyr/devicetree/clocks.h>
#include <zephyr/drivers/clock_control/nrf_clock_control.h>

#define DELTA (1)

Expand Down Expand Up @@ -49,6 +51,38 @@ static volatile uint32_t high, low;
static struct k_timer my_timer;
static bool timer_expired;

#if defined(CONFIG_CLOCK_CONTROL)
const struct nrf_clock_spec clk_spec_global_hsfll = {
.frequency = MHZ(CONFIG_GLOBAL_DOMAIN_CLOCK_FREQUENCY_MHZ)
};

/*
* Set Global Domain frequency (HSFLL120)
* based on: CONFIG_GLOBAL_DOMAIN_CLOCK_FREQUENCY_MHZ
*/
void set_global_domain_frequency(void)
{
int err;
int res;
struct onoff_client cli;
const struct device *hsfll_dev = DEVICE_DT_GET(DT_NODELABEL(hsfll120));

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);
printk("Return code: %d\n", err);
__ASSERT_NO_MSG(err < 3);
__ASSERT_NO_MSG(err >= 0);
do {
err = sys_notify_fetch_result(&cli.notify, &res);
k_yield();
} while (err == -EAGAIN);
printk("Clock control request return value: %d\n", err);
printk("Clock control request response code: %d\n", res);
__ASSERT_NO_MSG(err == 0);
__ASSERT_NO_MSG(res == 0);
}
#endif /* CONFIG_CLOCK_CONTROL */

void my_timer_handler(struct k_timer *dummy)
{
Expand Down Expand Up @@ -97,6 +131,12 @@ int main(void)
.count = 1
};

#if defined(CONFIG_CLOCK_CONTROL)
k_msleep(1000);
set_global_domain_frequency();
k_msleep(100);
#endif

LOG_INF("Multicore idle_spi_loopback test on %s", CONFIG_BOARD_TARGET);
LOG_INF("Core will sleep for %u ms", CONFIG_TEST_SLEEP_DURATION_MS);
LOG_INF("Testing SPIM device %s", spim_spec.bus->name);
Expand Down
81 changes: 81 additions & 0 deletions tests/benchmarks/multicore/idle_spim_loopback/testcase.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,45 @@ tests:
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.gd_freq_256MHz.s2ram_fast:
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"
- CONFIG_CLOCK_CONTROL=y
- CONFIG_GLOBAL_DOMAIN_CLOCK_FREQUENCY_OPTION_256MHZ=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_spim_loopback.4_bytes.gd_freq_128MHz.s2ram_fast:
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"
- CONFIG_CLOCK_CONTROL=y
- CONFIG_GLOBAL_DOMAIN_CLOCK_FREQUENCY_OPTION_128MHZ=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_spim_loopback.4_bytes.gd_freq_64MHz.s2ram_fast:
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"
- CONFIG_CLOCK_CONTROL=y
- CONFIG_GLOBAL_DOMAIN_CLOCK_FREQUENCY_OPTION_64MHZ=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"

#
# 16 Bytes of data
#
Expand Down Expand Up @@ -163,6 +202,48 @@ tests:
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.gd_freq_256MHz.s2ram_fast:
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
- CONFIG_CLOCK_CONTROL=y
- CONFIG_GLOBAL_DOMAIN_CLOCK_FREQUENCY_OPTION_256MHZ=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_spim_loopback.16_bytes.gd_freq_128MHz.s2ram_fast:
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
- CONFIG_CLOCK_CONTROL=y
- CONFIG_GLOBAL_DOMAIN_CLOCK_FREQUENCY_OPTION_128MHZ=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_spim_loopback.16_bytes.gd_freq_64MHz.s2ram_fast:
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
- CONFIG_CLOCK_CONTROL=y
- CONFIG_GLOBAL_DOMAIN_CLOCK_FREQUENCY_OPTION_64MHZ=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"

#
# 4 Bytes of data with SPI Chip Select Lock enabled
#
Expand Down

0 comments on commit 4970484

Please sign in to comment.