File tree Expand file tree Collapse file tree 3 files changed +18
-4
lines changed
libraries/SrcWrapper/src/stm32 Expand file tree Collapse file tree 3 files changed +18
-4
lines changed Original file line number Diff line number Diff line change 33#if defined(CMSIS_STARTUP_FILE)
44#include CMSIS_STARTUP_FILE
55#endif
6+
7+ # Expose Reset_Handler under a different name, to allow overriding it
8+ # with a strong symbol and then calling the original.
9+ .global Original_Reset_Handler
10+ .thumb_set Original_Reset_Handler,Reset_Handler
Original file line number Diff line number Diff line change 1313/* Private definitions to manage system memory address */
1414#define SYSMEM_ADDR_COMMON 0xFFF
1515
16- static bool BootIntoBootloaderAfterReset __attribute__(( __section__ ( ".noinit" ))) ;
16+ static bool BootIntoBootloaderAfterReset ;
1717
1818typedef struct {
1919 uint32_t devID ;
@@ -87,6 +87,18 @@ WEAK void jumpToBootloaderRequested(void)
8787 NVIC_SystemReset ();
8888}
8989
90+ // This overrides the Reset_Handler that is run on reset before
91+ // *anything* else (including memory initialization). Only the stack
92+ // pointer is set up by this time.
93+ void Reset_Handler ()
94+ {
95+ // Jump to the bootloader if needed.
96+ jumpToBootloader ();
97+
98+ // Continue with regular startup by calling the original reset handler
99+ Original_Reset_Handler ();
100+ }
101+
90102/* Jump to system memory boot from user application */
91103WEAK void jumpToBootloader (void )
92104{
Original file line number Diff line number Diff line change @@ -60,9 +60,6 @@ void hw_config_init(void)
6060 /* Initialize the HAL */
6161 HAL_Init ();
6262
63- /* Check if a jump to system memory boot requested */
64- jumpToBootloader ();
65-
6663 /* Configure the system clock */
6764 SystemClock_Config ();
6865
You can’t perform that action at this time.
0 commit comments