How to make stm32duino support sprintf under Arduino frame?

I have tried add build flags but no effect?
build_flags =
-Wl,–undefined,_printf_float
-DENABLE_HWSERIALLP1
-DPIN_SERIALLP1_RX=PC0
-DPIN_SERIALLP1_TX=PC1

or how to enable it like this

could you help me?

1 Like

Looking at the file boards.txt from which that menu is generated, it looks like you are after:

GenF1.menu.rtlib.nanofp=Newlib Nano + Float Printf
GenF1.menu.rtlib.nanofp.build.flags.ldspecs=--specs=nano.specs -u _printf_float

This gets used in platforms.txt in c.compiler.elf.flags

I just don’t know if you shove it in like build_flags = -Wl,--specs=nano.specs,-u _printf_float or something else… it looks about right given that example you gave for the Arduino Nano/atmega328.

The docs tell you exactly how to do it.

build_flags = -D PIO_FRAMEWORK_ARDUINO_NANOLIB_FLOAT_PRINTF

in the platformio.ini.

The python builder code will handle it then.

2 Likes

thank you for your help