kopia lustrzana https://github.com/espressif/esp-idf
Merge branch 'refactor/decouple-psram-init-from-essp-system' into 'master'
refactor(esp_psram): Decouple psram init from esp_system Closes IDF-8769 See merge request espressif/esp-idf!29042pull/12709/merge
commit
d0b97fbd6b
|
@ -27,7 +27,7 @@
|
||||||
#include "esp_psram.h"
|
#include "esp_psram.h"
|
||||||
#include "esp_private/esp_mmu_map_private.h"
|
#include "esp_private/esp_mmu_map_private.h"
|
||||||
#include "esp_mmu_map.h"
|
#include "esp_mmu_map.h"
|
||||||
|
#include "esp_private/startup_internal.h"
|
||||||
#if CONFIG_IDF_TARGET_ESP32
|
#if CONFIG_IDF_TARGET_ESP32
|
||||||
#include "esp32/himem.h"
|
#include "esp32/himem.h"
|
||||||
#include "esp32/rom/cache.h"
|
#include "esp32/rom/cache.h"
|
||||||
|
@ -82,6 +82,23 @@ typedef struct {
|
||||||
static psram_ctx_t s_psram_ctx;
|
static psram_ctx_t s_psram_ctx;
|
||||||
static const char* TAG = "esp_psram";
|
static const char* TAG = "esp_psram";
|
||||||
|
|
||||||
|
ESP_SYSTEM_INIT_FN(init_psram, CORE, BIT(0), 103)
|
||||||
|
{
|
||||||
|
#if CONFIG_SPIRAM_BOOT_INIT && (CONFIG_SPIRAM_USE_CAPS_ALLOC || CONFIG_SPIRAM_USE_MALLOC)
|
||||||
|
if (esp_psram_is_initialized()) {
|
||||||
|
esp_err_t r = esp_psram_extram_add_to_heap_allocator();
|
||||||
|
if (r != ESP_OK) {
|
||||||
|
ESP_EARLY_LOGE(TAG, "External RAM could not be added to heap!");
|
||||||
|
abort();
|
||||||
|
}
|
||||||
|
#if CONFIG_SPIRAM_USE_MALLOC
|
||||||
|
heap_caps_malloc_extmem_enable(CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
#if CONFIG_IDF_TARGET_ESP32
|
#if CONFIG_IDF_TARGET_ESP32
|
||||||
//If no function in esp_himem.c is used, this function will be linked into the
|
//If no function in esp_himem.c is used, this function will be linked into the
|
||||||
//binary instead of the one in esp_himem.c, automatically making sure no memory
|
//binary instead of the one in esp_himem.c, automatically making sure no memory
|
||||||
|
|
|
@ -44,11 +44,6 @@
|
||||||
#include "hal/brownout_ll.h"
|
#include "hal/brownout_ll.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if CONFIG_SPIRAM
|
|
||||||
#include "esp_psram.h"
|
|
||||||
#include "esp_private/esp_psram_extram.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Using the same tag as in startup.c to keep the logs unchanged
|
// Using the same tag as in startup.c to keep the logs unchanged
|
||||||
static const char* TAG = "cpu_start";
|
static const char* TAG = "cpu_start";
|
||||||
|
|
||||||
|
@ -68,23 +63,6 @@ ESP_SYSTEM_INIT_FN(init_show_cpu_freq, CORE, BIT(0), 10)
|
||||||
return ESP_OK;
|
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)
|
|
||||||
if (esp_psram_is_initialized()) {
|
|
||||||
esp_err_t r = esp_psram_extram_add_to_heap_allocator();
|
|
||||||
if (r != ESP_OK) {
|
|
||||||
ESP_EARLY_LOGE(TAG, "External RAM could not be added to heap!");
|
|
||||||
abort();
|
|
||||||
}
|
|
||||||
#if CONFIG_SPIRAM_USE_MALLOC
|
|
||||||
heap_caps_malloc_extmem_enable(CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
return ESP_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
ESP_SYSTEM_INIT_FN(init_brownout, CORE, BIT(0), 104)
|
ESP_SYSTEM_INIT_FN(init_brownout, CORE, BIT(0), 104)
|
||||||
{
|
{
|
||||||
// [refactor-todo] leads to call chain rtc_is_register (driver) -> esp_intr_alloc (esp32/esp32s2) ->
|
// [refactor-todo] leads to call chain rtc_is_register (driver) -> esp_intr_alloc (esp32/esp32s2) ->
|
||||||
|
|
|
@ -41,7 +41,7 @@ CORE: 100: init_heap in components/heap/heap_caps_init.c on BIT(0)
|
||||||
CORE: 101: esp_timer_init_nonos in components/esp_timer/src/esp_timer_init.c on BIT(0)
|
CORE: 101: esp_timer_init_nonos in components/esp_timer/src/esp_timer_init.c on BIT(0)
|
||||||
|
|
||||||
CORE: 102: init_newlib in components/newlib/newlib_init.c on BIT(0)
|
CORE: 102: init_newlib in components/newlib/newlib_init.c on BIT(0)
|
||||||
CORE: 103: init_psram_heap in components/esp_system/startup_funcs.c on BIT(0)
|
CORE: 103: init_psram in components/esp_psram/esp_psram.c on BIT(0)
|
||||||
CORE: 104: init_brownout in components/esp_system/startup_funcs.c on BIT(0)
|
CORE: 104: init_brownout in components/esp_system/startup_funcs.c on BIT(0)
|
||||||
CORE: 105: init_newlib_time in components/esp_system/startup_funcs.c on BIT(0)
|
CORE: 105: init_newlib_time in components/esp_system/startup_funcs.c on BIT(0)
|
||||||
|
|
||||||
|
|
Ładowanie…
Reference in New Issue