refactor(heap): decouple heap_init from esp_system

This commit is contained in:
Guillaume Souchere 2024-02-12 11:10:33 +01:00
parent 5f85aefe0d
commit e2144e01c1
3 changed files with 10 additions and 9 deletions

View File

@ -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)

View File

@ -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

View File

@ -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;