diff --git a/asm.S b/asm.S index 0d078b37..28404181 100644 --- a/asm.S +++ b/asm.S @@ -44,6 +44,21 @@ Reset: ldr r4,=0xffffffff mov lr,r4 + # Some faulty debuggers fake a reset by jumping to the reset vector + # without triggering a system reset, leaving the stack pointer at + # its previous value. To ensure consistency, set MSP ourselves here. + ldr r0,=_stack_start + msr msp,r0 + + # Some buggy bootloaders do not set VTOR when jumping to application + # code, which leaves a very hard-to-debug issue where everything works + # except your interrupt handlers. We manually set VTOR here to avoid + # this issue. The VTOR register is optional on ARMv6-M, but when not + # present must be RAZ,WI and is therefore safe to write to. + ldr r0,=0xe000ed08 + ldr r1,=__vector_table + str r1,[r0] + # Run user pre-init code, which must be executed immediately after startup, # before the potentially time-consuming memory initialisation takes place. # Example use cases include disabling default watchdogs or enabling RAM. diff --git a/bin/thumbv6m-none-eabi.a b/bin/thumbv6m-none-eabi.a index c145cc61..a01bdc0c 100644 Binary files a/bin/thumbv6m-none-eabi.a and b/bin/thumbv6m-none-eabi.a differ diff --git a/bin/thumbv7em-none-eabi.a b/bin/thumbv7em-none-eabi.a index 2d6b6a1f..ca7f10c9 100644 Binary files a/bin/thumbv7em-none-eabi.a and b/bin/thumbv7em-none-eabi.a differ diff --git a/bin/thumbv7em-none-eabihf.a b/bin/thumbv7em-none-eabihf.a index aa765ea3..818068c5 100644 Binary files a/bin/thumbv7em-none-eabihf.a and b/bin/thumbv7em-none-eabihf.a differ diff --git a/bin/thumbv7m-none-eabi.a b/bin/thumbv7m-none-eabi.a index 3d1783c6..da9140e3 100644 Binary files a/bin/thumbv7m-none-eabi.a and b/bin/thumbv7m-none-eabi.a differ diff --git a/bin/thumbv8m.base-none-eabi.a b/bin/thumbv8m.base-none-eabi.a index a9fb4345..92d44cb5 100644 Binary files a/bin/thumbv8m.base-none-eabi.a and b/bin/thumbv8m.base-none-eabi.a differ diff --git a/bin/thumbv8m.main-none-eabi.a b/bin/thumbv8m.main-none-eabi.a index 40a5c512..9b1db956 100644 Binary files a/bin/thumbv8m.main-none-eabi.a and b/bin/thumbv8m.main-none-eabi.a differ diff --git a/bin/thumbv8m.main-none-eabihf.a b/bin/thumbv8m.main-none-eabihf.a index 6c523af3..e15e52f8 100644 Binary files a/bin/thumbv8m.main-none-eabihf.a and b/bin/thumbv8m.main-none-eabihf.a differ diff --git a/link.x.in b/link.x.in index 92004b7f..8e5ed0fd 100644 --- a/link.x.in +++ b/link.x.in @@ -68,6 +68,7 @@ SECTIONS { /* Initial Stack Pointer (SP) value */ LONG(_stack_start); + __vector_table = .; /* Reset vector */ KEEP(*(.vector_table.reset_vector)); /* this is the `__RESET_VECTOR` symbol */