Skip to content

Commit 93de06d

Browse files
matthijskooijmanfpistm
authored andcommitted
Clear reset flags before starting bootloader
Since the bootloader does not touch these flags, but can start the sketch if instructed by the programmer (without a reset), clearing is needed to prevent a start from the bootloader looking like a software-reset. Otherwise, the startup code would be looking at the BootIntoBootloaderAfterReset variable to decide whether to jump to the bootloader. This variable should have been cleared before jumping to the bootloader the last time, but the bootloader might have overwritten it (or a sketch was uploaded with a different address for that variable). Additionally, clearing the reset flags allows a sketch to see that the they are started through the bootloader, when all reset flags are cleared.
1 parent c0ef636 commit 93de06d

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

libraries/SrcWrapper/src/stm32/bootloader.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ WEAK void jumpToBootloader(void)
119119
#endif
120120
void (*sysMemBootJump)(void);
121121

122+
__HAL_RCC_CLEAR_RESET_FLAGS();
123+
122124
/**
123125
* Get system memory address
124126
*

0 commit comments

Comments
 (0)