Skip to main content
Gpeti
Senior
January 6, 2026
Question

Floating point printf formatting error using ARM GCC newlib-nano on STM32H753

  • January 6, 2026
  • 4 replies
  • 737 views

I am working on STM32H753 (with eval board EVAL 2).

I am modifying an existing firmware built without libc and without startup files.

I need to convert floating point variables to strings, so I want to use as little as libc as possible. I choosed newlib-nano for memory size.

I compiled with `-mfpu=fpv5-d16 -mfloat-abi=hard -specs=nano.specs ...` and linked with `-mfpu=fpv5-d16 -mfloat-abi=hard -specs=nosys.specs -specs=nano.specs -u _printf_float -nostartfiles ...`

I also added the definition of symbols required by the libc and reserved a memory area for the heap.

 

I tried to write a string from a double variable with the following code (it's code for debug only, I know it may overflow the char array depending on float value):

char my_string[64];
double my_double = 1.3;
sprintf(my_string, "%.3f", my_double);

But the content of the string (checked by dumping the memory on debugger) is `1300` and not `1.300`

(i tried with different values and format specifiers)

Am I missing something ?

4 replies

Pavel A.
January 6, 2026

What is the version of the toolchain? 

Gpeti
GpetiAuthor
Senior
January 6, 2026

Sorry, it is arm-none-eabi-gcc 10.2.0

ST Technical Moderator
January 6, 2026

Hello @Gpeti 

Are you using STM32CubeIDE?

In order to give better visibility on the answered topics, please click on 'Best answer' on the reply which solved your issue or answered your question. Saket_Om
Gpeti
GpetiAuthor
Senior
January 6, 2026

No. I build with make and gcc and I load and debug with Lauterbach trace32