esp32/main: Allocate the uPy heap via malloc instead of on the bss.
This allows to get slightly more memory for the heap (currently around 110k vs previous 92k) because the ESP IDF frees up some RAM after booting up.
This commit is contained in:
parent
c49a73ab0e
commit
e600810f39
|
@ -53,11 +53,9 @@
|
|||
#define MP_TASK_PRIORITY (ESP_TASK_PRIO_MIN + 1)
|
||||
#define MP_TASK_STACK_SIZE (16 * 1024)
|
||||
#define MP_TASK_STACK_LEN (MP_TASK_STACK_SIZE / sizeof(StackType_t))
|
||||
#define MP_TASK_HEAP_SIZE (92 * 1024)
|
||||
|
||||
STATIC StaticTask_t mp_task_tcb;
|
||||
STATIC StackType_t mp_task_stack[MP_TASK_STACK_LEN] __attribute__((aligned (8)));
|
||||
STATIC uint8_t mp_task_heap[MP_TASK_HEAP_SIZE];
|
||||
|
||||
void mp_task(void *pvParameter) {
|
||||
volatile uint32_t sp = (uint32_t)get_sp();
|
||||
|
@ -66,11 +64,15 @@ void mp_task(void *pvParameter) {
|
|||
#endif
|
||||
uart_init();
|
||||
|
||||
// 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);
|
||||
void *mp_task_heap = malloc(mp_task_heap_size);
|
||||
|
||||
soft_reset:
|
||||
// initialise the stack pointer for the main thread
|
||||
mp_stack_set_top((void *)sp);
|
||||
mp_stack_set_limit(MP_TASK_STACK_SIZE - 1024);
|
||||
gc_init(mp_task_heap, mp_task_heap + sizeof(mp_task_heap));
|
||||
gc_init(mp_task_heap, mp_task_heap + mp_task_heap_size);
|
||||
mp_init();
|
||||
mp_obj_list_init(mp_sys_path, 0);
|
||||
mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR_));
|
||||
|
|
Loading…
Reference in New Issue