Firmware size increased more than twice after adding _printf_float flag

Floating point operations and code are known to be costly in runtime and heavy-weight in flash. Same goes for printing formatted floating point stuff. Otherwise they can’t implement all the what’s specified for floating point maths, like NaNs, infinities, etc. Adding printf() alone as opposed to leaving it out is a huge flash impact. So this is expected.

Especially since your Bluepill with its STM32F103C8 is a Cortex-M3 chip with no Floating-Point-Unit (FPU) hardware to help do stuff. Software implementations must compute everything, like add, subtract, multiply, divide,… (see related blogpost)

To see exactly which exact functions and code is added, you can have GCC generate a .map file (Generate a .map file - #8 by Krishna_Chaitanya) and look at the differences between a non-floating point printf and floating point printf versions with tools like Amap | Sergey Sikorskiy.

Of course, smaller versions than those included by standard with the GCC standard libraries exist.

4 Likes