Hi,
I've recently moved my development environment from Windows + Keil uVision to Linux + ARM GNU Toolchain. I'm able to build and flash the application firmware, but I notice that the size of final binary is significantly bigger with Linux + ARM GNU Toolchain.
- size of final binary file on Windows+KEIL: ~32kB
- size of final binary file on Linux + ARM GNU Toolchain: ~44kB
I'm using one math routine (floor) at few places and hence linking math library(libm). The size gets reduced by 4k if I remove floor() invocation in my firmware and do not link libm. However, I still need such math libraries, hence removing them is not an option.
# Libraries to link
LIBRARIES := -lm
## Link C and assembler objects to an .out file
$(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out: $(BUILD_DIRECTORIES) $(C_OBJECTS) $(ASSEMBLER_OBJECTS) $(LIBRARIES)
$(CC) $(LDFLAGS) $(C_OBJECTS) $(ASSEMBLER_OBJECTS) $(LIBRARIES) -o $(OUTPUT_BINARY_DIRECTORY)/$(OUTPUT_FILENAME).out
I'm guessing that I might be missing some compiler or linker flags and/or path. They are as follows:
INCLUDE_PATHS: [-I../../sdk_v6_1/nrf51822/Include -I../../sdk_v6_1/nrf51822/Include/s110 -I../../sdk_v6_1/nrf51822/Include/ble -I../../sdk_v6_1/nrf51822/Include/ble/ble_services -I../../sdk_v6_1/nrf51822/Include/app_common -I../../sdk_v6_1/nrf51822/Include/sd_common -I../../sdk_v6_1/nrf51822/Include/sdk -I../../sdk_v6_1/nrf51822/Include/bootloader_dfu -I../../sdk_v6_1/nrf51822/../../custom_sdk -I../../sdk_v6_1/nrf51822/../../ARM/CMSIS/Include -I../../sdk_v6_1/nrf51822/Device/ARM/ARMCM0/Include -I../../tools/gcc-arm-none-eabi-4_9-2015q2/arm-none-eabi/include -I../ -I../../sdk_v6_1/nrf51822/Include/gcc]
LDFLAGS: [-Wl,--gc-sections -flto -L../../tools/gcc-arm-none-eabi-4_9-2015q2/arm-none-eabi/lib/armv6-m -L../../tools/gcc-arm-none-eabi-4_9-2015q2/lib/gcc/arm-none-eabi/4.9.3/armv6-m -Xlinker -Map=_build/testing_s110_xxaa.map -mcpu=cortex-m0 -mthumb -mabi=aapcs -L../../sdk_v6_1/nrf51822/Source/templates/gcc/ -Tgcc_nrf51_s110_xxaa.ld --specs=nano.specs -lc -lnosys]
CFLAGS: [-DDEBUG_NRF_USER -DBLE_STACK_SUPPORT_REQD -DSPI_MASTER_0_ENABLE -DNRF51 -DTOOLCHAIN_GCC_ARM -fno-strict-aliasing -ffunction-sections -fdata-sections -mcpu=cortex-m0 -mthumb -mabi=aapcs -DNRF51 -DBOARD_NRF6310 -DNRF51822_QFAA_CA --std=gnu99 -Wall -o0 -fno-common -fmessage-length=0 -mfloat-abi=soft -fno-exceptions -ffunction-sections -fdata-sections -fomit-frame-pointer --specs=nano.specs ]
Some information about the environment:
- ARM Toolchain: gcc-arm-none-eabi-4_9-2015q2
- Target: nrf51822QF_AA (256kB flash memory)
- Nordic SDK: v6.1.0
Note: I'm not using Eclipse or any IDE, just plain GNU tools(make, cscope, vim etc).
Thank you for your help.