summaryrefslogtreecommitdiff
path: root/ports/esp32/main.c
diff options
context:
space:
mode:
authorDamien George <damien@micropython.org>2021-05-06 10:58:12 +1000
committerDamien George <damien@micropython.org>2021-05-10 16:56:53 +1000
commit5093d49fae5b59d6440d34b4c05f2950f40a6b9f (patch)
tree67d72cb675c448ebea60fb3ef2bcfb51e5b59f85 /ports/esp32/main.c
parent4cdcbdb7531b98b2dc9a85737b760f509957e31e (diff)
esp32: Extend support for S2 series, and S3 where applicable.
Improvements made: - PSRAM support for S2 - partition definition for 16MiB flash - correct ADC and DAC pins - correct GPIO and IRQ pins - S3 components in CMakeLists Based on original commit made by Seon Rozenblum aka @UnexpectedMaker. Signed-off-by: Damien George <damien@micropython.org>
Diffstat (limited to 'ports/esp32/main.c')
-rw-r--r--ports/esp32/main.c14
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);