From 441498390ed4a885223e042f270b1c3c65b9fa52 Mon Sep 17 00:00:00 2001 From: Chen Peng Date: Fri, 17 Jul 2026 12:02:26 +0800 Subject: [PATCH] =?UTF-8?q?HardFault=5FHandler=20=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- os_port.c | 2 +- os_port_armcc.S | 1 + os_port_gnu.S | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/os_port.c b/os_port.c index 1d09d31..dc634d1 100644 --- a/os_port.c +++ b/os_port.c @@ -243,7 +243,7 @@ void HardFault_Handler_C(ContextStateFrame_t* frame, uint32_t lr_value){ // "thumb instruction interworking" bit set frame->xpsr = (1 << 24); #else - while(1); + while(1){} #endif } diff --git a/os_port_armcc.S b/os_port_armcc.S index f159f77..10ee3e4 100644 --- a/os_port_armcc.S +++ b/os_port_armcc.S @@ -69,6 +69,7 @@ __PendSV_SwitchTo HardFault_Handler PROC EXPORT HardFault_Handler + IMPORT HardFault_Handler_C tst lr, #4 // 检查 EXC_RETURN (LR) 的位 2 ite eq mrseq r0, msp // 如果位 2 是 0,栈帧在 MSP diff --git a/os_port_gnu.S b/os_port_gnu.S index 0f1fc63..9fa99e2 100644 --- a/os_port_gnu.S +++ b/os_port_gnu.S @@ -78,6 +78,7 @@ cpu_clz: .section .text.HardFault_Handler,"ax",%progbits .global HardFault_Handler + .global HardFault_Handler_C .thumb_func HardFault_Handler: tst lr, #4