diff options
author | Damien George <damien@micropython.org> | 2020-06-23 13:56:20 +1000 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2020-06-23 13:56:20 +1000 |
commit | 81a7293ed63bb39e05e4303f7ad297807748c7ea (patch) | |
tree | 417f8f7e754fa5a0320f32dca079ab357efd6fa2 | |
parent | 13ad1a4f06f2d114c821279f58fa7462e8bd0d41 (diff) |
stm32/mboot: Set VTOR on start up to ensure it has the correct value.
Commit 8675858465f3d83aab709170eab6dc141570acf4 switched to using the CMSIS
provided SystemInit function which sets VTOR to 0x00000000 (previously it
was 0x08000000). A VTOR of 0x00000000 will be correct on some MCUs but not
on others where the built-in bootloader is remapped to this address, via
__HAL_SYSCFG_REMAPMEMORY_SYSTEMFLASH().
To make sure mboot has the correct vector table, this commit explicitly
sets VTOR to the correct value of 0x08000000.
Signed-off-by: Damien George <damien@micropython.org>
-rw-r--r-- | ports/stm32/mboot/main.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/ports/stm32/mboot/main.c b/ports/stm32/mboot/main.c index b3af49526..b3e63ccc2 100644 --- a/ports/stm32/mboot/main.c +++ b/ports/stm32/mboot/main.c @@ -1285,6 +1285,9 @@ void stm32_main(int initial_r0) { RCC->D3CCIPR = 0x00000000; #endif + // Make sure IRQ vector table points to flash where this bootloader lives. + SCB->VTOR = FLASH_BASE; + // Enable 8-byte stack alignment for IRQ handlers, in accord with EABI SCB->CCR |= SCB_CCR_STKALIGN_Msk; |