-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: benchmarks: Add TWIM suspend test with current measurement
Call the suspend/resume manually and measure the current consumption. Signed-off-by: Bartosz Miller <[email protected]>
- Loading branch information
1 parent
2e8ae9b
commit 23e242d
Showing
11 changed files
with
236 additions
and
0 deletions.
There are no files selected for viewing
13 changes: 13 additions & 0 deletions
13
tests/benchmarks/current_consumption/twim_suspend/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# | ||
# 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(twim_suspend) | ||
|
||
target_sources(app PRIVATE src/main.c) |
11 changes: 11 additions & 0 deletions
11
tests/benchmarks/current_consumption/twim_suspend/Kconfig.sysbuild
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# | ||
# 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 |
8 changes: 8 additions & 0 deletions
8
.../benchmarks/current_consumption/twim_suspend/boards/nrf54h20dk_nrf54h20_cpuapp_pm.overlay
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* | ||
* Copyright (C) 2025 Nordic Semiconductor ASA | ||
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
*/ | ||
|
||
&i2c130 { | ||
/delete-property/ zephyr,pm-device-runtime-auto; | ||
}; |
8 changes: 8 additions & 0 deletions
8
.../benchmarks/current_consumption/twim_suspend/boards/nrf54l15dk_nrf54l15_cpuapp_pm.overlay
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* | ||
* Copyright (C) 2025 Nordic Semiconductor ASA | ||
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
*/ | ||
|
||
&i2c22 { | ||
/delete-property/ zephyr,pm-device-runtime-auto; | ||
}; |
18 changes: 18 additions & 0 deletions
18
tests/benchmarks/current_consumption/twim_suspend/prj.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
CONFIG_I2C=y | ||
|
||
CONFIG_PM=y | ||
CONFIG_PM_DEVICE=y | ||
CONFIG_PM_DEVICE_RUNTIME=y | ||
CONFIG_POWEROFF=y | ||
|
||
CONFIG_GPIO=n | ||
CONFIG_BOOT_BANNER=n | ||
|
||
CONFIG_ASSERT=y | ||
|
||
# Enable for debugging purposes only | ||
CONFIG_PRINTK=n | ||
CONFIG_LOG=n | ||
CONFIG_CONSOLE=n | ||
CONFIG_UART_CONSOLE=n | ||
CONFIG_SERIAL=n |
12 changes: 12 additions & 0 deletions
12
tests/benchmarks/current_consumption/twim_suspend/remote/CMakeLists.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# | ||
# Copyright (c) 2024 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) | ||
|
||
target_sources(app PRIVATE src/main.c) |
7 changes: 7 additions & 0 deletions
7
tests/benchmarks/current_consumption/twim_suspend/remote/prj.conf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
CONFIG_PM=y | ||
CONFIG_POWEROFF=y | ||
CONFIG_CONSOLE=n | ||
CONFIG_UART_CONSOLE=n | ||
CONFIG_SERIAL=n | ||
CONFIG_GPIO=n | ||
CONFIG_BOOT_BANNER=n |
14 changes: 14 additions & 0 deletions
14
tests/benchmarks/current_consumption/twim_suspend/remote/src/main.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* Copyright (c) 2024 Nordic Semiconductor ASA | ||
* | ||
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
*/ | ||
|
||
#include <zephyr/kernel.h> | ||
|
||
int main(void) | ||
{ | ||
k_sleep(K_FOREVER); | ||
|
||
return 0; | ||
} |
82 changes: 82 additions & 0 deletions
82
tests/benchmarks/current_consumption/twim_suspend/src/main.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* Copyright (c) 2025 Nordic Semiconductor ASA | ||
* | ||
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
*/ | ||
|
||
#include <zephyr/kernel.h> | ||
#include <zephyr/logging/log.h> | ||
#include <zephyr/drivers/i2c.h> | ||
#include <zephyr/pm/device.h> | ||
|
||
/* Note: logging is normally disabled for this test | ||
* Enable only for debugging purposes | ||
*/ | ||
LOG_MODULE_REGISTER(twim_suspend); | ||
|
||
#define SENSOR_NODE DT_COMPAT_GET_ANY_STATUS_OKAY(bosch_bme680) | ||
#define I2C_TEST_NODE DT_PARENT(SENSOR_NODE) | ||
#define DEVICE_ADDRESS (uint8_t) DT_REG_ADDR(SENSOR_NODE) | ||
|
||
#define CHIP_ID_REGISTER_ADDRESS 0xD0 | ||
#define VARIANT_ID_REGISTER_ADDRESS 0xF0 | ||
|
||
static const struct device *const i2c_device = DEVICE_DT_GET(I2C_TEST_NODE); | ||
|
||
/* | ||
* Helper method for reading the BME688 I2C registers | ||
*/ | ||
static uint8_t read_sensor_register(uint8_t register_address) | ||
{ | ||
int rc; | ||
uint8_t response; | ||
|
||
rc = i2c_reg_read_byte(i2c_device, DEVICE_ADDRESS, register_address, &response); | ||
printk("i2c_reg_read_byte ret: %d\n", rc); | ||
__ASSERT_NO_MSG(rc == 0); | ||
printk("I2C read reg, addr: 0x%x, val: 0x%x\n", register_address, response); | ||
return response; | ||
} | ||
|
||
int main(void) | ||
{ | ||
uint8_t response; | ||
uint32_t i2c_config = I2C_SPEED_SET(I2C_SPEED_STANDARD) | I2C_MODE_CONTROLLER; | ||
|
||
printk("Device address 0x%x\n", DEVICE_ADDRESS); | ||
printk("I2C speed setting: %d\n", I2C_SPEED_STANDARD); | ||
|
||
response = i2c_configure(i2c_device, i2c_config); | ||
if (response != 0) { | ||
printk("I2C configuration failed%d\n", response); | ||
__ASSERT_NO_MSG(response == 0); | ||
} | ||
|
||
response = pm_device_action_run(i2c_device, PM_DEVICE_ACTION_SUSPEND); | ||
printk("PM_DEVICE_ACTION_SUSPEND status: %d\n", response); | ||
__ASSERT_NO_MSG(response == 0); | ||
|
||
while (1) { | ||
response = pm_device_action_run(i2c_device, PM_DEVICE_ACTION_RESUME); | ||
printk("PM_DEVICE_ACTION_RESUME status: %d\n", response); | ||
__ASSERT_NO_MSG(response == 0); | ||
|
||
response = read_sensor_register(CHIP_ID_REGISTER_ADDRESS); | ||
printk("Chip_Id: %d\n", response); | ||
__ASSERT_NO_MSG(response != 0); | ||
|
||
response = read_sensor_register(VARIANT_ID_REGISTER_ADDRESS); | ||
printk("Variant_Id: %d\n", response); | ||
__ASSERT_NO_MSG(response != 0); | ||
|
||
response = pm_device_action_run(i2c_device, PM_DEVICE_ACTION_SUSPEND); | ||
printk("PM_DEVICE_ACTION_SUSPEND status: %d\n", response); | ||
__ASSERT_NO_MSG(response == 0); | ||
|
||
printk("Good night\n"); | ||
k_msleep(1000); | ||
printk("Good morning\n"); | ||
} | ||
|
||
return 0; | ||
} |
19 changes: 19 additions & 0 deletions
19
tests/benchmarks/current_consumption/twim_suspend/sysbuild.cmake
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
# | ||
# Copyright (c) 2025 Nordic Semiconductor ASA | ||
# | ||
# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause | ||
# | ||
|
||
if(SB_CONFIG_SOC_NRF54H20) | ||
# Add remote project | ||
ExternalZephyrProject_Add( | ||
APPLICATION remote | ||
SOURCE_DIR ${APP_DIR}/remote | ||
BOARD ${SB_CONFIG_REMOTE_BOARD} | ||
BOARD_REVISION ${BOARD_REVISION} | ||
) | ||
# Add a dependency so that the remote image will be built and flashed first | ||
add_dependencies(twim_suspend remote) | ||
# Add dependency so that the remote image is flashed first. | ||
sysbuild_add_dependencies(FLASH twim_suspend remote) | ||
endif() |
44 changes: 44 additions & 0 deletions
44
tests/benchmarks/current_consumption/twim_suspend/testcase.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
common: | ||
sysbuild: true | ||
depends_on: i2c | ||
|
||
tests: | ||
benchmarks.current_consumption.twim_suspend.nrf54h: | ||
tags: | ||
- ci_build | ||
- ci_tests_benchmarks_multicore | ||
- twim | ||
- ppk_power_measure | ||
platform_allow: | ||
- nrf54h20dk/nrf54h20/cpuapp | ||
integration_platforms: | ||
- nrf54h20dk/nrf54h20/cpuapp | ||
extra_args: | ||
- SHIELD=pca63566 | ||
- EXTRA_DTC_OVERLAY_FILE=boards/nrf54h20dk_nrf54h20_cpuapp_pm.overlay | ||
- CONFIG_PM_S2RAM=y | ||
- CONFIG_PM_S2RAM_CUSTOM_MARKING=y | ||
harness: pytest | ||
harness_config: | ||
fixture: pca63566 | ||
pytest_root: | ||
- "${CUSTOM_ROOT_TEST_DIR}/test_measure_power_consumption.py::test_measure_and_data_dump_power_consumption_twim" | ||
|
||
benchmarks.current_consumption.twim_suspend.nrf54l: | ||
tags: | ||
- ci_build | ||
- ci_tests_benchmarks_multicore | ||
- twim | ||
- ppk_power_measure | ||
platform_allow: | ||
- nrf54l15dk/nrf54l15/cpuapp | ||
integration_platforms: | ||
- nrf54l15dk/nrf54l15/cpuapp | ||
extra_args: | ||
- SHIELD=pca63565 | ||
- EXTRA_DTC_OVERLAY_FILE=boards/nrf54l15dk_nrf54l15_cpuapp_pm.overlay | ||
harness: pytest | ||
harness_config: | ||
fixture: pca63565 | ||
pytest_root: | ||
- "${CUSTOM_ROOT_TEST_DIR}/test_measure_power_consumption.py::test_measure_and_data_dump_power_consumption_twim" |