Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests: pm: Adding tests based on new approach to PM testing. #80692

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

gbarkadiusz
Copy link
Collaborator

@gbarkadiusz gbarkadiusz commented Oct 31, 2024

  • Introduces two scripts abstract_power_monitor.py and pwsh_stm32l562.py.

  • Adds three new power management pytests based on a new approach.

SETUP

image
image

TESTS

pm.states: Verifies the transition to all available power states on stm32l562e_dk.

During the test, pytest detects each step and calculates the RMS (Root Mean Square) current for every detected state. The test then compares the calculated RMS values against the expected values, which have been determined manually through experimental observation

pm.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.

pm.wakeup_timer: Tests the RTC alarm’s ability to wake the CPU from the lowest power state.

Each test calculates RMS current values for each detected state and compares them to expected values, which were manually set based on experimental data.

To Reproduce

  1. Configure the stm32l562e_dk board according to the instructions provided above.
  2. Connect both USB ports of the board to your host system. The board will appear as two separate targets:
    Power Monitor: e.g., /dev/ttyACM0 or /dev/serial/by-id/usb-STMicroelectronics_PowerShield__Virtual_ComPort_in_FS_Mode__FFFFFFFEFFFF-if00
    Target: e.g., /dev/ttyACM1 or /dev/serial/by-id/usb-STMicroelectronics_STLINK-V3_004##############39-if02
  3. Copy the path of the Power Monitor and update the <path_to_power_monitor> in the tests/subsys/pm/power_states/testcase.yaml file under the pytest_args section as follows:
    pytest_args: [--powershield=<path_to_power_monitor>]
  4. Run the following command to execute the test:
    twister --device-testing --device-serial <path_to_target> -p stm32l562e_dk -s <test_name> -x=CONFIG_BOOT_DELAY=500

@gbarkadiusz gbarkadiusz added the DNM This PR should not be merged (Do Not Merge) label Oct 31, 2024
@gbarkadiusz gbarkadiusz changed the title tests: pm: Adding tests based on a new approach to power management tests: pm: Adding tests based on new approach to PM testing. Oct 31, 2024
@gbarkadiusz gbarkadiusz force-pushed the topic/rfc/power_management branch 8 times, most recently from bb6e11e to cc760a2 Compare November 5, 2024 11:26
@gbarkadiusz gbarkadiusz linked an issue Nov 6, 2024 that may be closed by this pull request
@gbarkadiusz gbarkadiusz marked this pull request as ready for review November 14, 2024 09:38
gbarkadiusz added a commit to gbarkadiusz/zephyr that referenced this pull request Nov 18, 2024
This commit adds debug scripts, including `pwsh_stm32l562.py`
and `abstract_power_monitor.py`.
These scripts are part of the proposed changes in pull request zephyrproject-rtos#80692.

Signed-off-by: Arkadiusz Cholewinski <[email protected]>
data = current_measurement_output
# Empirical RMS values in mA with descriptive keys
rms_expected = {
"k_cpu_idle":57.0, # K_cpu_idle
Copy link
Collaborator

@hakehuang hakehuang Nov 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we move those expected data to a yaml file for different platform?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course we can, the good hint. Thank you.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PS: Btw, Please take a look. #80989. Feel free to share ideas or warries. :)

while (1) {
printk("\nGoing to k_cpu_idle.\n");
k_msleep(400);
printk("\nWake Up.\n");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we use this tests\subsys\pm\power_mgmt_soc\src\power_mgmt.c, instead of the sleep time?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know yet, let me see.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, get the information from the device tree is the way to go imho, otherwise it will not be portable and the previous comment is useless.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ceolin I added the use of DTS, is this what you meant?

@@ -0,0 +1,30 @@
# Copyright (c) 2024 Intel Corporation.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would this be better to move this function to scripts/pm/pm_helper.py, and rms is not the only implement, e.g. we can have average mean

@gbarkadiusz gbarkadiusz marked this pull request as draft November 25, 2024 14:49
@gbarkadiusz gbarkadiusz force-pushed the topic/rfc/power_management branch 3 times, most recently from f959bb2 to 980a943 Compare December 10, 2024 14:35
@gbarkadiusz gbarkadiusz force-pushed the topic/rfc/power_management branch 18 times, most recently from 1f00e48 to 69e3a4f Compare December 13, 2024 11:57
@gbarkadiusz gbarkadiusz force-pushed the topic/rfc/power_management branch 6 times, most recently from 2525c2f to dc18404 Compare January 10, 2025 13:43
@gbarkadiusz gbarkadiusz requested a review from hakehuang January 10, 2025 13:49
@gbarkadiusz
Copy link
Collaborator Author

@hakehuang I've moved the hardcoded expected value to the appropriate yaml file. Please take a look.

@gbarkadiusz gbarkadiusz marked this pull request as ready for review January 10, 2025 13:50
Introduces scripts for powerShiled on stm32l562e_dk board.
Adds three new power management pytests based on a new approach.

Signed-off-by: Arkadiusz Cholewinski <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Power Management DNM This PR should not be merged (Do Not Merge)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RFC: New Testing Approach for Power Management Subsystem.
4 participants