diff --git a/STM32F1/platform.txt b/STM32F1/platform.txt index fbeaac41e..7a0218579 100644 --- a/STM32F1/platform.txt +++ b/STM32F1/platform.txt @@ -22,7 +22,7 @@ compiler.c.elf.flags={build.flags.optimize} -Wl,--gc-sections {build.flags.ldspe compiler.S.cmd=arm-none-eabi-gcc compiler.S.flags=-c -g -x assembler-with-cpp -MMD compiler.cpp.cmd=arm-none-eabi-g++ -compiler.cpp.flags=-c -g {build.flags.optimize} {compiler.warning_flags} -std=gnu++11 -MMD -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -DBOARD_{build.variant} -D{build.vect} -DERROR_LED_PORT={build.error_led_port} -DERROR_LED_PIN={build.error_led_pin} +compiler.cpp.flags=-c -g {build.flags.optimize} {compiler.warning_flags} -std=gnu++11 -MMD -ffunction-sections -fdata-sections -nostdlib --param max-inline-insns-single=500 -fno-rtti -fno-exceptions -fno-use-cxa-atexit -DBOARD_{build.variant} -D{build.vect} -DERROR_LED_PORT={build.error_led_port} -DERROR_LED_PIN={build.error_led_pin} compiler.ar.cmd=arm-none-eabi-ar compiler.ar.flags=rcs compiler.objcopy.cmd=arm-none-eabi-objcopy @@ -174,4 +174,4 @@ tools.hid_upload.path.linux={runtime.hardware.path}/tools/linux tools.hid_upload.path.linux64={runtime.hardware.path}/tools/linux64 tools.hid_upload.upload.params.verbose=-d tools.hid_upload.upload.params.quiet=n -tools.hid_upload.upload.pattern="{path}/{cmd}" "{build.path}/{build.project_name}.bin" {serial.port.file} \ No newline at end of file +tools.hid_upload.upload.pattern="{path}/{cmd}" "{build.path}/{build.project_name}.bin" {serial.port.file} diff --git a/STM32F1/variants/generic_stm32f103c/wirish/syscalls.c b/STM32F1/variants/generic_stm32f103c/wirish/syscalls.c index 91ed5a104..d8b751cf3 100644 --- a/STM32F1/variants/generic_stm32f103c/wirish/syscalls.c +++ b/STM32F1/variants/generic_stm32f103c/wirish/syscalls.c @@ -56,7 +56,14 @@ extern char _lm_heap_end; * * Get incr bytes more RAM (for use by the heap). malloc() and * friends call this function behind the scenes. + * + * The following can be included in application code to reserve + * a minimum amount of space for future stack growth: + * extern int __sbrk_stack_reserve; + * __sbrk_stack_reserve=10240; + * */ +volatile int __sbrk_stack_reserve = 256; void *_sbrk(int incr) { static void * pbreak = NULL; /* current program break */ void * ret; @@ -65,7 +72,7 @@ void *_sbrk(int incr) { pbreak = CONFIG_HEAP_START; } - if ((CONFIG_HEAP_END - pbreak < incr) || + if (((void*)&ret - pbreak < incr + __sbrk_stack_reserve) || (pbreak - CONFIG_HEAP_START < -incr)) { errno = ENOMEM; return (void *)-1;