From 7234303e9e717b703af4cc3cf46206230842e9c1 Mon Sep 17 00:00:00 2001 From: Erhan Kurubas Date: Wed, 24 Jan 2024 01:41:18 +0100 Subject: [PATCH] feat(system): move esp_dbg_stubs_init into component --- components/app_trace/CMakeLists.txt | 5 +++++ components/{esp_system => app_trace}/debug_stubs.c | 9 ++++++++- components/app_trace/gcov/gcov_rtio.c | 2 +- .../private_include}/dbg_stubs.h | 0 components/esp_system/CMakeLists.txt | 3 +-- components/esp_system/startup_funcs.c | 10 ---------- components/esp_system/system_init_fn.txt | 4 +++- 7 files changed, 18 insertions(+), 15 deletions(-) rename components/{esp_system => app_trace}/debug_stubs.c (95%) rename components/{esp_system/include/esp_private => app_trace/private_include}/dbg_stubs.h (100%) diff --git a/components/app_trace/CMakeLists.txt b/components/app_trace/CMakeLists.txt index c4b31ca7dc..866ba9f72d 100644 --- a/components/app_trace/CMakeLists.txt +++ b/components/app_trace/CMakeLists.txt @@ -9,6 +9,11 @@ set(srcs "app_trace_util.c" "host_file_io.c") +if(CONFIG_ESP_DEBUG_STUBS_ENABLE) + list(APPEND srcs + "debug_stubs.c") +endif() + if(CONFIG_APPTRACE_GCOV_ENABLE) if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") list(APPEND srcs diff --git a/components/esp_system/debug_stubs.c b/components/app_trace/debug_stubs.c similarity index 95% rename from components/esp_system/debug_stubs.c rename to components/app_trace/debug_stubs.c index ae62049f05..2244c2db00 100644 --- a/components/esp_system/debug_stubs.c +++ b/components/app_trace/debug_stubs.c @@ -8,7 +8,8 @@ // Currently one stub is used for GCOV functionality // -#include "esp_private/dbg_stubs.h" +#include "esp_private/startup_internal.h" +#include "dbg_stubs.h" #include "esp_attr.h" /* @@ -92,3 +93,9 @@ esp_err_t esp_dbg_stub_entry_get(esp_dbg_stub_id_t id, uint32_t *entry) return ESP_OK; } + +ESP_SYSTEM_INIT_FN(init_dbg_stubs, SECONDARY, BIT(0), 140) +{ + esp_dbg_stubs_init(); + return ESP_OK; +} diff --git a/components/app_trace/gcov/gcov_rtio.c b/components/app_trace/gcov/gcov_rtio.c index 887440d780..c18d678cb9 100644 --- a/components/app_trace/gcov/gcov_rtio.c +++ b/components/app_trace/gcov/gcov_rtio.c @@ -14,7 +14,7 @@ #include "soc/timer_periph.h" #include "esp_app_trace.h" #include "esp_freertos_hooks.h" -#include "esp_private/dbg_stubs.h" +#include "dbg_stubs.h" #include "esp_ipc.h" #include "hal/wdt_hal.h" #if CONFIG_IDF_TARGET_ESP32 diff --git a/components/esp_system/include/esp_private/dbg_stubs.h b/components/app_trace/private_include/dbg_stubs.h similarity index 100% rename from components/esp_system/include/esp_private/dbg_stubs.h rename to components/app_trace/private_include/dbg_stubs.h diff --git a/components/esp_system/CMakeLists.txt b/components/esp_system/CMakeLists.txt index 78e7fe079e..0c8ab5d422 100644 --- a/components/esp_system/CMakeLists.txt +++ b/components/esp_system/CMakeLists.txt @@ -37,8 +37,7 @@ else() "system_time.c" "stack_check.c" "ubsan.c" - "xt_wdt.c" - "debug_stubs.c") + "xt_wdt.c") if(CONFIG_ESP_TASK_WDT_EN) list(APPEND srcs "task_wdt/task_wdt.c") diff --git a/components/esp_system/startup_funcs.c b/components/esp_system/startup_funcs.c index 8e399d8652..551cc6b11b 100644 --- a/components/esp_system/startup_funcs.c +++ b/components/esp_system/startup_funcs.c @@ -45,8 +45,6 @@ #include "esp_core_dump.h" #endif -#include "esp_private/dbg_stubs.h" - #if CONFIG_PM_ENABLE #include "esp_pm.h" #include "esp_private/pm_impl.h" @@ -273,14 +271,6 @@ ESP_SYSTEM_INIT_FN(init_xt_wdt, CORE, BIT(0), 170) } #endif // CONFIG_ESP_XT_WDT -#if CONFIG_ESP_DEBUG_STUBS_ENABLE -ESP_SYSTEM_INIT_FN(init_dbg_stubs, SECONDARY, BIT(0), 200) -{ - esp_dbg_stubs_init(); - return ESP_OK; -} -#endif // CONFIG_ESP_DEBUG_STUBS_ENABLE - #if CONFIG_PM_ENABLE ESP_SYSTEM_INIT_FN(init_pm, SECONDARY, BIT(0), 201) { diff --git a/components/esp_system/system_init_fn.txt b/components/esp_system/system_init_fn.txt index a8cfa09986..272957ee5a 100644 --- a/components/esp_system/system_init_fn.txt +++ b/components/esp_system/system_init_fn.txt @@ -75,9 +75,11 @@ SECONDARY: 107: sleep_sys_periph_startup_init in components/esp_hw_support/sleep SECONDARY: 115: esp_apptrace_init in components/app_trace/app_trace.c on ESP_SYSTEM_INIT_ALL_CORES SECONDARY: 120: sysview_init in components/app_trace/sys_view/esp/SEGGER_RTT_esp.c on BIT(0) +# esp_debug_stubs doesn't have init dependencies +SECONDARY: 140: init_dbg_stubs in components/app_trace/debug_stubs.c on BIT(0) + # the rest of the components which are initialized from startup_funcs.c # [refactor-todo]: move init calls into respective components -SECONDARY: 200: init_dbg_stubs in components/esp_system/startup_funcs.c on BIT(0) SECONDARY: 201: init_pm in components/esp_system/startup_funcs.c on BIT(0) SECONDARY: 202: init_coredump in components/esp_system/startup_funcs.c on BIT(0) SECONDARY: 203: init_apb_dma in components/esp_system/startup_funcs.c on BIT(0)