From 00ddd8a81a79d94ed5302469261c103d5e3f0096 Mon Sep 17 00:00:00 2001 From: Wilfried Chauveau Date: Tue, 23 Apr 2024 19:02:42 +0100 Subject: [PATCH] =?UTF-8?q?arch:=20arm:=20cortex=5Fm:=20enable=20interrupt?= =?UTF-8?q?s=20before=20entering=20application=E2=80=99s=20main?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This also fixes a typo in `z_arm_switch_to_main_no_multithreading` making it unlock irq instead of locking them when main returns. Signed-off-by: Wilfried Chauveau --- arch/arm/core/cortex_m/thread.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/arch/arm/core/cortex_m/thread.c b/arch/arm/core/cortex_m/thread.c index f9a030675b..e9ab7292ab 100644 --- a/arch/arm/core/cortex_m/thread.c +++ b/arch/arm/core/cortex_m/thread.c @@ -595,6 +595,10 @@ void arch_switch_to_main_thread(struct k_thread *main_thread, char *stack_ptr, __used void arch_irq_unlock_outlined(unsigned int key) { +#if defined(CONFIG_ARMV7_M_ARMV8_M_MAINLINE) + __enable_fault_irq(); /* alters FAULTMASK */ + __enable_irq(); /* alters PRIMASK */ +#endif arch_irq_unlock(key); } @@ -646,9 +650,8 @@ FUNC_NORETURN void z_arm_switch_to_main_no_multithreading( "mov r2, %[_p3]\n" "blx %[_main_entry]\n" /* main_entry(p1, p2, p3) */ - "mov r0, #0\n" - "ldr r1, =arch_irq_unlock_outlined\n" - "blx r1\n" + "ldr r0, =arch_irq_lock_outlined\n" + "blx r0\n" "loop: b loop\n\t" /* while (true); */ : : [_p1]"r" (p1), [_p2]"r" (p2), [_p3]"r" (p3),