File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 5353#define MP_TASK_PRIORITY (ESP_TASK_PRIO_MIN + 1)
5454#define MP_TASK_STACK_SIZE (16 * 1024)
5555#define MP_TASK_STACK_LEN (MP_TASK_STACK_SIZE / sizeof(StackType_t))
56- #define MP_TASK_HEAP_SIZE (92 * 1024)
5756
5857STATIC StaticTask_t mp_task_tcb ;
5958STATIC StackType_t mp_task_stack [MP_TASK_STACK_LEN ] __attribute__((aligned (8 )));
60- STATIC uint8_t mp_task_heap [MP_TASK_HEAP_SIZE ];
6159
6260void mp_task (void * pvParameter ) {
6361 volatile uint32_t sp = (uint32_t )get_sp ();
@@ -66,11 +64,15 @@ void mp_task(void *pvParameter) {
6664 #endif
6765 uart_init ();
6866
67+ // Allocate the uPy heap using malloc and get the largest available region
68+ size_t mp_task_heap_size = heap_caps_get_largest_free_block (MALLOC_CAP_8BIT );
69+ void * mp_task_heap = malloc (mp_task_heap_size );
70+
6971soft_reset :
7072 // initialise the stack pointer for the main thread
7173 mp_stack_set_top ((void * )sp );
7274 mp_stack_set_limit (MP_TASK_STACK_SIZE - 1024 );
73- gc_init (mp_task_heap , mp_task_heap + sizeof ( mp_task_heap ) );
75+ gc_init (mp_task_heap , mp_task_heap + mp_task_heap_size );
7476 mp_init ();
7577 mp_obj_list_init (mp_sys_path , 0 );
7678 mp_obj_list_append (mp_sys_path , MP_OBJ_NEW_QSTR (MP_QSTR_ ));
You can’t perform that action at this time.
0 commit comments