Size matters ! online mbed compile STM32F051 16K vs pio > 64K

As I am trying to use the STM32F051 F0 Discovery board with the mbed framework and the support of platformio, I am in need for some flash size optimization

→ pio run : /arm-none-eabi/bin/ld: region `FLASH’ overflowed by 52 bytes - so bigger then 64K withy platformio.ini :
[env:disco_f051r8]
platform = ststm32
board = disco_f051r8
framework = mbed
→ compiling the same code on mbed online compiler : DiscoveryF0-simple_USART - Simply UART communication for STM32F0 Discovery u… | Mbed
gives a FLASH size of 16K.

So some basic difference in the compile options is playing a role !
As the compîlation process of mbed and pio are non-transparent I am stuck on analyzing the root cause.

Any suggestions or similar experiences ?

Any chance using libopencm3 with STM32F0 in platformio ? libopencm3 seems to support this board and chip.

Sure.
Just specify framework = libopencm3 in the platformio.INI file.

  1. You can build project in verbose mode. See Redirecting...

  2. Also, you can ignore built-in mbed libraries. See Redirecting...

Tried it, doesn’t work :
Error: This board doesn’t support libopencm3 framework!
As expected I would say, it was not in the table of supported combinations on the platformio site.

Tried : lib_ignore
lib_ignore = mbed-rtos, mbed-events, mbed-fs, mbed-net, mbed-rpc, mbed-dsp, mbed-USBHost, mbed-USBDevice
in the platformio.ini.

Same result : FLASH overflowed by 52 bytes

I’ll have a look at compiler options

Seems that the most FLASH saving options are there in pio run :
-fno-exceptions -fno-builtin -ffunction-sections -fdata-sections
I observe the standard libraries :
-lstdc++ -lsupc++ -lm -lc -lgcc -lnosys
Shouldn’t there be any newlib / nanolib ?