Skip to content

Commit 9c55695

Browse files
nordic-baminordic-piks
authored andcommitted
tests: benchmarks: Add PM test for console UART
Test verifies device sleep current with console UART. It uses string lenght of 33 characters due to nrf52840 specific issue. Signed-off-by: Bartosz Miller <[email protected]>
1 parent 5ff2331 commit 9c55695

File tree

6 files changed

+121
-0
lines changed

6 files changed

+121
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#
2+
# Copyright (c) 2025 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
cmake_minimum_required(VERSION 3.20.0)
8+
9+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
10+
11+
project(uart_console)
12+
13+
target_sources(app PRIVATE src/main.c)
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/*
2+
* Copyright (c) 2025 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
/ {
8+
aliases {
9+
led = &led0;
10+
/delete-property/ led1;
11+
};
12+
};
13+
14+
/delete-node/ &led1;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
CONFIG_PM=y
2+
CONFIG_PM_DEVICE=y
3+
CONFIG_PM_DEVICE_RUNTIME=y
4+
CONFIG_POWEROFF=y
5+
6+
# For nrf54h only, will be ingored for other platforms
7+
CONFIG_PM_S2RAM=y
8+
CONFIG_PM_S2RAM_CUSTOM_MARKING=y
9+
10+
CONFIG_SERIAL=y
11+
CONFIG_LOG=y
12+
CONFIG_LOG_BACKEND_UART_ASYNC=y
13+
CONFIG_UART_ASYNC_API=y
14+
CONFIG_LOG_MODE_DEFERRED=y
15+
CONFIG_LOG_PRINTK=y
16+
CONFIG_PRINTK=y
17+
CONFIG_CONSOLE=y
18+
CONFIG_UART_CONSOLE=y
19+
CONFIG_LOG_BACKEND_UART=y
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright (c) 2025 Nordic Semiconductor ASA
3+
*
4+
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
*/
6+
7+
#include <zephyr/kernel.h>
8+
#include <zephyr/logging/log.h>
9+
#include <zephyr/pm/device_runtime.h>
10+
11+
#define SLEEP_TIME_MS 1000
12+
13+
static const struct device *const console_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_console));
14+
15+
int main(void)
16+
{
17+
18+
#if defined(CONFIG_SOC_NRF52840)
19+
/* [246] System: Intermittent extra current consumption when going to sleep */
20+
*(volatile uint32_t *)0x4007AC84ul = 0x00000002ul;
21+
#endif
22+
23+
pm_device_runtime_enable(console_dev);
24+
25+
while (1) {
26+
printk("33 characters long string !!!!!!\n");
27+
k_sleep(K_MSEC(SLEEP_TIME_MS));
28+
}
29+
30+
return 0;
31+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#
2+
# Copyright (c) 2025 Nordic Semiconductor ASA
3+
#
4+
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5+
#
6+
7+
if(SB_CONFIG_SOC_NRF54H20)
8+
# Add remote project
9+
ExternalZephyrProject_Add(
10+
APPLICATION remote
11+
SOURCE_DIR ${ZEPHYR_NRF_MODULE_DIR}/tests/benchmarks/power_consumption/common/remote_sleep_forever
12+
BOARD ${SB_CONFIG_BOARD}/${SB_CONFIG_SOC}/cpurad
13+
BOARD_REVISION ${BOARD_REVISION}
14+
)
15+
# Add a dependency so that the remote image will be built and flashed first
16+
add_dependencies(uart_console remote)
17+
# Add dependency so that the remote image is flashed first.
18+
sysbuild_add_dependencies(FLASH uart_console remote)
19+
endif()
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
common:
2+
sysbuild: true
3+
4+
tests:
5+
benchmarks.current_consumption.uart_console:
6+
tags:
7+
- ci_build
8+
- ci_tests_benchmarks_multicore
9+
- uart
10+
- ppk_power_measure
11+
platform_allow:
12+
- nrf52840dk/nrf52840
13+
- nrf5340dk/nrf5340/cpuapp
14+
- nrf54l15dk/nrf54l15/cpuapp
15+
- nrf54h20dk/nrf54h20/cpuapp
16+
integration_platforms:
17+
- nrf52840dk/nrf52840
18+
- nrf5340dk/nrf5340/cpuapp
19+
- nrf54l15dk/nrf54l15/cpuapp
20+
- nrf54h20dk/nrf54h20/cpuapp
21+
harness: pytest
22+
harness_config:
23+
fixture: ppk_power_measure
24+
pytest_root:
25+
- "${CUSTOM_ROOT_TEST_DIR}/test_measure_power_consumption.py::test_measure_and_data_dump_power_consumption_uarte"

0 commit comments

Comments
 (0)