From 7bc0a261abdf295d0f35b89bfe51168a9f1c0b37 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Sat, 27 Jul 2019 17:03:18 -0400 Subject: [PATCH] stm32f4: Automatically calculate dynmem start/end Signed-off-by: Kevin O'Connor --- src/stm32f4/Makefile | 3 +-- src/stm32f4/main.c | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/src/stm32f4/Makefile b/src/stm32f4/Makefile index bfd8a6cf..5e32d647 100644 --- a/src/stm32f4/Makefile +++ b/src/stm32f4/Makefile @@ -16,8 +16,7 @@ CFLAGS_klipper.elf += -T $(OUT)stm32f4.ld --specs=nano.specs --specs=nosys.specs # Add source files src-y += stm32f4/main.c stm32f4/clock.c stm32f4/watchdog.c stm32f4/gpio.c -src-y += generic/crc16_ccitt.c generic/alloc.c -src-y += generic/armcm_irq.c generic/armcm_timer.c +src-y += generic/crc16_ccitt.c generic/armcm_irq.c generic/armcm_timer.c src-y += ../lib/stm32f4/system_stm32f4xx.c src-$(CONFIG_HAVE_GPIO_ADC) += stm32f4/adc.c src-$(CONFIG_HAVE_GPIO_SPI) += stm32f4/spi.c diff --git a/src/stm32f4/main.c b/src/stm32f4/main.c index a6424770..b3069cc9 100644 --- a/src/stm32f4/main.c +++ b/src/stm32f4/main.c @@ -11,6 +11,22 @@ DECL_CONSTANT_STR("MCU", CONFIG_MCU); +// Return the start of memory available for dynamic allocations +void * +dynmem_start(void) +{ + extern uint32_t _ebss; + return &_ebss; +} + +// Return the end of memory available for dynamic allocations +void * +dynmem_end(void) +{ + extern uint32_t _sstack; + return &_sstack; +} + void command_reset(uint32_t *args) {