aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien George2018-03-27 21:32:39 +1100
committerDamien George2018-03-27 21:32:39 +1100
commit04de9e33bce3c30de86c3486a132f5a646239c4a (patch)
treed4505bd9a4b05fb9b100501caa37f50851de7554
parentdcf4eb8134f7392d462e1a4d9f3db7cb8e62517e (diff)
stm32/system_stm32: Set VTOR pointer from TEXT0_ADDR.
-rw-r--r--ports/stm32/Makefile1
-rw-r--r--ports/stm32/system_stm32.c4
2 files changed, 5 insertions, 0 deletions
diff --git a/ports/stm32/Makefile b/ports/stm32/Makefile
index d1c5de6d3..66582058a 100644
--- a/ports/stm32/Makefile
+++ b/ports/stm32/Makefile
@@ -72,6 +72,7 @@ CFLAGS += $(CFLAGS_MCU_$(MCU_SERIES))
CFLAGS += $(COPT)
CFLAGS += -Iboards/$(BOARD)
CFLAGS += -DSTM32_HAL_H='<stm32$(MCU_SERIES)xx_hal.h>'
+CFLAGS += -DMICROPY_HW_VTOR=$(TEXT0_ADDR)
ifeq ($(MICROPY_FLOAT_IMPL),double)
CFLAGS += -DMICROPY_FLOAT_IMPL=MICROPY_FLOAT_IMPL_DOUBLE
diff --git a/ports/stm32/system_stm32.c b/ports/stm32/system_stm32.c
index 6c24ee417..251902259 100644
--- a/ports/stm32/system_stm32.c
+++ b/ports/stm32/system_stm32.c
@@ -275,11 +275,15 @@ void SystemInit(void)
#endif
/* Configure the Vector Table location add offset address ------------------*/
+#ifdef MICROPY_HW_VTOR
+ SCB->VTOR = MICROPY_HW_VTOR;
+#else
#ifdef VECT_TAB_SRAM
SCB->VTOR = SRAM1_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */
#else
SCB->VTOR = FLASH_BASE | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal FLASH */
#endif
+#endif
/* dpgeorge: enable 8-byte stack alignment for IRQ handlers, in accord with EABI */
SCB->CCR |= SCB_CCR_STKALIGN_Msk;