fix(psram): Do not abort if PSRAM is not found (#10395)
Also add to heap in app_main
This commit is contained in:
parent
5a06dd9e57
commit
84ddf0ad28
3 changed files with 21 additions and 6 deletions
|
|
@ -253,7 +253,8 @@ extern bool btInUse();
|
||||||
#if CONFIG_SPIRAM_SUPPORT || CONFIG_SPIRAM
|
#if CONFIG_SPIRAM_SUPPORT || CONFIG_SPIRAM
|
||||||
#ifndef CONFIG_SPIRAM_BOOT_INIT
|
#ifndef CONFIG_SPIRAM_BOOT_INIT
|
||||||
ESP_SYSTEM_INIT_FN(init_psram_new, BIT(0), 99) {
|
ESP_SYSTEM_INIT_FN(init_psram_new, BIT(0), 99) {
|
||||||
return psramInit() ? ESP_OK : ESP_FAIL;
|
psramInit();
|
||||||
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -261,6 +262,11 @@ ESP_SYSTEM_INIT_FN(init_psram_new, BIT(0), 99) {
|
||||||
void initArduino() {
|
void initArduino() {
|
||||||
//init proper ref tick value for PLL (uncomment if REF_TICK is different than 1MHz)
|
//init proper ref tick value for PLL (uncomment if REF_TICK is different than 1MHz)
|
||||||
//ESP_REG(APB_CTRL_PLL_TICK_CONF_REG) = APB_CLK_FREQ / REF_CLK_FREQ - 1;
|
//ESP_REG(APB_CTRL_PLL_TICK_CONF_REG) = APB_CLK_FREQ / REF_CLK_FREQ - 1;
|
||||||
|
#if CONFIG_SPIRAM_SUPPORT || CONFIG_SPIRAM
|
||||||
|
#ifndef CONFIG_SPIRAM_BOOT_INIT
|
||||||
|
psramAddToHeap();
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
#ifdef CONFIG_APP_ROLLBACK_ENABLE
|
#ifdef CONFIG_APP_ROLLBACK_ENABLE
|
||||||
if (!verifyRollbackLater()) {
|
if (!verifyRollbackLater()) {
|
||||||
const esp_partition_t *running = esp_ota_get_running_partition();
|
const esp_partition_t *running = esp_ota_get_running_partition();
|
||||||
|
|
|
||||||
|
|
@ -79,17 +79,25 @@ bool psramInit() {
|
||||||
ESP_EARLY_LOGE(TAG, "PSRAM test failed!");
|
ESP_EARLY_LOGE(TAG, "PSRAM test failed!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
ESP_EARLY_LOGI(TAG, "PSRAM enabled");
|
||||||
|
#endif /* CONFIG_SPIRAM_BOOT_INIT */
|
||||||
|
spiramDetected = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool psramAddToHeap() {
|
||||||
|
if (!spiramDetected) {
|
||||||
|
log_e("PSRAM not initialized!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (esp_psram_extram_add_to_heap_allocator() != ESP_OK) {
|
if (esp_psram_extram_add_to_heap_allocator() != ESP_OK) {
|
||||||
spiramFailed = true;
|
log_e("PSRAM could not be added to the heap!");
|
||||||
ESP_EARLY_LOGE(TAG, "PSRAM could not be added to the heap!");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
#if CONFIG_SPIRAM_USE_MALLOC && !CONFIG_ARDUINO_ISR_IRAM
|
#if CONFIG_SPIRAM_USE_MALLOC && !CONFIG_ARDUINO_ISR_IRAM
|
||||||
heap_caps_malloc_extmem_enable(CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL);
|
heap_caps_malloc_extmem_enable(CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL);
|
||||||
#endif
|
#endif
|
||||||
ESP_EARLY_LOGI(TAG, "PSRAM enabled");
|
log_i("PSRAM added to the heap.");
|
||||||
#endif /* CONFIG_SPIRAM_BOOT_INIT */
|
|
||||||
spiramDetected = true;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool psramInit();
|
bool psramInit();
|
||||||
|
bool psramAddToHeap();
|
||||||
bool psramFound();
|
bool psramFound();
|
||||||
|
|
||||||
void *ps_malloc(size_t size);
|
void *ps_malloc(size_t size);
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue