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

STM32F4x power management #65050

Merged
merged 2 commits into from Nov 21, 2023

Conversation

niedzwiecki-dawid
Copy link
Member

@niedzwiecki-dawid niedzwiecki-dawid commented Nov 10, 2023

Add Power Management support for the STM32F4x chips

ceolin
ceolin previously approved these changes Nov 11, 2023
Copy link
Member

@ceolin ceolin left a comment

Choose a reason for hiding this comment

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

Minor comment, it looks good from the subsystem usage perspective.

Copy link
Member

@erwango erwango left a comment

Choose a reason for hiding this comment

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

Few changes requested, but otherwise looks good.

This being said, would you mind enabling board on samples/boards/stm32/power_mgmt/blinky ?

I'm having a try and I can't see the LED blinking nor I can see power savings.
I'm using nucleo_f429zi and measuring power on JP5. Please let me know if this should be made in a different way.

soc/arm/st_stm32/stm32f4/Kconfig.series Outdated Show resolved Hide resolved
soc/arm/st_stm32/stm32f4/Kconfig.series Outdated Show resolved Hide resolved
@erwango
Copy link
Member

erwango commented Nov 13, 2023

Note:
I can see different behavior with CONFIG_DEBUG=y and =n

CONFIG_DEBUG=y:

  • LED is blinking (10 sec in stead of 2 sec)
  • Power is around 5mA

CONFIG_DEBUG=n:

  • LED is not blinking
  • Power is around 55mA

Difference between the 2 configs should be DBGMCU_CR_DBG_SLEEP value in DBGMCU->CR

@niedzwiecki-dawid
Copy link
Member Author

Sure, I'll check the blinky sample.

@niedzwiecki-dawid
Copy link
Member Author

I've reproduced the same problem. It is about the stack size. Using the RTC as idle timer requires IDLE_STACK_SIZE at least 500, because of additional calls to set the alarm. With that, everything works fine on my side. Power is ~6,9mA regardless of the CONFIG_DEBUG.

Now, I'm thinking if I should add increasing the idle stack automatically or let the user do it in the config files. I would rather chose the second option with some additional documentation somewhere.

Add soc power management for the STM32F4x chips.

One low power state is added supported by all chips from the family -
the Stop mode with voltage regulator in low-power mode.

The Stop mode for STM32F chips has to work with the IDLE timer -
CORTEX_M_SYSTICK_IDLE_TIMER, because PLL and HSI are disabled in the
Stop mode (Systick is not clocked). The only possible wakeup source is
RTC, which works as a IDLE timer for the Systick.

The exit latency may need to be adjusted per system, depending on the
system tick frequency and other variables.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
Add soc power management test and blinky sample for the nucleo_f429zi
board.

Signed-off-by: Dawid Niedzwiecki <dawidn@google.com>
@erwango erwango requested a review from ceolin November 16, 2023 12:59
@niedzwiecki-dawid
Copy link
Member Author

@ceolin ping

@fabiobaltieri fabiobaltieri merged commit e6c7a4c into zephyrproject-rtos:main Nov 21, 2023
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants