فهرست منبع

app_trace: perform initialization using ESP_SYSTEM_INIT_FN

Ivan Grokhotkov 3 سال پیش
والد
کامیت
a334cd50ce

+ 6 - 0
components/app_trace/app_trace.c

@@ -8,6 +8,7 @@
 #include "esp_log.h"
 #include "esp_app_trace.h"
 #include "esp_app_trace_port.h"
+#include "esp_private/startup_internal.h"
 
 #ifdef CONFIG_APPTRACE_DEST_UART0
 #define ESP_APPTRACE_DEST_UART_NUM 0
@@ -75,6 +76,11 @@ esp_err_t esp_apptrace_init(void)
     return ESP_OK;
 }
 
+ESP_SYSTEM_INIT_FN(esp_apptrace_init, ESP_SYSTEM_INIT_ALL_CORES, 115)
+{
+    return esp_apptrace_init();
+}
+
 void esp_apptrace_down_buffer_config(uint8_t *buf, uint32_t size)
 {
     esp_apptrace_channel_t *ch;

+ 14 - 0
components/app_trace/sys_view/esp/SEGGER_RTT_esp.c

@@ -12,6 +12,7 @@
 
 #include "esp_app_trace.h"
 #include "esp_log.h"
+#include "esp_private/startup_internal.h"
 
 const static char *TAG = "segger_rtt";
 
@@ -288,4 +289,17 @@ int SEGGER_RTT_ConfigDownBuffer(unsigned BufferIndex, const char* sName, void* p
   return 0;
 }
 
+/*************************** Init hook ****************************
+ *
+ * This init function is placed here because this port file will be
+ * linked whenever SystemView is used.
+ */
+
+ESP_SYSTEM_INIT_FN(sysview_init, BIT(0), 120)
+{
+    SEGGER_SYSVIEW_Conf();
+    return ESP_OK;
+}
+
+
 /*************************** End of file ****************************/

+ 0 - 13
components/esp_system/startup.c

@@ -47,10 +47,6 @@
 #include "esp_core_dump.h"
 #endif
 
-#if CONFIG_APPTRACE_ENABLE
-#include "esp_app_trace.h"
-#endif
-
 #include "esp_private/dbg_stubs.h"
 
 #if CONFIG_PM_ENABLE
@@ -446,15 +442,6 @@ static void start_cpu0_default(void)
 
 ESP_SYSTEM_INIT_FN(init_components0, BIT(0), 200)
 {
-
-#if CONFIG_APPTRACE_ENABLE
-    esp_err_t err = esp_apptrace_init();
-    assert(err == ESP_OK && "Failed to init apptrace module on PRO CPU!");
-#endif
-#if CONFIG_APPTRACE_SV_ENABLE
-    SEGGER_SYSVIEW_Conf();
-#endif
-
 #if CONFIG_ESP_DEBUG_STUBS_ENABLE
     esp_dbg_stubs_init();
 #endif

+ 4 - 0
components/esp_system/system_init_fn.txt

@@ -19,6 +19,10 @@
 # esp_sleep doesn't have init dependencies
 105: esp_sleep_startup_init in components/esp_hw_support/sleep_modes.c on BIT(0)
 
+# app_trace has to be initialized before systemview
+115: esp_apptrace_init in components/app_trace/app_trace.c on ESP_SYSTEM_INIT_ALL_CORES
+120: sysview_init in components/app_trace/sys_view/esp/SEGGER_RTT_esp.c on BIT(0)
+
 # the rest of the components which are initialized from startup.c
 # [refactor-todo]: move init calls into respective components
 200: init_components0 in components/esp_system/startup.c on BIT(0)