diff options
Diffstat (limited to 'ports/esp32/main.c')
-rw-r--r-- | ports/esp32/main.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/ports/esp32/main.c b/ports/esp32/main.c index 7ca3d8414..ff6dd6957 100644 --- a/ports/esp32/main.c +++ b/ports/esp32/main.c @@ -42,6 +42,8 @@ #include "esp32/spiram.h" #elif CONFIG_IDF_TARGET_ESP32S2 #include "esp32s2/spiram.h" +#elif CONFIG_IDF_TARGET_ESP32S3 +#include "esp32s3/spiram.h" #endif #include "py/stackctrl.h" @@ -104,6 +106,18 @@ void mp_task(void *pvParameter) { mp_task_heap = malloc(mp_task_heap_size); break; } + #elif CONFIG_ESP32S2_SPIRAM_SUPPORT || CONFIG_ESP32S3_SPIRAM_SUPPORT + // Try to use the entire external SPIRAM directly for the heap + size_t mp_task_heap_size; + size_t esp_spiram_size = esp_spiram_get_size(); + void *mp_task_heap = (void *)0x3ff80000 - esp_spiram_size; + if (esp_spiram_size > 0) { + mp_task_heap_size = esp_spiram_size; + } else { + // No SPIRAM, fallback to normal allocation + mp_task_heap_size = heap_caps_get_largest_free_block(MALLOC_CAP_8BIT); + mp_task_heap = malloc(mp_task_heap_size); + } #else // Allocate the uPy heap using malloc and get the largest available region size_t mp_task_heap_size = heap_caps_get_largest_free_block(MALLOC_CAP_8BIT); |