STM32 H7X: cleanup setting of power supply and voltage scaling #87332
+2
−43
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 becomes3 → 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.