Commit f6d63087 authored by Damien George's avatar Damien George

esp32: Add MICROPY_GC_INITIAL_HEAP_SIZE option and tune it.

This gets back the old heap-size behaviour on ESP32, before auto-split-heap
was introduced: after the heap is grown one time the size is 111936 bytes,
with about 40k left for the IDF.  That's enough to start WiFi and do a
HTTPS request.
Signed-off-by: default avatarDamien George <damien@micropython.org>
parent 97b13132
......@@ -79,10 +79,6 @@
#define MP_TASK_STACK_LIMIT_MARGIN (1024)
#endif
// Initial Python heap size. This starts small but adds new heap areas on
// demand due to settings MICROPY_GC_SPLIT_HEAP & MICROPY_GC_SPLIT_HEAP_AUTO
#define MP_TASK_HEAP_SIZE (64 * 1024)
int vprintf_null(const char *format, va_list ap) {
// do nothing: this is used as a log target during raw repl mode
return 0;
......@@ -120,13 +116,13 @@ void mp_task(void *pvParameter) {
ESP_LOGE("esp_init", "can't create event loop: 0x%x\n", err);
}
void *mp_task_heap = MP_PLAT_ALLOC_HEAP(MP_TASK_HEAP_SIZE);
void *mp_task_heap = MP_PLAT_ALLOC_HEAP(MICROPY_GC_INITIAL_HEAP_SIZE);
soft_reset:
// initialise the stack pointer for the main thread
mp_stack_set_top((void *)sp);
mp_stack_set_limit(MICROPY_TASK_STACK_SIZE - MP_TASK_STACK_LIMIT_MARGIN);
gc_init(mp_task_heap, mp_task_heap + MP_TASK_HEAP_SIZE);
gc_init(mp_task_heap, mp_task_heap + MICROPY_GC_INITIAL_HEAP_SIZE);
mp_init();
mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR__slash_lib));
readline_init0();
......
......@@ -26,6 +26,20 @@
// memory allocation policies
#define MICROPY_ALLOC_PATH_MAX (128)
// Initial Python heap size. This starts small but adds new heap areas on demand due to
// the settings MICROPY_GC_SPLIT_HEAP and MICROPY_GC_SPLIT_HEAP_AUTO. The value is
// different for different MCUs and is chosen so they can grow the heap once (double it)
// and still have enough internal RAM to start WiFi and make a HTTPS request.
#ifndef MICROPY_GC_INITIAL_HEAP_SIZE
#if CONFIG_IDF_TARGET_ESP32
#define MICROPY_GC_INITIAL_HEAP_SIZE (56 * 1024)
#elif CONFIG_IDF_TARGET_ESP32S2 && !CONFIG_SPIRAM
#define MICROPY_GC_INITIAL_HEAP_SIZE (36 * 1024)
#else
#define MICROPY_GC_INITIAL_HEAP_SIZE (64 * 1024)
#endif
#endif
// emitters
#define MICROPY_PERSISTENT_CODE_LOAD (1)
#if !CONFIG_IDF_TARGET_ESP32C3
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment