stm32duino : Switching to a newer toolchain to reduce flash consumption
The default toolchain when using stm32duino / RogerClark is the SAM one available in the arduino repository.
It is a bit old : gcc 4.8.3 2014
Let's build the DSO project with some toolchains, and see the effect on the flash size consumed.
(/!\ The compiler options were not changed and could be sub optimal for some compilers, it is to get an idea of the gain without spending time on it)
SAM / 4.8.3 : 114 kB
Platform IO 7.2.1 : 118 kB
stm32 8.2.1 / nano : 58 kB
Damn !, the 8.2.1 is about half the size.
It is pulled from https://github.com/stm32duino/arm-none-eabi-gcc.git, and used in nano mode (--specs=nano.spec)
A couple of gotcha though:
It is a bit old : gcc 4.8.3 2014
Let's build the DSO project with some toolchains, and see the effect on the flash size consumed.
(/!\ The compiler options were not changed and could be sub optimal for some compilers, it is to get an idea of the gain without spending time on it)
SAM / 4.8.3 : 114 kB
Platform IO 7.2.1 : 118 kB
stm32 8.2.1 / nano : 58 kB
Damn !, the 8.2.1 is about half the size.
It is pulled from https://github.com/stm32duino/arm-none-eabi-gcc.git, and used in nano mode (--specs=nano.spec)
A couple of gotcha though:
- The __always_inline_ macro is defined in a different way, which ends up with a "doubly define inline" error. The fix is easy : edit ./arm-none-eabi/include/sys/cdefs.h, go to line 380 and remove the __inline__ i.e. it should now be
- Newer gccs dont like when you declare a function as returning something (int/bool/...) and you forget the "return xxx;". It messes up it stack when returning from the function. Double check your code.
Now we have a DSO firmware that is globally working, with some minor issues to fix but at about half the size. Not bad at all :)
Updates:
Updates:
- If you use sprintf(xxx,"%f",...) you need to add -u _printf_float to the linker flags (after --specs=nano.spec)
- If you use the python enabled gdb and you have an error "Could not find platform independent libraries <prefix>", delete ${TOOLCHAIN_PATH}/bin/libpython2.7.so.1.0 so that the system one is used instead
Now everything works as previously
N
Comments
Post a Comment