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

[stm32] PM restore console after sleep mode #31284

Closed
FRASTM opened this issue Jan 13, 2021 · 4 comments · Fixed by #32128
Closed

[stm32] PM restore console after sleep mode #31284

FRASTM opened this issue Jan 13, 2021 · 4 comments · Fixed by #32128
Assignees
Labels
area: Power Management Enhancement Changes/Updates/Additions to existing features platform: STM32 ST Micro STM32

Comments

@FRASTM
Copy link
Collaborator

FRASTM commented Jan 13, 2021

When testing the PowerManagement on stm32L4 or stm32WB55 through the tests/subsys/power/power_mgmt
the console is no more functional and prints spurious characters.

Describe the solution you'd like
To define a function in the uart_stm32.c driver (replace device_pm_control_nop)
to flush the console before going to sleep
To restore the correct clock for the console after sleep mode

**Console: **


Running test suite power_management_test                                        
===================================================================             
START - test_power_idle                                                         
give way to idle thread                                                         
 PASS - test_power_idle                                                         
===================================================================             
START - test_power_state_trans                                                  
�������������������������������������������������������������������������������

@FRASTM FRASTM added the Enhancement Changes/Updates/Additions to existing features label Jan 13, 2021
@FRASTM FRASTM changed the title [stm32] PM restore trace after sleep mode [stm32] PM restore console after sleep mode Jan 13, 2021
@FRASTM
Copy link
Collaborator Author

FRASTM commented Jan 14, 2021

When considering STOP 0/1/2 low power modes as DEVICE_PM_LOW_POWER_STATE for the stm32l4xx soc:

  1. before going to sleep mode, wait for USART Rx and Tx empty
  2. USART is clocked by the PLL. During STOP mode the all clocks are OFF except LSE and LSI. After STOP mode HSI16 or MSI are wakeup clock, so the USART needs one of them or system must restore the PLL
  3. in the test application tests/subsys/power/power_mgmt, the dummy_driver is put in DEVICE_PM_SUSPEND_STATE
    not in DEVICE_PM_LOW_POWER_STATE
  4. LPUART is not available on this nucleo board

@FRASTM
Copy link
Collaborator Author

FRASTM commented Jan 15, 2021

In the test application tests/subsys/power/power_mgmt, the dummy_driver is put in DEVICE_PM_SUSPEND_STATE (=3)
Going to sleep mode the dummy driver is still in DEVICE_PM_SUSPEND_STATE (=3) when the irq (lptim) occurs and cause the system to wakeUp.
On wakeUp, the pm_notify_power_state_exit() is called in the pm_system_resume(), "from the ISR of the event that caused exit from kernel idling after PM operations" before the pm_resume_devices() function.
The pm_notify_power_state_exit, implemented in the main.c, is checking the device_power_state of the dummy driver.
At this moment the device_power_state of the dummy driver is still DEVICE_PM_SUSPEND_STATE.
--> zassert_equal(device_power_state, DEVICE_PM_ACTIVE_STATE, NULL); fails
After that, the pm_resume_devices(), especially for the dummy_driver is setting back the device_power_state from DEVICE_PM_SUSPEND_STATE to DEVICE_PM_ACTIVE_STATE.

@FRASTM
Copy link
Collaborator Author

FRASTM commented Feb 10, 2021

add the CONFIG_PM_DEVICE definition from the CONFIG_PM for the soc that supports the low power modes.

@FRASTM
Copy link
Collaborator Author

FRASTM commented Feb 10, 2021

Note that the tests/subsys/power/power_mgmt_soc might requires a stack size with CONFIG_IDLE_STACK_SIZE=640 in its prj.conf

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Power Management Enhancement Changes/Updates/Additions to existing features platform: STM32 ST Micro STM32
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant