Skip to content

Commit 18e7185

Browse files
Do not jump to system bootloader when custom bootloader is used
1 parent 0f48a67 commit 18e7185

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

libraries/SrcWrapper/src/stm32/bootloader.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,17 @@ WEAK uint32_t bootloaderAddress() {
7878
/* Jump to system memory boot from user application */
7979
WEAK void jumpToBootloaderIfRequested(void)
8080
{
81+
// If we are not at the start of flash, assume that a custom
82+
// bootloader is in front of us, and there is no need to jump to it
83+
// (since it will run before we can run anyway). If such a bootloader
84+
// exists, the BootIntoBootloaderAfterReset variable will likely be
85+
// corrupted anyway.
86+
// TODO: Might be better to use a specific macro to control this,
87+
// rather than check VECT_TAB_OFFSET
88+
#if defined(VECT_TAB_OFFSET) && (VECT_TAB_OFFSET > 0)
89+
return;
90+
#endif
91+
8192
// Boot into bootloader if BootIntoBootloaderAfterReset is set.
8293
// Note that BootIntoBootloaderAfterReset is a noinit variable, so it
8394
// s not automatically initialized on startup (so it can keep its

0 commit comments

Comments
 (0)