From 224860bc9cb7109a43cb19eb32df97b99ca9cc7b Mon Sep 17 00:00:00 2001 From: Erhan Kurubas Date: Sat, 27 Feb 2021 23:55:28 +0300 Subject: [PATCH] esp32c3: Call rtos `post_reset_cleanup` method after reset Close https://github.com/espressif/openocd-esp32/issues/144 --- src/target/esp32c3.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/target/esp32c3.c b/src/target/esp32c3.c index ad4f6234da..41b3dfdfd4 100644 --- a/src/target/esp32c3.c +++ b/src/target/esp32c3.c @@ -28,6 +28,7 @@ #include "semihosting_common.h" #include "riscv/debug_defines.h" #include "esp32_apptrace.h" +#include "rtos/rtos.h" #define ESP_RISCV_APPTRACE_SYSNR 0x64 @@ -284,6 +285,12 @@ static int esp32c3_poll(struct target *target) } else LOG_ERROR("Failed to halt core (%d)!", res); } + /* Clear memory which is used by RTOS layer to get the task count */ + if (target->rtos && target->rtos->type->post_reset_cleanup) { + res = (*target->rtos->type->post_reset_cleanup)(target); + if (res != ERROR_OK) + LOG_WARNING("Failed to do rtos-specific cleanup (%d)", res); + } /* enable ebreaks */ res = esp32c3_core_ebreaks_enable(target); if (res != ERROR_OK)