diff --git a/components/esp_system/startup_funcs.c b/components/esp_system/startup_funcs.c index ecd5d20943..db6509889b 100644 --- a/components/esp_system/startup_funcs.c +++ b/components/esp_system/startup_funcs.c @@ -13,7 +13,6 @@ #include "esp_check.h" #include "esp_system.h" #include "esp_log.h" -#include "esp_heap_caps_init.h" #include "spi_flash_mmap.h" #include "esp_flash_internal.h" #include "esp_newlib.h" @@ -69,12 +68,6 @@ ESP_SYSTEM_INIT_FN(init_show_cpu_freq, CORE, BIT(0), 10) return ESP_OK; } -ESP_SYSTEM_INIT_FN(init_heap, CORE, BIT(0), 100) -{ - heap_caps_init(); - return ESP_OK; -} - ESP_SYSTEM_INIT_FN(init_psram_heap, CORE, BIT(0), 103) { #if CONFIG_SPIRAM_BOOT_INIT && (CONFIG_SPIRAM_USE_CAPS_ALLOC || CONFIG_SPIRAM_USE_MALLOC) diff --git a/components/esp_system/system_init_fn.txt b/components/esp_system/system_init_fn.txt index 73054148e7..beb3c458df 100644 --- a/components/esp_system/system_init_fn.txt +++ b/components/esp_system/system_init_fn.txt @@ -32,7 +32,7 @@ CORE: 21: init_efuse_show_app_info in components/efuse/src/esp_efuse_startup.c # With SPI RAM enabled, there's a second reason: half of the SPI RAM will be managed by the # app CPU, and when that is not up yet, the memory will be inaccessible and heap_caps_init may # fail initializing it properly. -CORE: 100: init_heap in components/esp_system/startup_funcs.c on BIT(0) +CORE: 100: init_heap in components/heap/heap_caps_init.c on BIT(0) # When apptrace module is enabled, there will be SEGGER_SYSVIEW calls in the newlib init. # SEGGER_SYSVIEW relies on apptrace module diff --git a/components/heap/heap_caps_init.c b/components/heap/heap_caps_init.c index 134378af00..3e842367d2 100644 --- a/components/heap/heap_caps_init.c +++ b/components/heap/heap_caps_init.c @@ -1,5 +1,5 @@ /* - * SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD + * SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD * * SPDX-License-Identifier: Apache-2.0 */ @@ -14,11 +14,19 @@ #include "esp_heap_caps_init.h" #include "heap_memory_layout.h" +#include "esp_private/startup_internal.h" + static const char *TAG = "heap_init"; /* Linked-list of registered heaps */ struct registered_heap_ll registered_heaps; +ESP_SYSTEM_INIT_FN(init_heap, CORE, BIT(0), 100) +{ + heap_caps_init(); + return ESP_OK; +} + static void register_heap(heap_t *region) { size_t heap_size = region->end - region->start;