stm32/main: Add configuration macros for board to set heap start/end.

The macros are MICROPY_HEAP_START and MICROPY_HEAP_END, and if not defined
by a board then the default values will be used (maximum heap from SRAM as
defined by linker symbols).

As part of this commit the SDRAM initialisation is moved to much earlier in
main() to potentially make it available to other peripherals and avoid
re-initialisation on soft-reboot.  On boards with SDRAM enabled the heap
has been set to use that.
This commit is contained in:
Andrew Leech 2018-10-02 22:08:25 +10:00 committed by Damien George
parent 02ca8d4674
commit 338635ccc6
5 changed files with 21 additions and 10 deletions

View File

@ -76,6 +76,8 @@
// SDRAM
#define MICROPY_HW_SDRAM_SIZE (64 / 8 * 1024 * 1024) // 64 Mbit
#define MICROPY_HW_SDRAM_STARTUP_TEST (1)
#define MICROPY_HEAP_START sdram_start()
#define MICROPY_HEAP_END sdram_end()
// Timing configuration for 90 Mhz (11.90ns) of SD clock frequency (180Mhz/2)
#define MICROPY_HW_SDRAM_TIMING_TMRD (2)

View File

@ -83,6 +83,8 @@
// Optional SDRAM configuration; requires SYSCLK <= 200MHz
#define MICROPY_HW_SDRAM_SIZE (128 * 1024 * 1024 / 8) // 128 Mbit
#define MICROPY_HW_SDRAM_STARTUP_TEST (0)
#define MICROPY_HEAP_START sdram_start()
#define MICROPY_HEAP_END sdram_end()
// Timing configuration for 90 Mhz (11.90ns) of SD clock frequency (180Mhz/2)
#define MICROPY_HW_SDRAM_TIMING_TMRD (2)

View File

@ -84,6 +84,8 @@ void STM32F7DISC_board_early_init(void);
// SDRAM
#define MICROPY_HW_SDRAM_SIZE (64 / 8 * 1024 * 1024) // 64 Mbit
#define MICROPY_HW_SDRAM_STARTUP_TEST (1)
#define MICROPY_HEAP_START sdram_start()
#define MICROPY_HEAP_END sdram_end()
// Timing configuration for 90 Mhz (11.90ns) of SD clock frequency (180Mhz/2)
#define MICROPY_HW_SDRAM_TIMING_TMRD (2)

View File

@ -498,6 +498,12 @@ void stm32_main(uint32_t reset_mode) {
#endif
// basic sub-system init
#if MICROPY_HW_SDRAM_SIZE
sdram_init();
#if MICROPY_HW_SDRAM_STARTUP_TEST
sdram_test(true);
#endif
#endif
#if MICROPY_PY_THREAD
pyb_thread_init(&pyb_thread_main);
#endif
@ -556,16 +562,7 @@ soft_reset:
mp_stack_set_limit((char*)&_estack - (char*)&_heap_end - 1024);
// GC init
#if MICROPY_HW_SDRAM_SIZE
sdram_init();
#if MICROPY_HW_SDRAM_STARTUP_TEST
sdram_test(true);
#endif
gc_init(sdram_start(), sdram_end());
#else
gc_init(&_heap_start, &_heap_end);
#endif
gc_init(MICROPY_HEAP_START, MICROPY_HEAP_END);
#if MICROPY_ENABLE_PYSTACK
static mp_obj_t pystack[384];

View File

@ -115,6 +115,14 @@
/*****************************************************************************/
// General configuration
// Heap start / end definitions
#ifndef MICROPY_HEAP_START
#define MICROPY_HEAP_START &_heap_start
#endif
#ifndef MICROPY_HEAP_END
#define MICROPY_HEAP_END &_heap_end
#endif
// Configuration for STM32F0 series
#if defined(STM32F0)