Skip to content

Commit 99f5011

Browse files
committed
Fix heap without PSRAM. Never set heap_size.
1 parent 96cf60f commit 99f5011

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

ports/esp32s2/supervisor/port.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ void tick_timer_cb(void* arg) {
5959
supervisor_tick();
6060
}
6161

62-
uint32_t* heap;
63-
6462
safe_mode_t port_init(void) {
6563
esp_timer_create_args_t args;
6664
args.callback = &tick_timer_cb;
@@ -69,7 +67,7 @@ safe_mode_t port_init(void) {
6967
args.name = "CircuitPython Tick";
7068
esp_timer_create(&args, &_tick_timer);
7169

72-
heap = malloc(HEAP_SIZE);
70+
heap = NULL;
7371
never_reset_module_internal_pins();
7472

7573
#ifdef CONFIG_SPIRAM
@@ -81,6 +79,10 @@ safe_mode_t port_init(void) {
8179
heap = malloc(HEAP_SIZE);
8280
heap_size = HEAP_SIZE / sizeof(uint32_t);
8381
}
82+
if (heap == NULL) {
83+
return NO_HEAP;
84+
}
85+
8486
return NO_SAFE_MODE;
8587
}
8688

@@ -142,13 +144,6 @@ supervisor_allocation* port_fixed_stack(void) {
142144
return &_fixed_stack;
143145
}
144146

145-
supervisor_allocation _fixed_heap;
146-
supervisor_allocation* port_fixed_heap(void) {
147-
_fixed_heap.ptr = port_heap_get_bottom();
148-
_fixed_heap.length = (port_heap_get_top() - port_heap_get_bottom()) * sizeof(uint32_t);
149-
return &_fixed_heap;
150-
}
151-
152147
// Place the word to save just after our BSS section that gets blanked.
153148
void port_set_saved_word(uint32_t value) {
154149
}

supervisor/shared/safe_mode.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,10 @@ void print_safe_mode_message(safe_mode_t reason) {
133133
serial_write_compressed(translate("The CircuitPython heap was corrupted because the stack was too small.\nPlease increase the stack size if you know how, or if not:"));
134134
serial_write_compressed(FILE_AN_ISSUE);
135135
return;
136+
case NO_HEAP:
137+
serial_write_compressed(translate("CircuitPython was unable to allocate the heap.\n"));
138+
serial_write_compressed(FILE_AN_ISSUE);
139+
return;
136140
default:
137141
break;
138142
}

supervisor/shared/safe_mode.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ typedef enum {
4242
FLASH_WRITE_FAIL,
4343
MEM_MANAGE,
4444
WATCHDOG_RESET,
45+
NO_HEAP,
4546
} safe_mode_t;
4647

4748
safe_mode_t wait_for_safe_mode_reset(void);

0 commit comments

Comments
 (0)