From 76a6335b6e5dc92c7aac86e1efe6f6bbe1983968 Mon Sep 17 00:00:00 2001 From: mux Date: Wed, 29 Jan 2014 12:51:38 +0200 Subject: [PATCH 1/3] Move HEAP_END and RAM_END to linker script * Issue #232 --- stm/gccollect.c | 6 +++--- stm/gccollect.h | 5 ++--- stm/main.c | 2 +- stm/stm32f405.ld | 3 +++ 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/stm/gccollect.c b/stm/gccollect.c index c0f67ac0d5..cea0bc56eb 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, ((uint32_t)&_heap_start - (uint32_t)&_ram_start) / 4); + gc_collect_root((void**)&_ram_start, (&_heap_start - &_ram_start) / 4); machine_uint_t regs[10]; - gc_helper_get_regs_and_clean_stack(regs, 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_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_end(); uint32_t ticks = sys_tick_counter - start; // TODO implement a function that does this properly diff --git a/stm/gccollect.h b/stm/gccollect.h index 6467ec7d21..9187f0e9df 100644 --- a/stm/gccollect.h +++ b/stm/gccollect.h @@ -1,8 +1,7 @@ -#define HEAP_END (0x2001c000) // tunable -#define RAM_END (0x20020000) // fixed for chip - extern uint32_t _ram_start; extern uint32_t _heap_start; +extern uint32_t _ram_end; +extern uint32_t _heap_end; void gc_collect(void); diff --git a/stm/main.c b/stm/main.c index 9fc9633ff2..25dceddc2f 100644 --- a/stm/main.c +++ b/stm/main.c @@ -594,7 +594,7 @@ int main(void) { soft_reset: // GC init - gc_init(&_heap_start, (void*)HEAP_END); + gc_init(&_heap_start, &_heap_end); // Micro Python init qstr_init(); diff --git a/stm/stm32f405.ld b/stm/stm32f405.ld index fbfc584f9d..5cef201a9a 100644 --- a/stm/stm32f405.ld +++ b/stm/stm32f405.ld @@ -19,6 +19,9 @@ _minimum_heap_size = 16K; /* top end of the stack */ _estack = ORIGIN(RAM) + LENGTH(RAM); +_ram_end = 0x20020000; +_heap_end = 0x2001c000; + /* define output sections */ SECTIONS { From 8592d85b365a588a6ee18684e5d481b9e9df0866 Mon Sep 17 00:00:00 2001 From: mux Date: Wed, 29 Jan 2014 15:05:53 +0200 Subject: [PATCH 2/3] Remove redundant include in file.c * Remove include mpconfigport.h from file.c --- stm/file.c | 1 - 1 file changed, 1 deletion(-) diff --git a/stm/file.c b/stm/file.c index 35bfca16a5..84f7251fec 100644 --- a/stm/file.c +++ b/stm/file.c @@ -3,7 +3,6 @@ #include "misc.h" #include "mpconfig.h" -#include "mpconfigport.h" #include "qstr.h" #include "obj.h" #include "file.h" From bfb01e9da620d974e3e38bf7ea2aa22d9c527d9d Mon Sep 17 00:00:00 2001 From: mux Date: Wed, 29 Jan 2014 15:07:04 +0200 Subject: [PATCH 3/3] Fix unused function warning in main * Add SD card test to fix warning --- stm/main.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/stm/main.c b/stm/main.c index 25dceddc2f..9f2b6d564a 100644 --- a/stm/main.c +++ b/stm/main.c @@ -206,12 +206,14 @@ static mp_obj_t pyb_info(void) { return mp_const_none; } +#if MICROPY_HW_HAS_SDCARD // SD card test static mp_obj_t pyb_sd_test(void) { extern void sdio_init(void); sdio_init(); return mp_const_none; } +#endif static void SYSCLKConfig_STOP(void) { /* After wake-up from STOP reconfigure the system clock */