From f656a31e580f724b76aaa00ae0ee2b974e9eda37 Mon Sep 17 00:00:00 2001 From: Vincent Dupont <vincent@otakeys.com> Date: Wed, 22 Feb 2017 15:39:01 +0100 Subject: [PATCH] cpu/cortexm_common: use linker variable to initialize SCB->VTOR --- cpu/cortexm_common/cortexm_init.c | 7 ++++++- cpu/cortexm_common/ldscripts/cortexm_base.ld | 1 + cpu/kinetis_common/ldscripts/kinetis.ld | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/cpu/cortexm_common/cortexm_init.c b/cpu/cortexm_common/cortexm_init.c index 73bd40c4d7..664c55b050 100644 --- a/cpu/cortexm_common/cortexm_init.c +++ b/cpu/cortexm_common/cortexm_init.c @@ -26,6 +26,11 @@ */ #define FULL_FPU_ACCESS (0x00f00000) +/** + * Interrupt vector base address, defined by the linker + */ +extern const void *_isr_vectors; + void cortexm_init(void) { /* initialize the FPU on Cortex-M4F CPUs */ @@ -37,7 +42,7 @@ void cortexm_init(void) /* configure the vector table location to internal flash */ #if defined(CPU_ARCH_CORTEX_M3) || defined(CPU_ARCH_CORTEX_M4) || \ defined(CPU_ARCH_CORTEX_M4F) - SCB->VTOR = CPU_FLASH_BASE; + SCB->VTOR = (uint32_t)&_isr_vectors; #endif /* initialize the interrupt priorities */ diff --git a/cpu/cortexm_common/ldscripts/cortexm_base.ld b/cpu/cortexm_common/ldscripts/cortexm_base.ld index 68c19e7d3e..2e95c8ffc6 100644 --- a/cpu/cortexm_common/ldscripts/cortexm_base.ld +++ b/cpu/cortexm_common/ldscripts/cortexm_base.ld @@ -41,6 +41,7 @@ SECTIONS { . = ALIGN(4); _sfixed = .; + _isr_vectors = DEFINED(_isr_vectors) ? _isr_vectors : . ; KEEP(*(.vectors .vectors.*)) *(.text .text.* .gnu.linkonce.t.*) *(.glue_7t) *(.glue_7) diff --git a/cpu/kinetis_common/ldscripts/kinetis.ld b/cpu/kinetis_common/ldscripts/kinetis.ld index d4be65b5d5..084b115033 100644 --- a/cpu/kinetis_common/ldscripts/kinetis.ld +++ b/cpu/kinetis_common/ldscripts/kinetis.ld @@ -25,7 +25,7 @@ SECTIONS /* Interrupt vectors 0x00-0x3ff. */ .vector_table : { - _vector_rom = .; + _isr_vectors = .; KEEP(*(.vector_table)) } > vectors ASSERT (SIZEOF(.vector_table) == 0x400, "Interrupt vector table of invalid size.") -- GitLab