Skip to content

Commit 21f7e5f

Browse files
gbarkadiuszkartben
authored andcommitted
tests: power_residency_time: Tests the residency time of each power state
This test evaluates the residency time of different power states on the stm32l562e_dk board and calculates the RMS (Root Mean Square) current for every detected state. Signed-off-by: Arkadiusz Cholewinski <arkadiuszx.cholewinski@intel.com>
1 parent 513eb43 commit 21f7e5f

File tree

5 files changed

+131
-0
lines changed

5 files changed

+131
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Copyright (c) 2025 Intel Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
cmake_minimum_required(VERSION 3.20.0)
5+
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
6+
project(power_residency_time)
7+
8+
FILE(GLOB app_sources src/*.c)
9+
target_sources(app PRIVATE ${app_sources})
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
/*
2+
* Copyright (c) 2025 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
&stop0{
8+
compatible = "zephyr,power-state";
9+
power-state-name = "suspend-to-idle";
10+
substate-id = <1>;
11+
min-residency-us = <500000>;
12+
};
13+
&stop1{
14+
compatible = "zephyr,power-state";
15+
power-state-name = "suspend-to-idle";
16+
substate-id = <2>;
17+
min-residency-us = <1000000>;
18+
};
19+
&stop2{
20+
compatible = "zephyr,power-state";
21+
power-state-name = "suspend-to-idle";
22+
substate-id = <3>;
23+
min-residency-us = <1500000>;
24+
};
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Copyright (c) 2025 Intel Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
CONFIG_PM=y
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright (c) 2025 Intel Corporation
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <zephyr/kernel.h>
8+
#include <zephyr/devicetree.h>
9+
10+
#define DIFF_RESIDENCY_TIME_STATE_0 600
11+
#define DIFF_RESIDENCY_TIME_STATE_1 600
12+
#define DIFF_RESIDENCY_TIME_STATE_2 600
13+
14+
int main(void)
15+
{
16+
17+
int stop0_min_residency_time = DT_PROP(DT_NODELABEL(stop0), min_residency_us);
18+
int stop1_min_residency_time = DT_PROP(DT_NODELABEL(stop1), min_residency_us);
19+
int stop2_min_residency_time = DT_PROP(DT_NODELABEL(stop2), min_residency_us);
20+
21+
while (1) {
22+
printk("\nSleep time < min_residency_time of state 0\n");
23+
k_usleep(stop0_min_residency_time - DIFF_RESIDENCY_TIME_STATE_0);
24+
printk("\nSleep time = min_residency_time of state 0\n");
25+
k_usleep(stop0_min_residency_time);
26+
printk("\nSleep time < min_residency_time of state 1\n");
27+
k_usleep(stop1_min_residency_time - DIFF_RESIDENCY_TIME_STATE_1);
28+
printk("\nSleep time = min_residency_time of state 1\n");
29+
k_usleep(stop1_min_residency_time);
30+
printk("\nSleep time < min_residency_time of state 2\n");
31+
k_usleep(stop2_min_residency_time - DIFF_RESIDENCY_TIME_STATE_2);
32+
printk("\nSleep time = min_residency_time of state 2\n");
33+
k_usleep(stop2_min_residency_time);
34+
printk("\nWakeup.\n");
35+
36+
/**
37+
* Keeping alive loop
38+
*/
39+
while (1) {
40+
arch_nop();
41+
}
42+
}
43+
return 0;
44+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Copyright (c) 2025 Intel Corporation
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
common:
5+
harness: power
6+
harness_config:
7+
fixture: pm_probe
8+
pytest_dut_scope: session
9+
power_measurements:
10+
elements_to_trim: 100
11+
min_peak_distance: 40
12+
min_peak_height: 0.008
13+
peak_padding: 40
14+
measurement_duration: 8
15+
num_of_transitions: 6
16+
expected_rms_values: [56.0, 4.0, 4.0, 1.4, 1.4, 0.26, 91]
17+
tolerance_percentage: 10
18+
19+
tests:
20+
pm.power_residency_time:
21+
platform_allow:
22+
- stm32l562e_dk
23+
tags:
24+
- pm
25+
26+
pm.power_residency_time.pm_device:
27+
platform_allow:
28+
- stm32l562e_dk
29+
tags:
30+
- pm
31+
extra_args:
32+
- CONFIG_PM_DEVICE=y
33+
34+
pm.power_residency_time.pm_device_runtime:
35+
platform_allow:
36+
- stm32l562e_dk
37+
tags:
38+
- pm
39+
extra_args:
40+
- CONFIG_PM_DEVICE=y
41+
- CONFIG_PM_DEVICE_RUNTIME=y
42+
43+
pm.power_residency_time.pm_device_system_managed:
44+
platform_allow:
45+
- stm32l562e_dk
46+
tags:
47+
- pm
48+
extra_args:
49+
- CONFIG_PM_DEVICE=y
50+
- CONFIG_PM_DEVICE_SYSTEM_MANAGED=y

0 commit comments

Comments
 (0)