diff --git a/components/esp32/cpu_start.c b/components/esp32/cpu_start.c index 27f646c31..d344268ba 100644 --- a/components/esp32/cpu_start.c +++ b/components/esp32/cpu_start.c @@ -172,7 +172,6 @@ void IRAM_ATTR call_start_cpu0(void) } #if CONFIG_SPIRAM_BOOT_INIT - esp_spiram_init_cache(); if (esp_spiram_init() != ESP_OK) { #if CONFIG_SPIRAM_ALLOW_BSS_SEG_EXTERNAL_MEMORY ESP_EARLY_LOGE(TAG, "Failed to init external RAM, needed for external .bss segment"); @@ -187,6 +186,7 @@ void IRAM_ATTR call_start_cpu0(void) abort(); #endif } + esp_spiram_init_cache(); #endif ESP_EARLY_LOGI(TAG, "Pro cpu up."); diff --git a/components/esp32/spiram.c b/components/esp32/spiram.c index bb250908c..c1bd976a1 100644 --- a/components/esp32/spiram.c +++ b/components/esp32/spiram.c @@ -127,7 +127,7 @@ esp_spiram_size_t esp_spiram_get_chip_size(void) { if (!spiram_inited) { ESP_EARLY_LOGE(TAG, "SPI RAM not initialized"); - return ESP_SPIRAM_SIZE_INVALID; + abort(); } psram_size_t psram_size = psram_get_size(); switch (psram_size) { diff --git a/components/esp32s2/spiram.c b/components/esp32s2/spiram.c index 89a6367c5..fdb476615 100644 --- a/components/esp32s2/spiram.c +++ b/components/esp32s2/spiram.c @@ -300,6 +300,7 @@ esp_err_t esp_spiram_init(void) return r; } + spiram_inited=true; #if (CONFIG_SPIRAM_SIZE != -1) if (esp_spiram_get_size()!=CONFIG_SPIRAM_SIZE) { ESP_EARLY_LOGE(TAG, "Expected %dKiB chip but found %dKiB chip. Bailing out..", CONFIG_SPIRAM_SIZE/1024, esp_spiram_get_size()/1024); @@ -315,7 +316,6 @@ esp_err_t esp_spiram_init(void) (PSRAM_MODE==PSRAM_VADDR_MODE_EVENODD)?"even/odd (2-core)": \ (PSRAM_MODE==PSRAM_VADDR_MODE_LOWHIGH)?"low/high (2-core)": \ (PSRAM_MODE==PSRAM_VADDR_MODE_NORMAL)?"normal (1-core)":"ERROR"); - spiram_inited=true; return ESP_OK; } @@ -386,6 +386,11 @@ esp_err_t esp_spiram_reserve_dma_pool(size_t size) { size_t esp_spiram_get_size(void) { + if (!spiram_inited) { + ESP_EARLY_LOGE(TAG, "SPI RAM not initialized"); + abort(); + } + psram_size_t size=psram_get_size(); if (size==PSRAM_SIZE_16MBITS) return 2*1024*1024; if (size==PSRAM_SIZE_32MBITS) return 4*1024*1024;