|
|
@@ -30,7 +30,6 @@
|
|
|
#include "esp_efuse.h"
|
|
|
#include "esp_flash_encrypt.h"
|
|
|
#include "esp_secure_boot.h"
|
|
|
-#include "esp_sleep.h"
|
|
|
#include "esp_xt_wdt.h"
|
|
|
|
|
|
#if __has_include("esp_ota_ops.h")
|
|
|
@@ -48,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
|
|
|
@@ -179,17 +174,25 @@ static void do_global_ctors(void)
|
|
|
|
|
|
#if __riscv
|
|
|
for (p = &__init_priority_array_start; p < &__init_priority_array_end; ++p) {
|
|
|
- ESP_EARLY_LOGD(TAG, "calling init function: %p", *p);
|
|
|
+ ESP_LOGD(TAG, "calling init function: %p", *p);
|
|
|
(*p)();
|
|
|
}
|
|
|
#endif
|
|
|
|
|
|
for (p = &__init_array_end - 1; p >= &__init_array_start; --p) {
|
|
|
- ESP_EARLY_LOGD(TAG, "calling init function: %p", *p);
|
|
|
+ ESP_LOGD(TAG, "calling init function: %p", *p);
|
|
|
(*p)();
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+/**
|
|
|
+ * @brief Call component init functions defined using ESP_SYSTEM_INIT_Fn macros.
|
|
|
+ * The esp_system_init_fn_t structures describing these functions are collected into
|
|
|
+ * an array [_esp_system_init_fn_array_start, _esp_system_init_fn_array_end) by the
|
|
|
+ * linker. The functions are sorted by their priority value.
|
|
|
+ * The sequence of the init function calls (sorted by priority) is documented in
|
|
|
+ * system_init_fn.txt file.
|
|
|
+ */
|
|
|
static void do_system_init_fn(void)
|
|
|
{
|
|
|
extern esp_system_init_fn_t _esp_system_init_fn_array_start;
|
|
|
@@ -197,14 +200,20 @@ static void do_system_init_fn(void)
|
|
|
|
|
|
esp_system_init_fn_t *p;
|
|
|
|
|
|
- for (p = &_esp_system_init_fn_array_end - 1; p >= &_esp_system_init_fn_array_start; --p) {
|
|
|
- if (p->cores & BIT(cpu_hal_get_core_id())) {
|
|
|
- (*(p->fn))();
|
|
|
+ int core_id = cpu_hal_get_core_id();
|
|
|
+ for (p = &_esp_system_init_fn_array_start; p < &_esp_system_init_fn_array_end; ++p) {
|
|
|
+ if (p->cores & BIT(core_id)) {
|
|
|
+ ESP_LOGD(TAG, "calling init function: %p on core: %d", p->fn, core_id);
|
|
|
+ esp_err_t err = (*(p->fn))();
|
|
|
+ if (err != ESP_OK) {
|
|
|
+ ESP_LOGE(TAG, "init function %p has failed (0x%x), aborting", p->fn, err);
|
|
|
+ abort();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
#if !CONFIG_ESP_SYSTEM_SINGLE_CORE_MODE
|
|
|
- s_system_inited[cpu_hal_get_core_id()] = true;
|
|
|
+ s_system_inited[core_id] = true;
|
|
|
#endif
|
|
|
}
|
|
|
|
|
|
@@ -216,6 +225,9 @@ static void esp_startup_start_app_other_cores_default(void)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+/* This function has to be in IRAM, as while it is running on CPU1, CPU0 may do some flash operations
|
|
|
+ * (e.g. initialize the core dump), which means that cache will be disabled.
|
|
|
+ */
|
|
|
static void IRAM_ATTR start_cpu_other_cores_default(void)
|
|
|
{
|
|
|
do_system_init_fn();
|
|
|
@@ -428,26 +440,8 @@ static void start_cpu0_default(void)
|
|
|
while (1);
|
|
|
}
|
|
|
|
|
|
-IRAM_ATTR ESP_SYSTEM_INIT_FN(init_components0, BIT(0))
|
|
|
+ESP_SYSTEM_INIT_FN(init_components0, BIT(0), 200)
|
|
|
{
|
|
|
- esp_timer_init();
|
|
|
-
|
|
|
-#if CONFIG_ESP_SLEEP_GPIO_RESET_WORKAROUND && !CONFIG_PM_SLP_DISABLE_GPIO
|
|
|
- // Configure to isolate (disable the Input/Output/Pullup/Pulldown
|
|
|
- // function of the pin) all GPIO pins in sleep state
|
|
|
- esp_sleep_config_gpio_isolate();
|
|
|
- // Enable automatic switching of GPIO configuration
|
|
|
- esp_sleep_enable_gpio_switch(true);
|
|
|
-#endif
|
|
|
-
|
|
|
-#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
|
|
|
@@ -474,4 +468,6 @@ IRAM_ATTR ESP_SYSTEM_INIT_FN(init_components0, BIT(0))
|
|
|
_Unwind_SetNoFunctionContextInstall(1);
|
|
|
_Unwind_SetEnableExceptionFdeSorting(0);
|
|
|
#endif // CONFIG_COMPILER_CXX_EXCEPTIONS
|
|
|
+
|
|
|
+ return ESP_OK;
|
|
|
}
|