From cb9094dabbd9eb127791e29c48a4d101cfe3703a Mon Sep 17 00:00:00 2001 From: Aidan MacDonald Date: Mon, 29 Dec 2025 13:17:38 +0000 Subject: [PATCH] arm: fix start_thread() on Cortex-M targets The layout of 'struct regs' is a bit different on Cortex-M and start_thread() wasn't updated to match; it was loading 'sp' from the wrong offset. Change-Id: I57dbef26809821d411dc86e2066a2f53e78a3f2d --- firmware/asm/arm/thread.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/firmware/asm/arm/thread.c b/firmware/asm/arm/thread.c index e6f180f4ec..1ef836b128 100644 --- a/firmware/asm/arm/thread.c +++ b/firmware/asm/arm/thread.c @@ -29,7 +29,11 @@ static void __attribute__((naked)) USED_ATTR start_thread(void) { /* r0 = context */ asm volatile ( +#if defined(CPU_ARM_MICRO) && ARCH_VERSION >= 7 + "ldr sp, [r0, #36] \n" /* Load initial sp */ +#else "ldr sp, [r0, #32] \n" /* Load initial sp */ +#endif "ldr r4, [r0, #40] \n" /* start in r4 since it's non-volatile */ "mov r1, #0 \n" /* Mark thread as running */ "str r1, [r0, #40] \n"