diff --git a/stm/gccollect.c b/stm/gccollect.c index cea0bc56e..ada5493a2 100644 --- a/stm/gccollect.c +++ b/stm/gccollect.c @@ -13,10 +13,10 @@ void gc_helper_get_regs_and_clean_stack(machine_uint_t *regs, machine_uint_t hea void gc_collect(void) { uint32_t start = sys_tick_counter; gc_collect_start(); - gc_collect_root((void**)&_ram_start, (&_heap_start - &_ram_start) / 4); + gc_collect_root((void**)&_ram_start, ((uint32_t)&_heap_start - (uint32_t)&_ram_start) / sizeof(uint32_t)); machine_uint_t regs[10]; gc_helper_get_regs_and_clean_stack(regs, (machine_uint_t)&_heap_end); - gc_collect_root((void**)&_heap_end, (&_ram_end - &_heap_end) / 4); // will trace regs since they now live in this function on the stack + gc_collect_root((void**)&_heap_end, ((uint32_t)&_ram_end - (uint32_t)&_heap_end) / sizeof(uint32_t)); // will trace regs since they now live in this function on the stack gc_collect_end(); uint32_t ticks = sys_tick_counter - start; // TODO implement a function that does this properly diff --git a/stm/main.c b/stm/main.c index 9f2b6d564..5c2d3cf17 100644 --- a/stm/main.c +++ b/stm/main.c @@ -174,15 +174,24 @@ static mp_obj_t pyb_info(void) { extern void *_ebss; extern void *_estack; extern void *_etext; + printf("_etext=%p\n", &_etext); printf("_sidata=%p\n", &_sidata); printf("_sdata=%p\n", &_sdata); printf("_edata=%p\n", &_edata); printf("_sbss=%p\n", &_sbss); printf("_ebss=%p\n", &_ebss); printf("_estack=%p\n", &_estack); - printf("_etext=%p\n", &_etext); printf("_ram_start=%p\n", &_ram_start); printf("_heap_start=%p\n", &_heap_start); + printf("_heap_end=%p\n", &_heap_end); + printf("_ram_end=%p\n", &_ram_end); + } + + // qstr info + { + uint n_pool, n_qstr, n_str_data_bytes, n_total_bytes; + qstr_pool_info(&n_pool, &n_qstr, &n_str_data_bytes, &n_total_bytes); + printf("qstr:\n n_pool=%u\n n_qstr=%u\n n_str_data_bytes=%u\n n_total_bytes=%u\n", n_pool, n_qstr, n_str_data_bytes, n_total_bytes); } // GC info diff --git a/stm/stm32f405.ld b/stm/stm32f405.ld index 5cef201a9..6c29a681c 100644 --- a/stm/stm32f405.ld +++ b/stm/stm32f405.ld @@ -19,8 +19,9 @@ _minimum_heap_size = 16K; /* top end of the stack */ _estack = ORIGIN(RAM) + LENGTH(RAM); -_ram_end = 0x20020000; -_heap_end = 0x2001c000; +/* RAM extents for the garbage collector */ +_ram_end = ORIGIN(RAM) + LENGTH(RAM); +_heap_end = 0x2001c000; /* tunable */ /* define output sections */ SECTIONS