From 1207bfced987bd4c47ddc9c436a62b8dd22abf76 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sat, 4 Dec 2021 08:16:37 -0600 Subject: [PATCH] espressif: Use detected size of spiram --- ports/espressif/supervisor/port.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/ports/espressif/supervisor/port.c b/ports/espressif/supervisor/port.c index 277777a332..c8cb344aae 100644 --- a/ports/espressif/supervisor/port.c +++ b/ports/espressif/supervisor/port.c @@ -77,6 +77,10 @@ #include "esp_debug_helpers.h" +#ifdef CONFIG_SPIRAM +#include "esp32/spiram.h" +#endif + #define HEAP_SIZE (48 * 1024) uint32_t *heap; @@ -158,8 +162,11 @@ safe_mode_t port_init(void) { #endif #ifdef CONFIG_SPIRAM - heap = (uint32_t *)(DRAM0_CACHE_ADDRESS_HIGH - CONFIG_SPIRAM_SIZE); - heap_size = CONFIG_SPIRAM_SIZE / sizeof(uint32_t); + if (esp_spiram_is_initialized()) { + size_t spiram_size = esp_spiram_get_size(); + heap = (uint32_t *)(SOC_EXTRAM_DATA_HIGH - spiram_size); + heap_size = spiram_size / sizeof(uint32_t); + } #endif if (heap == NULL) {