Skip to content

Commit ac6b882

Browse files
nordic-bamirlubos
authored andcommitted
tests: benchmarks: Add test for s2ram with uart automatic usage
Test UARTE driver power management without manual enable/disable Signed-off-by: Bartosz Miller <[email protected]> (cherry picked from commit d318939)
1 parent a8bdf26 commit ac6b882

File tree

4 files changed

+63
-9
lines changed

4 files changed

+63
-9
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
source "Kconfig.zephyr"
2+
3+
config TEST_AUTOMATIC_POWER_CONTROL
4+
default n
5+
bool "Enable testing without manual UART disable/enable"

tests/benchmarks/multicore/idle_uarte/prj.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ CONFIG_POWEROFF=y
1212

1313
CONFIG_BOOT_BANNER=n
1414
CONFIG_NRFS_MRAM_SERVICE_ENABLED=n
15+
CONFIG_ASSERT=y
1516

1617
# Enable for debugging purposes only
1718
CONFIG_PRINTK=n

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

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ static void async_uart_callback(const struct device *dev, struct uart_event *evt
4646
break;
4747
case UART_TX_ABORTED:
4848
printk("UART_TX_ABORTED\n");
49+
printk("Callback should not enter here\n");
50+
__ASSERT_NO_MSG(1 == 0);
4951
break;
5052
case UART_RX_RDY:
5153
printk("UART_RX_RDY\n");
@@ -74,6 +76,33 @@ static void async_uart_callback(const struct device *dev, struct uart_event *evt
7476
}
7577
}
7678

79+
/* Helper function for enabling UART RX */
80+
void enable_uart_rx(void)
81+
{
82+
int err;
83+
84+
printk("Enable UART RX\n");
85+
err = uart_rx_enable(uart_dev, test_buffer, TEST_BUFFER_LEN,
86+
5 * UART_ACTION_BASE_TIMEOUT_US);
87+
if (err != 0) {
88+
printk("Unexpected error when enabling UART RX: %d\n", err);
89+
}
90+
}
91+
92+
/* Helper function for disabling UART RX */
93+
void disable_uart_rx(void)
94+
{
95+
int err;
96+
97+
k_msleep(250);
98+
printk("Disable UART RX\n");
99+
err = uart_rx_disable(uart_dev);
100+
if (err != 0) {
101+
printk("Unexpected error when disabling RX: %d\n", err);
102+
}
103+
k_msleep(250);
104+
}
105+
77106
int main(void)
78107
{
79108
int err;
@@ -112,23 +141,27 @@ int main(void)
112141
pm_device_runtime_enable(console_dev);
113142
}
114143

144+
#if defined(CONFIG_TEST_AUTOMATIC_POWER_CONTROL)
145+
enable_uart_rx();
146+
#endif
147+
115148
while (1) {
116149
printk("Hello\n");
117150

118-
err = uart_rx_enable(uart_dev, test_buffer, TEST_BUFFER_LEN,
119-
5 * UART_ACTION_BASE_TIMEOUT_US);
120-
if (err != 0) {
121-
printk("Unexpected error when enabling UART RX: %d\n", err);
122-
return -1;
123-
}
151+
#if !defined(CONFIG_TEST_AUTOMATIC_POWER_CONTROL)
152+
enable_uart_rx();
153+
#endif
154+
155+
printk("UART test transmission\n");
124156
err = uart_tx(uart_dev, test_pattern, TEST_BUFFER_LEN, UART_ACTION_BASE_TIMEOUT_US);
125157
if (err != 0) {
126158
printk("Unexpected error when sending UART TX data: %d\n", err);
127159
return -1;
128160
}
129-
k_msleep(250);
130-
uart_rx_disable(uart_dev);
131-
k_msleep(250);
161+
162+
#if !defined(CONFIG_TEST_AUTOMATIC_POWER_CONTROL)
163+
disable_uart_rx();
164+
#endif
132165

133166
printk("Good night\n");
134167
k_msleep(2000);

tests/benchmarks/multicore/idle_uarte/testcase.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,18 @@ tests:
3131
fixture: gpio_loopback
3232
pytest_root:
3333
- "${CUSTOM_ROOT_TEST_DIR}/test_measure_power_consumption.py::test_measure_and_data_dump_power_consumption_uarte"
34+
35+
benchmarks.multicore.idle_uarte.automatic_pm.nrf54h20dk_cpuapp_cpurad.s2ram:
36+
harness: pytest
37+
platform_allow:
38+
- nrf54h20dk/nrf54h20/cpuapp
39+
integration_platforms:
40+
- nrf54h20dk/nrf54h20/cpuapp
41+
extra_args:
42+
- SB_CONF_FILE=sysbuild/nrf54h20dk_nrf54h20_cpurad.conf
43+
- DTC_OVERLAY_FILE="boards/nrf54h20dk_nrf54h20_cpuapp_normal.overlay"
44+
- CONFIG_TEST_AUTOMATIC_POWER_CONTROL=y
45+
harness_config:
46+
fixture: gpio_loopback
47+
pytest_root:
48+
- "${CUSTOM_ROOT_TEST_DIR}/test_measure_power_consumption.py::test_measure_and_data_dump_power_consumption_uarte"

0 commit comments

Comments
 (0)