From 3b15cae493cd4658cf154a53759ee749756603be Mon Sep 17 00:00:00 2001 From: Masayuki Ishikawa Date: Tue, 24 Jul 2018 11:42:54 +0000 Subject: [PATCH] Merged in masayuki2009/nuttx.nuttx/debug_memfault (pull request #693) arch/arm: Add CONFIG_DEBUG_MEMFAULT to Kconfig Also, fix src/armv7-m/up_memfault.c Signed-off-by: Masayuki Ishikawa Approved-by: GregoryN --- arch/arm/Kconfig | 9 +++++++++ arch/arm/src/armv7-m/up_memfault.c | 10 ++++++---- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 3f9ddf3f4d..960c05daad 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -735,6 +735,15 @@ 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_MEMFAULT + bool "Verbose Mem-Fault Debug" + default n + depends on DEBUG_FEATURES && ARCH_USE_MPU + ---help--- + Enables verbose debug output when a mem fault is occurs. This verbose + output is sometimes helpful when debugging difficult mem fault problems, + but may be more than you typically want to see. + if ARCH_CORTEXM0 source arch/arm/src/armv6-m/Kconfig endif diff --git a/arch/arm/src/armv7-m/up_memfault.c b/arch/arm/src/armv7-m/up_memfault.c index f4f642e4de..ee90cef710 100644 --- a/arch/arm/src/armv7-m/up_memfault.c +++ b/arch/arm/src/armv7-m/up_memfault.c @@ -52,9 +52,7 @@ * Pre-processor Definitions ****************************************************************************/ -#undef DEBUG_MEMFAULTS /* Define to debug memory management faults */ - -#ifdef DEBUG_MEMFAULTS +#ifdef CONFIG_DEBUG_MEMFAULT # define mferr(format, ...) _alert(format, ##__VA_ARGS__) # define mfinfo(format, ...) _alert(format, ##__VA_ARGS__) #else @@ -79,11 +77,15 @@ int up_memfault(int irq, FAR void *context, FAR void *arg) { +#if defined(CONFIG_DEBUG_MEMFAULT) + uint32_t *regs = (uint32_t *)context; +#endif + /* Dump some memory management fault info */ (void)up_irq_save(); _alert("PANIC!!! Memory Management Fault:\n"); - mfinfo(" IRQ: %d context: %p\n", irq, regs); + mfinfo(" IRQ: %d context: %p\n", irq, context); _alert(" CFAULTS: %08x MMFAR: %08x\n", getreg32(NVIC_CFAULTS), getreg32(NVIC_MEMMANAGE_ADDR)); mfinfo(" BASEPRI: %08x PRIMASK: %08x IPSR: %08x CONTROL: %08x\n",