From 382a829657b29ddd90de4c50e72892259e41b49f Mon Sep 17 00:00:00 2001 From: Masayuki Ishikawa Date: Mon, 30 Jul 2018 12:32:55 +0000 Subject: [PATCH] Merged in masayuki2009/nuttx.nuttx/hardfault_info (pull request #699) hardfault info * arch/arm: Introduce CONFIG_DEBUG_HARDFAULT_INFO to Kconfig Signed-off-by: Masayuki Ishikawa * arch/arm/src/armv7-m: Introduce CONFIG_DEBUG_HARDFAULT_INFO to up_hardfault.c Signed-off-by: Masayuki Ishikawa * arch/arm/src/armv6-m: Introduce CONFIG_DEBUG_HARDFAULT_INFO to up_hardfault.c Also, replace _alert() with hfalert() Signed-off-by: Masayuki Ishikawa Approved-by: GregoryN --- arch/arm/Kconfig | 7 +++++++ arch/arm/src/armv6-m/up_hardfault.c | 22 ++++++++++++++-------- arch/arm/src/armv7-m/up_hardfault.c | 11 +++++++++-- 3 files changed, 30 insertions(+), 10 deletions(-) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 01609ff59e..9ca8c41713 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -759,6 +759,13 @@ config DEBUG_HARDFAULT output is sometimes helpful when debugging difficult hard fault problems, but may be more than you typically want to see. +config DEBUG_HARDFAULT_INFO + bool "Hard-Fault Informational Output" + default n + depends on ARCH_HAVE_HARDFAULT_DEBUG && DEBUG_FEATURES && DEBUG_INFO + ---help--- + Enable hard fault informational output to SYSLOG. + config ARCH_HAVE_MEMFAULT_DEBUG bool default n diff --git a/arch/arm/src/armv6-m/up_hardfault.c b/arch/arm/src/armv6-m/up_hardfault.c index 6b4f69760e..4f0c7b4f78 100644 --- a/arch/arm/src/armv6-m/up_hardfault.c +++ b/arch/arm/src/armv6-m/up_hardfault.c @@ -55,7 +55,13 @@ ****************************************************************************/ #ifdef CONFIG_DEBUG_HARDFAULT -# define hfinfo(format, ...) _alert(format, ##__VA_ARGS__) +# define hfalert(format, ...) _alert(format, ##__VA_ARGS__) +#else +# define hfalert(x...) +#endif + +#ifdef CONFIG_DEBUG_HARDFAULT_INFO +# define hfinfo(format, ...) _info(format, ##__VA_ARGS__) #else # define hfinfo(x...) #endif @@ -122,22 +128,22 @@ int up_hardfault(int irq, FAR void *context, FAR void *arg) #if defined(CONFIG_DEBUG_HARDFAULT) /* Dump some hard fault info */ - _alert("\nHard Fault:\n"); - _alert(" IRQ: %d regs: %p\n", irq, regs); - _alert(" PRIMASK: %08x IPSR: %08x\n", + hfalert("\nHard Fault:\n"); + hfalert(" IRQ: %d regs: %p\n", irq, regs); + hfalert(" PRIMASK: %08x IPSR: %08x\n", getprimask(), getipsr()); - _alert(" R0: %08x %08x %08x %08x %08x %08x %08x %08x\n", + hfalert(" R0: %08x %08x %08x %08x %08x %08x %08x %08x\n", regs[REG_R0], regs[REG_R1], regs[REG_R2], regs[REG_R3], regs[REG_R4], regs[REG_R5], regs[REG_R6], regs[REG_R7]); - _alert(" R8: %08x %08x %08x %08x %08x %08x %08x %08x\n", + hfalert(" R8: %08x %08x %08x %08x %08x %08x %08x %08x\n", regs[REG_R8], regs[REG_R9], regs[REG_R10], regs[REG_R11], regs[REG_R12], regs[REG_R13], regs[REG_R14], regs[REG_R15]); - _alert(" xPSR: %08x PRIMASK: %08x (saved)\n", + hfalert(" xPSR: %08x PRIMASK: %08x (saved)\n", CURRENT_REGS[REG_XPSR], CURRENT_REGS[REG_PRIMASK]); #endif (void)up_irq_save(); - _alert("PANIC!!! Hard fault\n"); + hfalert("PANIC!!! Hard fault\n"); PANIC(); return OK; /* Won't get here */ } diff --git a/arch/arm/src/armv7-m/up_hardfault.c b/arch/arm/src/armv7-m/up_hardfault.c index a68996836e..1f13c30b58 100644 --- a/arch/arm/src/armv7-m/up_hardfault.c +++ b/arch/arm/src/armv7-m/up_hardfault.c @@ -65,6 +65,13 @@ # define hfalert(x...) #endif +#ifdef CONFIG_DEBUG_HARDFAULT_INFO +# define hfinfo(format, ...) _info(format, ##__VA_ARGS__) +#else +# define hfinfo(x...) +#endif + + #define INSN_SVC0 0xdf00 /* insn: svc 0 */ /**************************************************************************** @@ -115,7 +122,7 @@ int up_hardfault(int irq, FAR void *context, FAR void *arg) /* Fetch the instruction that caused the Hard fault */ uint16_t insn = *pc; - hfalert(" PC: %p INSN: %04x\n", pc, insn); + hfinfo(" PC: %p INSN: %04x\n", pc, insn); /* If this was the instruction 'svc 0', then forward processing * to the SVCall handler @@ -123,7 +130,7 @@ int up_hardfault(int irq, FAR void *context, FAR void *arg) if (insn == INSN_SVC0) { - hfalert("Forward SVCall\n"); + hfinfo("Forward SVCall\n"); return up_svcall(irq, context, arg); } }