Important changes to forums and questions
All forums and questions are now archived. To start a new conversation or read the latest updates go to forums.mbed.com.
10 years ago.
Flash overflows with GCC export by adding UART
Hi, I've been using the MBED LPC1768 with the offline GNU toolchain (on Windows) for some time now and recently I switched to compiling for the FRDM-KL05Z.
A basic blinking led is not a problem. However, the second I add a uart port the linker complains about overflowing the flash.
-eabi/4.7.3/../../../../arm-none-eabi/bin/ld.exe: region `FLASH' overflowed by 5344 bytes collect2.exe: error: ld returned 1 exit status
This is by simply calling the exported makefile. The command line this generates is:
arm-none-eabi-g++ -mcpu=cortex-m0plus -mthumb -c -g -fno-common -fmessage-length =0 -Wall -fno-exceptions -ffunction-sections -fdata-sections -fomit-frame-pointe r -MMD -MP -DNDEBUG -Os -DTARGET_KL05Z -DTARGET_M0P -DTARGET_CORTEX_M -DTARGET_F reescale -DTARGET_KLXX -DTOOLCHAIN_GCC_ARM -DTOOLCHAIN_GCC -D__CORTEX_M0PLUS -DA RM_MATH_CM0PLUS -DMBED_BUILD_TIMESTAMP=1418324231.0 -D__MBED__=1 -DTARGET_FF_ARD UINO -std=gnu++98 -fno-rtti -I. -I./external/mbed -I./external/mbed/TARGET_KL05 Z -I./external/mbed/TARGET_KL05Z/TARGET_Freescale -I./external/mbed/TARGET_KL05Z /TARGET_Freescale/TARGET_KLXX -I./external/mbed/TARGET_KL05Z/TARGET_Freescale/TA RGET_KLXX/TARGET_KL05Z -I./external/mbed/TARGET_KL05Z/TOOLCHAIN_GCC_ARM -o main .o main.cpp
Then the linker generates the error:
arm-none-eabi-gcc -mcpu=cortex-m0plus -mthumb -Wl,--gc-sections --specs=nano.specs -u _printf_float -u _scanf_float -Wl,-Map=frdm_serial.map,--cref -T./external /mbed/TARGET_KL05Z/TOOLCHAIN_GCC_ARM/MKL05Z4.ld -L./external/mbed/TARGET_KL05Z/TOOLCHAIN_GCC_ARM -o frdm_serial.elf main.o external/mbed/TARGET_KL05Z/TOOLCHAIN_GCC_ARM/retarget.o external/mbed/TARGET_KL05Z/TOOLCHAIN_GCC_ARM/system_MKL05Z4.o external/mbed/TARGET_KL05Z/TOOLCHAIN_GCC_ARM/board.o external/mbed/TARGET_KL05Z/TOOLCHAIN_GCC_ARM/cmsis_nvic.o external/mbed/TARGET_KL05Z/TOOLCHAIN_GCC_ARM/mbed_overrides.o external/mbed/TARGET_KL05Z/TOOLCHAIN_GCC_ARM/startup_MKL05Z4.o -lmbed -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys -lmbed -lstdc++ -lsupc++ -lm -lc -lgcc -lnosys
The code is surprisingly simple...
Serial uart(PTA0, PTA1); DigitalOut blinky(LED1); int main() { for(;;) { wait_ms(100); blinky = !blinky } return 0; }
Compiling much more complex programs in the online compiler is not an issue. So is this a bug from the GCC toolchain? Or related to my building on Windows?
Any help would be greatly appreciated
Question relating to:
2 Answers
10 years ago.
Edit: Yeah, what Martin said :)
Try removing these two options from the linker command line and see what happens:
-u _printf_float -u _scanf_float
That should discard a bunch of floating point code that the UART streaming support pulls in.
I hope that helps,
Adam
Hot diggity! Removing -u _printf_float -u _scanf_float did it.
arm-none-eabi-size Blinky.elf text data bss dec hex filename 16912 136 460 17508 4464 Blinky.elf
I already played with optimizations without any luck.
For future reference the KL05z has 32kB of flash:
Blinky with -u _printf_float -u _scanf_float: arm-none-eabi-size Blinky.elf text data bss dec hex filename 32360 228 608 33196 81ac Blinky.elf Blinky without -u _printf_float -u _scanf_float: arm-none-eabi-size Blinky.elf text data bss dec hex filename 9720 128 352 10200 27d8 Blinky.elf Blinky without -u _printf_float -u _scanf_float with serial: arm-none-eabi-size Blinky.elf text data bss dec hex filename 16912 136 460 17508 4464 Blinky.elf
Still seems high for just a LED and uart though?
posted by 12 Dec 201410 years ago.
Hi,
you did not specify the size of blinky without uart, the size of KL05Z (not all of us know all flash/ram sizes from top of our heads).
I would start removing floating support specs=nano.specs -u _printf_float -u _scanf_float, and play with optimizations, use LTO?