diff --git a/arch/arm/src/armv6-m/arm_vectors.c b/arch/arm/src/armv6-m/arm_vectors.c index eb4f27ebbde..8beb9443c1d 100644 --- a/arch/arm/src/armv6-m/arm_vectors.c +++ b/arch/arm/src/armv6-m/arm_vectors.c @@ -57,13 +57,27 @@ #endif /**************************************************************************** - * Public Functions + * Private Functions ****************************************************************************/ /* Chip-specific entrypoint */ extern void __start(void); +static void start(void) +{ + /* Zero lr to mark the end of backtrace */ + + asm volatile ("mov lr, %0\n\t" + "bx %1\n\t" + : + : "r"(0), "r"(__start)); +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + /* Common exception entrypoint */ extern void exception_common(void); @@ -89,7 +103,7 @@ const void * const _vectors[] locate_data(".vectors") = /* Reset exception handler */ - __start, + start, /* Vectors 2 - n point directly at the generic handler */ diff --git a/arch/arm/src/armv7-m/arm_vectors.c b/arch/arm/src/armv7-m/arm_vectors.c index b5459ebd1d2..c4674ab20f4 100644 --- a/arch/arm/src/armv7-m/arm_vectors.c +++ b/arch/arm/src/armv7-m/arm_vectors.c @@ -49,13 +49,25 @@ #define IDLE_STACK (_ebss + CONFIG_IDLETHREAD_STACKSIZE) /**************************************************************************** - * Public Functions + * Private Functions ****************************************************************************/ /* Chip-specific entrypoint */ extern void __start(void); +static void start(void) +{ + /* Zero lr to mark the end of backtrace */ + + asm volatile ("mov lr, #0\n\t" + "b __start\n\t"); +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + /* Common exception entrypoint */ extern void exception_common(void); @@ -82,7 +94,7 @@ const void * const _vectors[] locate_data(".vectors") /* Reset exception handler */ - __start, + start, /* Vectors 2 - n point directly at the generic handler */ diff --git a/arch/arm/src/armv8-m/arm_vectors.c b/arch/arm/src/armv8-m/arm_vectors.c index 7427b23a437..75308996e14 100644 --- a/arch/arm/src/armv8-m/arm_vectors.c +++ b/arch/arm/src/armv8-m/arm_vectors.c @@ -52,13 +52,25 @@ #endif /**************************************************************************** - * Public Functions + * Private Functions ****************************************************************************/ /* Chip-specific entrypoint */ extern void __start(void); +static void start(void) +{ + /* Zero lr to mark the end of backtrace */ + + asm volatile ("mov lr, #0\n\t" + "b __start\n\t"); +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + /* Common exception entrypoint */ extern void exception_common(void); @@ -84,7 +96,7 @@ const void * const _vectors[] locate_data(".vectors") = /* Reset exception handler */ - __start, + start, /* Vectors 2 - n point directly at the generic handler */