Skip to content

Commit 9fbeaf3

Browse files
nordic-bamirlubos
authored andcommitted
tests: benchmarks: Verify fast SPI with different GD frequencies
Verify fast SPI with 256MHz, 128MHz and 64MHz Global Domain frequencies. Signed-off-by: Bartosz Miller <[email protected]>
1 parent 52c415c commit 9fbeaf3

File tree

3 files changed

+145
-0
lines changed

3 files changed

+145
-0
lines changed

tests/benchmarks/multicore/idle_spim_loopback/Kconfig

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,29 @@ config TEST_SPI_RELEASE_BEFORE_SLEEP
4545
first test iteration will see SPI CS signal activation. Next test iterations
4646
will NOT observe changes on SPI CS signal.
4747

48+
choice GLOBAL_DOMAIN_CLOCK_FREQUENCY_OPTION
49+
prompt "Global domain clock frequency"
50+
default GLOBAL_DOMAIN_CLOCK_FREQUENCY_OPTION_320MHZ
51+
52+
config GLOBAL_DOMAIN_CLOCK_FREQUENCY_OPTION_320MHZ
53+
bool "320MHz"
54+
55+
config GLOBAL_DOMAIN_CLOCK_FREQUENCY_OPTION_256MHZ
56+
bool "256MHz"
57+
58+
config GLOBAL_DOMAIN_CLOCK_FREQUENCY_OPTION_128MHZ
59+
bool "128MHz"
60+
61+
config GLOBAL_DOMAIN_CLOCK_FREQUENCY_OPTION_64MHZ
62+
bool "64MHz"
63+
64+
endchoice
65+
66+
config GLOBAL_DOMAIN_CLOCK_FREQUENCY_MHZ
67+
int
68+
default 320 if GLOBAL_DOMAIN_CLOCK_FREQUENCY_OPTION_320MHZ
69+
default 256 if GLOBAL_DOMAIN_CLOCK_FREQUENCY_OPTION_256MHZ
70+
default 128 if GLOBAL_DOMAIN_CLOCK_FREQUENCY_OPTION_128MHZ
71+
default 64 if GLOBAL_DOMAIN_CLOCK_FREQUENCY_OPTION_64MHZ
4872

4973
source "Kconfig.zephyr"

tests/benchmarks/multicore/idle_spim_loopback/src/main.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ LOG_MODULE_REGISTER(idle_spim_loopback, LOG_LEVEL_INF);
1212
#include <zephyr/drivers/spi.h>
1313
#include <zephyr/linker/devicetree_regions.h>
1414
#include <zephyr/pm/device_runtime.h>
15+
#include <zephyr/devicetree/clocks.h>
16+
#include <zephyr/drivers/clock_control/nrf_clock_control.h>
1517

1618
#define DELTA (1)
1719

@@ -49,6 +51,38 @@ static volatile uint32_t high, low;
4951
static struct k_timer my_timer;
5052
static bool timer_expired;
5153

54+
#if defined(CONFIG_CLOCK_CONTROL)
55+
const struct nrf_clock_spec clk_spec_global_hsfll = {
56+
.frequency = MHZ(CONFIG_GLOBAL_DOMAIN_CLOCK_FREQUENCY_MHZ)
57+
};
58+
59+
/*
60+
* Set Global Domain frequency (HSFLL120)
61+
* based on: CONFIG_GLOBAL_DOMAIN_CLOCK_FREQUENCY_MHZ
62+
*/
63+
void set_global_domain_frequency(void)
64+
{
65+
int err;
66+
int res;
67+
struct onoff_client cli;
68+
const struct device *hsfll_dev = DEVICE_DT_GET(DT_NODELABEL(hsfll120));
69+
70+
printk("Requested frequency [Hz]: %d\n", clk_spec_global_hsfll.frequency);
71+
sys_notify_init_spinwait(&cli.notify);
72+
err = nrf_clock_control_request(hsfll_dev, &clk_spec_global_hsfll, &cli);
73+
printk("Return code: %d\n", err);
74+
__ASSERT_NO_MSG(err < 3);
75+
__ASSERT_NO_MSG(err >= 0);
76+
do {
77+
err = sys_notify_fetch_result(&cli.notify, &res);
78+
k_yield();
79+
} while (err == -EAGAIN);
80+
printk("Clock control request return value: %d\n", err);
81+
printk("Clock control request response code: %d\n", res);
82+
__ASSERT_NO_MSG(err == 0);
83+
__ASSERT_NO_MSG(res == 0);
84+
}
85+
#endif /* CONFIG_CLOCK_CONTROL */
5286

5387
void my_timer_handler(struct k_timer *dummy)
5488
{
@@ -97,6 +131,12 @@ int main(void)
97131
.count = 1
98132
};
99133

134+
#if defined(CONFIG_CLOCK_CONTROL)
135+
k_msleep(1000);
136+
set_global_domain_frequency();
137+
k_msleep(100);
138+
#endif
139+
100140
LOG_INF("Multicore idle_spi_loopback test on %s", CONFIG_BOARD_TARGET);
101141
LOG_INF("Core will sleep for %u ms", CONFIG_TEST_SLEEP_DURATION_MS);
102142
LOG_INF("Testing SPIM device %s", spim_spec.bus->name);

tests/benchmarks/multicore/idle_spim_loopback/testcase.yaml

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,45 @@ tests:
8282
pytest_root:
8383
- "${CUSTOM_ROOT_TEST_DIR}/test_measure_power_consumption.py::test_measure_and_data_dump_pwm_and_s2ram"
8484

85+
benchmarks.multicore.idle_spim_loopback.4_bytes.gd_freq_256MHz.s2ram_fast:
86+
tags: ppk_power_measure
87+
extra_args:
88+
- idle_spim_loopback_CONF_FILE=prj_s2ram.conf
89+
- idle_spim_loopback_DTC_OVERLAY_FILE="boards/nrf54h20dk_nrf54h20_cpuapp_fast.overlay"
90+
- CONFIG_CLOCK_CONTROL=y
91+
- CONFIG_GLOBAL_DOMAIN_CLOCK_FREQUENCY_OPTION_256MHZ=y
92+
harness: pytest
93+
harness_config:
94+
fixture: spi_loopback
95+
pytest_root:
96+
- "${CUSTOM_ROOT_TEST_DIR}/test_measure_power_consumption.py::test_measure_and_data_dump_pwm_and_s2ram"
97+
98+
benchmarks.multicore.idle_spim_loopback.4_bytes.gd_freq_128MHz.s2ram_fast:
99+
tags: ppk_power_measure
100+
extra_args:
101+
- idle_spim_loopback_CONF_FILE=prj_s2ram.conf
102+
- idle_spim_loopback_DTC_OVERLAY_FILE="boards/nrf54h20dk_nrf54h20_cpuapp_fast.overlay"
103+
- CONFIG_CLOCK_CONTROL=y
104+
- CONFIG_GLOBAL_DOMAIN_CLOCK_FREQUENCY_OPTION_128MHZ=y
105+
harness: pytest
106+
harness_config:
107+
fixture: spi_loopback
108+
pytest_root:
109+
- "${CUSTOM_ROOT_TEST_DIR}/test_measure_power_consumption.py::test_measure_and_data_dump_pwm_and_s2ram"
110+
111+
benchmarks.multicore.idle_spim_loopback.4_bytes.gd_freq_64MHz.s2ram_fast:
112+
tags: ppk_power_measure
113+
extra_args:
114+
- idle_spim_loopback_CONF_FILE=prj_s2ram.conf
115+
- idle_spim_loopback_DTC_OVERLAY_FILE="boards/nrf54h20dk_nrf54h20_cpuapp_fast.overlay"
116+
- CONFIG_CLOCK_CONTROL=y
117+
- CONFIG_GLOBAL_DOMAIN_CLOCK_FREQUENCY_OPTION_64MHZ=y
118+
harness: pytest
119+
harness_config:
120+
fixture: spi_loopback
121+
pytest_root:
122+
- "${CUSTOM_ROOT_TEST_DIR}/test_measure_power_consumption.py::test_measure_and_data_dump_pwm_and_s2ram"
123+
85124
#
86125
# 16 Bytes of data
87126
#
@@ -163,6 +202,48 @@ tests:
163202
pytest_root:
164203
- "${CUSTOM_ROOT_TEST_DIR}/test_measure_power_consumption.py::test_measure_and_data_dump_pwm_and_s2ram"
165204

205+
benchmarks.multicore.idle_spim_loopback.16_bytes.gd_freq_256MHz.s2ram_fast:
206+
tags: ppk_power_measure
207+
extra_args:
208+
- idle_spim_loopback_CONF_FILE=prj_s2ram.conf
209+
- idle_spim_loopback_DTC_OVERLAY_FILE="boards/nrf54h20dk_nrf54h20_cpuapp_fast.overlay"
210+
- idle_spim_loopback_CONFIG_DATA_FIELD=16
211+
- CONFIG_CLOCK_CONTROL=y
212+
- CONFIG_GLOBAL_DOMAIN_CLOCK_FREQUENCY_OPTION_256MHZ=y
213+
harness: pytest
214+
harness_config:
215+
fixture: spi_loopback
216+
pytest_root:
217+
- "${CUSTOM_ROOT_TEST_DIR}/test_measure_power_consumption.py::test_measure_and_data_dump_pwm_and_s2ram"
218+
219+
benchmarks.multicore.idle_spim_loopback.16_bytes.gd_freq_128MHz.s2ram_fast:
220+
tags: ppk_power_measure
221+
extra_args:
222+
- idle_spim_loopback_CONF_FILE=prj_s2ram.conf
223+
- idle_spim_loopback_DTC_OVERLAY_FILE="boards/nrf54h20dk_nrf54h20_cpuapp_fast.overlay"
224+
- idle_spim_loopback_CONFIG_DATA_FIELD=16
225+
- CONFIG_CLOCK_CONTROL=y
226+
- CONFIG_GLOBAL_DOMAIN_CLOCK_FREQUENCY_OPTION_128MHZ=y
227+
harness: pytest
228+
harness_config:
229+
fixture: spi_loopback
230+
pytest_root:
231+
- "${CUSTOM_ROOT_TEST_DIR}/test_measure_power_consumption.py::test_measure_and_data_dump_pwm_and_s2ram"
232+
233+
benchmarks.multicore.idle_spim_loopback.16_bytes.gd_freq_64MHz.s2ram_fast:
234+
tags: ppk_power_measure
235+
extra_args:
236+
- idle_spim_loopback_CONF_FILE=prj_s2ram.conf
237+
- idle_spim_loopback_DTC_OVERLAY_FILE="boards/nrf54h20dk_nrf54h20_cpuapp_fast.overlay"
238+
- idle_spim_loopback_CONFIG_DATA_FIELD=16
239+
- CONFIG_CLOCK_CONTROL=y
240+
- CONFIG_GLOBAL_DOMAIN_CLOCK_FREQUENCY_OPTION_64MHZ=y
241+
harness: pytest
242+
harness_config:
243+
fixture: spi_loopback
244+
pytest_root:
245+
- "${CUSTOM_ROOT_TEST_DIR}/test_measure_power_consumption.py::test_measure_and_data_dump_pwm_and_s2ram"
246+
166247
#
167248
# 4 Bytes of data with SPI Chip Select Lock enabled
168249
#

0 commit comments

Comments
 (0)