Merge branch 'feature/ignore_no_psram' into 'master'
Add option to continue running (with less ram) if psram is enabled but not detected See merge request idf/esp-idf!1911
This commit is contained in:
commit
d1559732b0
3 changed files with 38 additions and 15 deletions
|
@ -45,6 +45,15 @@ config SPIRAM_BOOT_INIT
|
||||||
have specific requirements, you'll want to leave this enabled so memory allocated
|
have specific requirements, you'll want to leave this enabled so memory allocated
|
||||||
during boot-up can also be placed in SPI RAM.
|
during boot-up can also be placed in SPI RAM.
|
||||||
|
|
||||||
|
config SPIRAM_IGNORE_NOTFOUND
|
||||||
|
bool "Ignore PSRAM when not found"
|
||||||
|
default "n"
|
||||||
|
depends on SPIRAM_BOOT_INIT
|
||||||
|
help
|
||||||
|
Normally, if psram initialization is enabled during compile time but not found at runtime, it
|
||||||
|
is seen as an error making the ESP32 panic. If this is enabled, the ESP32 will keep on
|
||||||
|
running but will not add the (non-existing) RAM to any allocator.
|
||||||
|
|
||||||
choice SPIRAM_USE
|
choice SPIRAM_USE
|
||||||
prompt "SPI RAM access method"
|
prompt "SPI RAM access method"
|
||||||
default SPIRAM_USE_MALLOC
|
default SPIRAM_USE_MALLOC
|
||||||
|
|
|
@ -102,6 +102,9 @@ struct object { long placeholder[ 10 ]; };
|
||||||
void __register_frame_info (const void *begin, struct object *ob);
|
void __register_frame_info (const void *begin, struct object *ob);
|
||||||
extern char __eh_frame[];
|
extern char __eh_frame[];
|
||||||
|
|
||||||
|
//If CONFIG_SPIRAM_IGNORE_NOTFOUND is set and external RAM is not found or errors out on testing, this is set to false.
|
||||||
|
static bool s_spiram_okay=true;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We arrive here after the bootloader finished loading the program from flash. The hardware is mostly uninitialized,
|
* We arrive here after the bootloader finished loading the program from flash. The hardware is mostly uninitialized,
|
||||||
* and the app CPU is in reset. We do have a stack, so we can do the initialization in C.
|
* and the app CPU is in reset. We do have a stack, so we can do the initialization in C.
|
||||||
|
@ -147,8 +150,13 @@ void IRAM_ATTR call_start_cpu0()
|
||||||
#if CONFIG_SPIRAM_BOOT_INIT
|
#if CONFIG_SPIRAM_BOOT_INIT
|
||||||
esp_spiram_init_cache();
|
esp_spiram_init_cache();
|
||||||
if (esp_spiram_init() != ESP_OK) {
|
if (esp_spiram_init() != ESP_OK) {
|
||||||
|
#if CONFIG_SPIRAM_IGNORE_NOTFOUND
|
||||||
|
ESP_EARLY_LOGI(TAG, "Failed to init external RAM; continuing without it.");
|
||||||
|
s_spiram_okay = false;
|
||||||
|
#else
|
||||||
ESP_EARLY_LOGE(TAG, "Failed to init external RAM!");
|
ESP_EARLY_LOGE(TAG, "Failed to init external RAM!");
|
||||||
abort();
|
abort();
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -182,10 +190,12 @@ void IRAM_ATTR call_start_cpu0()
|
||||||
|
|
||||||
|
|
||||||
#if CONFIG_SPIRAM_MEMTEST
|
#if CONFIG_SPIRAM_MEMTEST
|
||||||
bool ext_ram_ok=esp_spiram_test();
|
if (s_spiram_okay) {
|
||||||
if (!ext_ram_ok) {
|
bool ext_ram_ok=esp_spiram_test();
|
||||||
ESP_EARLY_LOGE(TAG, "External RAM failed memory test!");
|
if (!ext_ram_ok) {
|
||||||
abort();
|
ESP_EARLY_LOGE(TAG, "External RAM failed memory test!");
|
||||||
|
abort();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -252,23 +262,25 @@ void start_cpu0_default(void)
|
||||||
esp_err_t err;
|
esp_err_t err;
|
||||||
esp_setup_syscall_table();
|
esp_setup_syscall_table();
|
||||||
|
|
||||||
|
if (s_spiram_okay) {
|
||||||
#if CONFIG_SPIRAM_BOOT_INIT && (CONFIG_SPIRAM_USE_CAPS_ALLOC || CONFIG_SPIRAM_USE_MALLOC)
|
#if CONFIG_SPIRAM_BOOT_INIT && (CONFIG_SPIRAM_USE_CAPS_ALLOC || CONFIG_SPIRAM_USE_MALLOC)
|
||||||
esp_err_t r=esp_spiram_add_to_heapalloc();
|
esp_err_t r=esp_spiram_add_to_heapalloc();
|
||||||
if (r != ESP_OK) {
|
if (r != ESP_OK) {
|
||||||
ESP_EARLY_LOGE(TAG, "External RAM could not be added to heap!");
|
ESP_EARLY_LOGE(TAG, "External RAM could not be added to heap!");
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
#if CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL
|
#if CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL
|
||||||
r=esp_spiram_reserve_dma_pool(CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL);
|
r=esp_spiram_reserve_dma_pool(CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL);
|
||||||
if (r != ESP_OK) {
|
if (r != ESP_OK) {
|
||||||
ESP_EARLY_LOGE(TAG, "Could not reserve internal/DMA pool!");
|
ESP_EARLY_LOGE(TAG, "Could not reserve internal/DMA pool!");
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if CONFIG_SPIRAM_USE_MALLOC
|
#if CONFIG_SPIRAM_USE_MALLOC
|
||||||
heap_caps_malloc_extmem_enable(CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL);
|
heap_caps_malloc_extmem_enable(CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
//Enable trace memory and immediately start trace.
|
//Enable trace memory and immediately start trace.
|
||||||
#if CONFIG_ESP32_TRAX
|
#if CONFIG_ESP32_TRAX
|
||||||
|
|
|
@ -108,7 +108,9 @@ esp_err_t esp_spiram_init()
|
||||||
esp_err_t r;
|
esp_err_t r;
|
||||||
r = psram_enable(PSRAM_SPEED, PSRAM_MODE);
|
r = psram_enable(PSRAM_SPEED, PSRAM_MODE);
|
||||||
if (r != ESP_OK) {
|
if (r != ESP_OK) {
|
||||||
|
#if CONFIG_SPIRAM_IGNORE_NOTFOUND
|
||||||
ESP_EARLY_LOGE(TAG, "SPI RAM enabled but initialization failed. Bailing out.");
|
ESP_EARLY_LOGE(TAG, "SPI RAM enabled but initialization failed. Bailing out.");
|
||||||
|
#endif
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue