From bc289f92d894fffd5465a10a3fc05865b6f4e213 Mon Sep 17 00:00:00 2001 From: Erhan Kurubas Date: Sun, 14 Dec 2025 22:31:25 +0100 Subject: [PATCH] refactor(hal): update assist_debug_ll_reset_register() to pass core_id --- components/esp_system/hw_stack_guard.c | 4 ++-- .../hal/esp32c2/include/hal/assist_debug_ll.h | 2 +- .../hal/esp32c3/include/hal/assist_debug_ll.h | 2 +- .../hal/esp32c5/include/hal/assist_debug_ll.h | 2 +- .../hal/esp32c6/include/hal/assist_debug_ll.h | 2 +- .../hal/esp32c61/include/hal/assist_debug_ll.h | 2 +- .../hal/esp32h2/include/hal/assist_debug_ll.h | 2 +- .../hal/esp32p4/include/hal/assist_debug_ll.h | 16 +++++++--------- 8 files changed, 15 insertions(+), 17 deletions(-) diff --git a/components/esp_system/hw_stack_guard.c b/components/esp_system/hw_stack_guard.c index 06040d85fa1..61774288c82 100644 --- a/components/esp_system/hw_stack_guard.c +++ b/components/esp_system/hw_stack_guard.c @@ -22,7 +22,7 @@ ESP_SYSTEM_INIT_FN(esp_hw_stack_guard_init, SECONDARY, ESP_SYSTEM_INIT_ALL_CORES #endif { assist_debug_ll_enable_bus_clock(true); - assist_debug_ll_reset_register(); + assist_debug_ll_reset_register(core_id); } /* set interrupt to matrix */ @@ -38,7 +38,7 @@ ESP_SYSTEM_INIT_FN(esp_hw_stack_guard_init, SECONDARY, ESP_SYSTEM_INIT_ALL_CORES * - trigger event happened * - you get an interrupt right after enabling interrupts * So, use monitor to disable hw_guard to avoid false-positives. - * And keep interrupt always enabled for better performace (don't spend cpu time for enable/disable) + * And keep interrupt always enabled for better performance (don't spend cpu time for enable/disable) */ assist_debug_hal_sp_int_enable(core_id); diff --git a/components/hal/esp32c2/include/hal/assist_debug_ll.h b/components/hal/esp32c2/include/hal/assist_debug_ll.h index 18b375fdb17..1fc98f882df 100644 --- a/components/hal/esp32c2/include/hal/assist_debug_ll.h +++ b/components/hal/esp32c2/include/hal/assist_debug_ll.h @@ -119,7 +119,7 @@ FORCE_INLINE_ATTR void assist_debug_ll_enable_bus_clock(bool enable) SYSTEM.cpu_peri_clk_en.clk_en_assist_debug = enable; } -FORCE_INLINE_ATTR void assist_debug_ll_reset_register(void) +FORCE_INLINE_ATTR void assist_debug_ll_reset_register(__attribute__((unused)) uint32_t core_id) { SYSTEM.cpu_peri_rst_en.rst_en_assist_debug = true; SYSTEM.cpu_peri_rst_en.rst_en_assist_debug = false; diff --git a/components/hal/esp32c3/include/hal/assist_debug_ll.h b/components/hal/esp32c3/include/hal/assist_debug_ll.h index 978cbde323a..b0fabe37df8 100644 --- a/components/hal/esp32c3/include/hal/assist_debug_ll.h +++ b/components/hal/esp32c3/include/hal/assist_debug_ll.h @@ -119,7 +119,7 @@ FORCE_INLINE_ATTR void assist_debug_ll_enable_bus_clock(bool enable) SYSTEM.cpu_peri_clk_en.reg_clk_en_assist_debug = enable; } -FORCE_INLINE_ATTR void assist_debug_ll_reset_register(void) +FORCE_INLINE_ATTR void assist_debug_ll_reset_register(__attribute__((unused)) uint32_t core_id) { SYSTEM.cpu_peri_rst_en.reg_rst_en_assist_debug = true; SYSTEM.cpu_peri_rst_en.reg_rst_en_assist_debug = false; diff --git a/components/hal/esp32c5/include/hal/assist_debug_ll.h b/components/hal/esp32c5/include/hal/assist_debug_ll.h index 646a1ccbe81..aaca9d9ae28 100644 --- a/components/hal/esp32c5/include/hal/assist_debug_ll.h +++ b/components/hal/esp32c5/include/hal/assist_debug_ll.h @@ -121,7 +121,7 @@ FORCE_INLINE_ATTR void assist_debug_ll_enable_bus_clock(bool enable) PCR.assist_conf.assist_clk_en = enable; } -FORCE_INLINE_ATTR void assist_debug_ll_reset_register(void) +FORCE_INLINE_ATTR void assist_debug_ll_reset_register(__attribute__((unused)) uint32_t core_id) { PCR.assist_conf.assist_rst_en = true; PCR.assist_conf.assist_rst_en = false; diff --git a/components/hal/esp32c6/include/hal/assist_debug_ll.h b/components/hal/esp32c6/include/hal/assist_debug_ll.h index b864e8ffb1e..8e19c09377f 100644 --- a/components/hal/esp32c6/include/hal/assist_debug_ll.h +++ b/components/hal/esp32c6/include/hal/assist_debug_ll.h @@ -119,7 +119,7 @@ FORCE_INLINE_ATTR void assist_debug_ll_enable_bus_clock(bool enable) PCR.assist_conf.assist_clk_en = enable; } -FORCE_INLINE_ATTR void assist_debug_ll_reset_register(void) +FORCE_INLINE_ATTR void assist_debug_ll_reset_register(__attribute__((unused)) uint32_t core_id) { PCR.assist_conf.assist_rst_en = true; PCR.assist_conf.assist_rst_en = false; diff --git a/components/hal/esp32c61/include/hal/assist_debug_ll.h b/components/hal/esp32c61/include/hal/assist_debug_ll.h index 784e5906110..fd476e6dc4d 100644 --- a/components/hal/esp32c61/include/hal/assist_debug_ll.h +++ b/components/hal/esp32c61/include/hal/assist_debug_ll.h @@ -121,7 +121,7 @@ FORCE_INLINE_ATTR void assist_debug_ll_enable_bus_clock(bool enable) PCR.assist_conf.assist_clk_en = enable; } -FORCE_INLINE_ATTR void assist_debug_ll_reset_register(void) +FORCE_INLINE_ATTR void assist_debug_ll_reset_register(__attribute__((unused)) uint32_t core_id) { PCR.assist_conf.assist_rst_en = true; PCR.assist_conf.assist_rst_en = false; diff --git a/components/hal/esp32h2/include/hal/assist_debug_ll.h b/components/hal/esp32h2/include/hal/assist_debug_ll.h index b864e8ffb1e..8e19c09377f 100644 --- a/components/hal/esp32h2/include/hal/assist_debug_ll.h +++ b/components/hal/esp32h2/include/hal/assist_debug_ll.h @@ -119,7 +119,7 @@ FORCE_INLINE_ATTR void assist_debug_ll_enable_bus_clock(bool enable) PCR.assist_conf.assist_clk_en = enable; } -FORCE_INLINE_ATTR void assist_debug_ll_reset_register(void) +FORCE_INLINE_ATTR void assist_debug_ll_reset_register(__attribute__((unused)) uint32_t core_id) { PCR.assist_conf.assist_rst_en = true; PCR.assist_conf.assist_rst_en = false; diff --git a/components/hal/esp32p4/include/hal/assist_debug_ll.h b/components/hal/esp32p4/include/hal/assist_debug_ll.h index 765a2b453dd..677d25ba317 100644 --- a/components/hal/esp32p4/include/hal/assist_debug_ll.h +++ b/components/hal/esp32p4/include/hal/assist_debug_ll.h @@ -124,17 +124,15 @@ FORCE_INLINE_ATTR void _assist_debug_ll_enable_bus_clock(bool enable) #define assist_debug_ll_enable_bus_clock(...) \ (void)__DECLARE_RCC_ATOMIC_ENV; _assist_debug_ll_enable_bus_clock(__VA_ARGS__) -FORCE_INLINE_ATTR void _assist_debug_ll_reset_register(void) +FORCE_INLINE_ATTR void _assist_debug_ll_reset_register(uint32_t core_id) { /* esp32p4 has no assist_debug reset register: disable & clear interrupts manually. */ - for (int i = 0; i < SOC_CPU_CORES_NUM; i++) { - assist_debug_ll_sp_spill_monitor_disable(i); - assist_debug_ll_sp_spill_interrupt_clear(i); - assist_debug_ll_sp_spill_set_min(i, 0); - assist_debug_ll_sp_spill_set_max(i, 0xffffffff); - /* Enable PC register storing when trigger stack monitor. */ - REG_WRITE(i ? ASSIST_DEBUG_CORE_1_RCD_EN_REG : ASSIST_DEBUG_CORE_0_RCD_EN_REG, ASSIST_DEBUG_CORE_1_RCD_PDEBUGEN | ASSIST_DEBUG_CORE_1_RCD_RECORDEN); - } + assist_debug_ll_sp_spill_monitor_disable(core_id); + assist_debug_ll_sp_spill_interrupt_clear(core_id); + assist_debug_ll_sp_spill_set_min(core_id, 0); + assist_debug_ll_sp_spill_set_max(core_id, 0xffffffff); + /* Enable PC register storing when trigger stack monitor. */ + REG_WRITE(core_id ? ASSIST_DEBUG_CORE_1_RCD_EN_REG : ASSIST_DEBUG_CORE_0_RCD_EN_REG, ASSIST_DEBUG_CORE_1_RCD_PDEBUGEN | ASSIST_DEBUG_CORE_1_RCD_RECORDEN); } #define assist_debug_ll_reset_register(...) \ (void)__DECLARE_RCC_ATOMIC_ENV; _assist_debug_ll_reset_register(__VA_ARGS__)