diff --git a/components/esp32c3/memprot.c b/components/esp32c3/memprot.c index 20cc054ad5..35251a8b90 100644 --- a/components/esp32c3/memprot.c +++ b/components/esp32c3/memprot.c @@ -28,6 +28,8 @@ #include "esp32c3/rom/ets_sys.h" #include "esp_log.h" +#include "soc/cpu.h" + extern int _iram_text_end; static const char *TAG = "memprot"; @@ -532,6 +534,11 @@ void esp_memprot_set_prot_int(bool invoke_panic_handler, bool lock_feature, void esp_memprot_set_monitor_en(MEMPROT_DRAM0_SRAM, false); } + // do not enable if being debugged + if (esp_cpu_in_ocd_debug_mode()) { + return; + } + //panic handling if (invoke_panic_handler) { if (use_iram0) {