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 3
3
#if defined(CMSIS_STARTUP_FILE)
4
4
#include CMSIS_STARTUP_FILE
5
5
#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 13
13
/* Private definitions to manage system memory address */
14
14
#define SYSMEM_ADDR_COMMON 0xFFF
15
15
16
- static bool BootIntoBootloaderAfterReset __attribute__(( __section__ ( ".noinit" ))) ;
16
+ static bool BootIntoBootloaderAfterReset ;
17
17
18
18
typedef struct {
19
19
uint32_t devID ;
@@ -87,6 +87,18 @@ WEAK void jumpToBootloaderRequested(void)
87
87
NVIC_SystemReset ();
88
88
}
89
89
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
+
90
102
/* Jump to system memory boot from user application */
91
103
WEAK void jumpToBootloader (void )
92
104
{
Original file line number Diff line number Diff line change @@ -60,9 +60,6 @@ void hw_config_init(void)
60
60
/* Initialize the HAL */
61
61
HAL_Init ();
62
62
63
- /* Check if a jump to system memory boot requested */
64
- jumpToBootloader ();
65
-
66
63
/* Configure the system clock */
67
64
SystemClock_Config ();
68
65
You can’t perform that action at this time.
0 commit comments