Skip to content

Commit f656a31

Browse files
author
Vincent Dupont
committed
cpu/cortexm_common: use linker variable to initialize SCB->VTOR
1 parent 1b2b5d9 commit f656a31

File tree

3 files changed

+8
-2
lines changed

3 files changed

+8
-2
lines changed

cpu/cortexm_common/cortexm_init.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@
2626
*/
2727
#define FULL_FPU_ACCESS (0x00f00000)
2828

29+
/**
30+
* Interrupt vector base address, defined by the linker
31+
*/
32+
extern const void *_isr_vectors;
33+
2934
void cortexm_init(void)
3035
{
3136
/* initialize the FPU on Cortex-M4F CPUs */
@@ -37,7 +42,7 @@ void cortexm_init(void)
3742
/* configure the vector table location to internal flash */
3843
#if defined(CPU_ARCH_CORTEX_M3) || defined(CPU_ARCH_CORTEX_M4) || \
3944
defined(CPU_ARCH_CORTEX_M4F)
40-
SCB->VTOR = CPU_FLASH_BASE;
45+
SCB->VTOR = (uint32_t)&_isr_vectors;
4146
#endif
4247

4348
/* initialize the interrupt priorities */

cpu/cortexm_common/ldscripts/cortexm_base.ld

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ SECTIONS
4141
{
4242
. = ALIGN(4);
4343
_sfixed = .;
44+
_isr_vectors = DEFINED(_isr_vectors) ? _isr_vectors : . ;
4445
KEEP(*(.vectors .vectors.*))
4546
*(.text .text.* .gnu.linkonce.t.*)
4647
*(.glue_7t) *(.glue_7)

cpu/kinetis_common/ldscripts/kinetis.ld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ SECTIONS
2525
/* Interrupt vectors 0x00-0x3ff. */
2626
.vector_table :
2727
{
28-
_vector_rom = .;
28+
_isr_vectors = .;
2929
KEEP(*(.vector_table))
3030
} > vectors
3131
ASSERT (SIZEOF(.vector_table) == 0x400, "Interrupt vector table of invalid size.")

0 commit comments

Comments
 (0)