diff --git a/components/esp_system/startup.c b/components/esp_system/startup.c index dfb7e75c4b..cb87153ec0 100644 --- a/components/esp_system/startup.c +++ b/components/esp_system/startup.c @@ -447,8 +447,6 @@ static void start_cpu0_default(void) 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 diff --git a/components/esp_system/system_init_fn.txt b/components/esp_system/system_init_fn.txt index 426f99eb95..0b91c17853 100644 --- a/components/esp_system/system_init_fn.txt +++ b/components/esp_system/system_init_fn.txt @@ -13,6 +13,9 @@ # affinity_expression: bit map of cores the function is executed on +# esp_timer has to be initialized early, since it is used by several other components +100: esp_timer_startup_init in components/esp_timer/src/esp_timer.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) diff --git a/components/esp_timer/src/esp_timer.c b/components/esp_timer/src/esp_timer.c index ff2e6bd322..3ca19f642f 100644 --- a/components/esp_timer/src/esp_timer.c +++ b/components/esp_timer/src/esp_timer.c @@ -460,6 +460,11 @@ out: return ESP_ERR_NO_MEM; } +ESP_SYSTEM_INIT_FN(esp_timer_startup_init, BIT(0), 100) +{ + return esp_timer_init(); +} + esp_err_t esp_timer_deinit(void) { if (!is_initialized()) {