From 440c4a28d787b82799dcfdc747d98290bc29eea0 Mon Sep 17 00:00:00 2001 From: Alexey Gerenkov Date: Thu, 4 Feb 2021 01:13:10 +0300 Subject: [PATCH] hal/esp32c3: Avoid entering WFI mode under debugger --- components/hal/esp32c3/include/hal/cpu_ll.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/components/hal/esp32c3/include/hal/cpu_ll.h b/components/hal/esp32c3/include/hal/cpu_ll.h index 0ac34b16e6..ab3ab17685 100644 --- a/components/hal/esp32c3/include/hal/cpu_ll.h +++ b/components/hal/esp32c3/include/hal/cpu_ll.h @@ -16,6 +16,8 @@ #include #include "soc/soc_caps.h" +#include "soc/dport_access.h" +#include "soc/system_reg.h" #include "esp_bit_defs.h" #include "soc/assist_debug_reg.h" #include "esp_attr.h" @@ -197,6 +199,11 @@ static inline void cpu_ll_set_vecbase(const void* vecbase) static inline void cpu_ll_waiti(void) { + if (cpu_ll_is_debugger_attached() && DPORT_REG_GET_BIT(SYSTEM_CPU_PER_CONF_REG, SYSTEM_CPU_WAIT_MODE_FORCE_ON) == 0) { + /* when SYSTEM_CPU_WAIT_MODE_FORCE_ON is disabled in WFI mode SBA access to memory does not work for debugger, + so do not enter that mode when debugger is connected */ + return; + } asm volatile ("wfi\n"); }