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 H7X: cleanup setting of power supply and voltage scaling #87332

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

GeorgeCGV
Copy link
Collaborator

Currently, the H7 configures power supply and voltage scaling in multiple locations: SoC initialization and clock initialization. Different scaling factors are applied: SoC init sets it to 1, while clock init applies the boost scale of 0.

This setup functions correctly when the firmware boots without MCUboot, following the sequence: 3 (default) → 1 → 0. However, when used with MCUboot, the sequence becomes 3 → 1 → 0 → 1 → 0. If the bootloader configures the system clock to 480 MHz and jumps to the application with a scaling factor of 0, the application then sets it back to 1 during early SoC initialization. This results in an incorrect scaling factor for the configured system clock, with potentially unknown consequences.

Additionally, the power source is redundantly set in multiple places to the same value, whereas it could be configured just once in early SoC initialization.

This PR simplifies the process by setting the power source only once in early SoC initialization while leaving voltage scaling to the clock initialization phase.

It has been tested successfully on the H730, but further testing, especially on H7 configurations with both M7 and M4 cores, would be valuable.

The voltage scaling is set during h7 clock initialization.

Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
The power supply configuration is already set during
the early H7 soc init.

Let the clock initialization handle the voltage scaling.

Signed-off-by: Georgij Cernysiov <geo.cgv@gmail.com>
@GeorgeCGV GeorgeCGV force-pushed the stm32_soc_clock_power_scale_refactor branch from 66678ac to 6576cb5 Compare March 19, 2025 10:20
@erwango
Copy link
Member

erwango commented Mar 19, 2025

It has been tested successfully on the H730, but further testing, especially on H7 configurations with both M7 and M4 cores, would be valuable.

@djiatsaf-st Can you help testing this on stm32h747i_disco (m7 and m4) ?

@GeorgeCGV GeorgeCGV changed the title STM32 H7 cleanup setting of power supply and voltage scaling STM32 H7X: cleanup setting of power supply and voltage scaling Mar 19, 2025
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.

This code only applies for M7 as no clock config is done in M4 case, so this change is fine. Thanks!

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.

2 participants