Fix STM32H7 DFU mode entry via CLI command #11295
Open
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.
User description
Summary
Fixes the CLI
dfucommand on STM32H743/H750 targets. Previously, the command would reboot the board but it would return as a VCP device instead of entering DFU mode for firmware flashing.Root cause: The bootloader request check was happening too late in the boot sequence (after clock and peripheral initialization). The H7 ROM bootloader requires the RTC backup register check to occur before any system configuration happens.
Solution: moved checkForBootLoaderRequest from src/main/drivers/system_stm32h7xx.c to src/main/target/system_stm32h7xx.c (CMSIS startup, before any hardware initialization). Also enable SYSCFG clock before jumping to bootloader.
Changes
SystemInit()before any clock configurationsystemInit()#if defined(STM32H7))Platform Impact
H7-specific only. All changes are either in H7-specific files or properly gated with
#if defined(STM32H7)in shared files. F4/F7/AT32 platforms are completely unaffected.Testing
dfucommandTest Plan
PR Type
Bug fix
Description
Move bootloader check to early SystemInit() before clock configuration
Enable SYSCFG clock before jumping to H7 bootloader
Add H7-specific bootloader jump code with proper gating
Remove late bootloader check from systemInit() driver function
Diagram Walkthrough
flowchart LR A["Boot sequence"] --> B["SystemInit CMSIS startup"] B --> C["checkForBootLoaderRequest early"] C --> D{"Bootloader request?"} D -->|Yes H7| E["Enable SYSCFG clock"] E --> F["Jump to bootloader"] D -->|No| G["Continue normal boot"] D -->|Yes F4/F7| H["Jump to bootloader"]File Walkthrough
system.c
Add H7-specific bootloader jump with SYSCFG clocksrc/main/drivers/system.c
__HAL_RCC_SYSCFG_CLK_ENABLE()call#if defined(STM32H7)preprocessorguard
steps
system_stm32h7xx.c
Remove late bootloader check from systemInitsrc/main/drivers/system_stm32h7xx.c
checkForBootLoaderRequest()call fromsystemInit()functionSystemInit()before clockconfiguration
system_stm32h7xx.c
Add early bootloader check in SystemInitsrc/main/target/system_stm32h7xx.c
checkForBootLoaderRequest()call inSystemInit()CMSISstartup function
initialization
bootloader