Skip to content

Commit 1207bfc

Browse files
committed
espressif: Use detected size of spiram
1 parent f594ab2 commit 1207bfc

File tree

1 file changed

+9
-2
lines changed
  • ports/espressif/supervisor

1 file changed

+9
-2
lines changed

ports/espressif/supervisor/port.c

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@
7777

7878
#include "esp_debug_helpers.h"
7979

80+
#ifdef CONFIG_SPIRAM
81+
#include "esp32/spiram.h"
82+
#endif
83+
8084
#define HEAP_SIZE (48 * 1024)
8185

8286
uint32_t *heap;
@@ -158,8 +162,11 @@ safe_mode_t port_init(void) {
158162
#endif
159163

160164
#ifdef CONFIG_SPIRAM
161-
heap = (uint32_t *)(DRAM0_CACHE_ADDRESS_HIGH - CONFIG_SPIRAM_SIZE);
162-
heap_size = CONFIG_SPIRAM_SIZE / sizeof(uint32_t);
165+
if (esp_spiram_is_initialized()) {
166+
size_t spiram_size = esp_spiram_get_size();
167+
heap = (uint32_t *)(SOC_EXTRAM_DATA_HIGH - spiram_size);
168+
heap_size = spiram_size / sizeof(uint32_t);
169+
}
163170
#endif
164171

165172
if (heap == NULL) {

0 commit comments

Comments
 (0)