From 7fa0af01cfad9357b0b6e1246ac3fb1f473c1dd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Piotr=20Jasi=C5=84ski?= Date: Tue, 22 Nov 2022 08:29:03 +0100 Subject: [PATCH] Kconfig: add config for low-priority debug mon isr MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Debug monitor needs to be configured to a low priority in order to be useful for debugging (to prioritize other interrupts when waiting on a breakpoint). Added a config that configures the interrupt this way. Signed-off-by: Piotr JasiƄski --- arch/arm/core/aarch32/cortex_m/Kconfig | 8 +++++++- arch/arm/include/aarch32/cortex_m/exc.h | 4 +++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/arch/arm/core/aarch32/cortex_m/Kconfig b/arch/arm/core/aarch32/cortex_m/Kconfig index 5c8bfad88ae..169d5bc838d 100644 --- a/arch/arm/core/aarch32/cortex_m/Kconfig +++ b/arch/arm/core/aarch32/cortex_m/Kconfig @@ -352,7 +352,13 @@ config CORTEX_M_DWT Enable and use the Data Watchpoint and Trace (DWT) unit for timing functions. -# Additional stack for tests when building with FPU_SHARING +config CORTEX_M_DEBUG_MONITOR_HOOK + bool "Debug monitor interrupt for debugging" + depends on !ARMV6_M_ARMV8_M_BASELINE + help + Enable this option to configure debug monitor exception to low priority + for debugging purposes. + # enabled, which may increase ESF stacking requirements for # threads. config TEST_EXTRA_STACK_SIZE diff --git a/arch/arm/include/aarch32/cortex_m/exc.h b/arch/arm/include/aarch32/cortex_m/exc.h index b0cc623c5a7..b4f1b6cd8f7 100644 --- a/arch/arm/include/aarch32/cortex_m/exc.h +++ b/arch/arm/include/aarch32/cortex_m/exc.h @@ -112,7 +112,9 @@ static ALWAYS_INLINE void z_arm_exc_setup(void) NVIC_SetPriority(MemoryManagement_IRQn, _EXC_FAULT_PRIO); NVIC_SetPriority(BusFault_IRQn, _EXC_FAULT_PRIO); NVIC_SetPriority(UsageFault_IRQn, _EXC_FAULT_PRIO); -#if defined(CONFIG_CPU_CORTEX_M_HAS_DWT) +#if defined(CONFIG_CORTEX_M_DEBUG_MONITOR_HOOK) + NVIC_SetPriority(DebugMonitor_IRQn, IRQ_PRIO_LOWEST); +#elif defined(CONFIG_CPU_CORTEX_M_HAS_DWT) NVIC_SetPriority(DebugMonitor_IRQn, _EXC_FAULT_PRIO); #endif #if defined(CONFIG_ARM_SECURE_FIRMWARE)