@@ -102,6 +102,9 @@ struct object { long placeholder[ 10 ]; };
102102void __register_frame_info (const void * begin , struct object * ob );
103103extern char __eh_frame [];
104104
105+ //If CONFIG_SPIRAM_IGNORE_NOTFOUND is set and external RAM is not found or errors out on testing, this is set to false.
106+ static bool s_spiram_okay = true;
107+
105108/*
106109 * We arrive here after the bootloader finished loading the program from flash. The hardware is mostly uninitialized,
107110 * 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()
147150#if CONFIG_SPIRAM_BOOT_INIT
148151 esp_spiram_init_cache ();
149152 if (esp_spiram_init () != ESP_OK ) {
153+ #if CONFIG_SPIRAM_IGNORE_NOTFOUND
154+ ESP_EARLY_LOGI (TAG , "Failed to init external RAM; continuing without it." );
155+ s_spiram_okay = false;
156+ #else
150157 ESP_EARLY_LOGE (TAG , "Failed to init external RAM!" );
151158 abort ();
159+ #endif
152160 }
153161#endif
154162
@@ -182,10 +190,12 @@ void IRAM_ATTR call_start_cpu0()
182190
183191
184192#if CONFIG_SPIRAM_MEMTEST
185- bool ext_ram_ok = esp_spiram_test ();
186- if (!ext_ram_ok ) {
187- ESP_EARLY_LOGE (TAG , "External RAM failed memory test!" );
188- abort ();
193+ if (s_spiram_okay ) {
194+ bool ext_ram_ok = esp_spiram_test ();
195+ if (!ext_ram_ok ) {
196+ ESP_EARLY_LOGE (TAG , "External RAM failed memory test!" );
197+ abort ();
198+ }
189199 }
190200#endif
191201
@@ -252,23 +262,25 @@ void start_cpu0_default(void)
252262 esp_err_t err ;
253263 esp_setup_syscall_table ();
254264
265+ if (s_spiram_okay ) {
255266#if CONFIG_SPIRAM_BOOT_INIT && (CONFIG_SPIRAM_USE_CAPS_ALLOC || CONFIG_SPIRAM_USE_MALLOC )
256- esp_err_t r = esp_spiram_add_to_heapalloc ();
257- if (r != ESP_OK ) {
258- ESP_EARLY_LOGE (TAG , "External RAM could not be added to heap!" );
259- abort ();
260- }
267+ esp_err_t r = esp_spiram_add_to_heapalloc ();
268+ if (r != ESP_OK ) {
269+ ESP_EARLY_LOGE (TAG , "External RAM could not be added to heap!" );
270+ abort ();
271+ }
261272#if CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL
262- r = esp_spiram_reserve_dma_pool (CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL );
263- if (r != ESP_OK ) {
264- ESP_EARLY_LOGE (TAG , "Could not reserve internal/DMA pool!" );
265- abort ();
266- }
273+ r = esp_spiram_reserve_dma_pool (CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL );
274+ if (r != ESP_OK ) {
275+ ESP_EARLY_LOGE (TAG , "Could not reserve internal/DMA pool!" );
276+ abort ();
277+ }
267278#endif
268279#if CONFIG_SPIRAM_USE_MALLOC
269- heap_caps_malloc_extmem_enable (CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL );
280+ heap_caps_malloc_extmem_enable (CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL );
270281#endif
271282#endif
283+ }
272284
273285//Enable trace memory and immediately start trace.
274286#if CONFIG_ESP32_TRAX
0 commit comments