CubeIDE sprintf %f is not working
Hi there,
I imported a Attolic studio project to the STM32CubeIDEand everything works execpt printf...
I'm trying to get the sprintf running in the new STM32CubeIDE and there are already several fixes available:
- _estack = 0x2001ffff fix here: https://community.st.com/s/question/0D50X0000AldaPzSQI/cubeide-sprintf-does-not-work-with-f
- linking issues: https://community.st.com/s/question/0D50X0000AnrcyjSQA/how-to-use-float-in-printf
Unfortunately, none of these fixes work for me... In my linker file there is the following line: _estack = 0x20020000; /* end of 128K RAM */, which should be fine.
My linker settings:
gcc -mcpu=cortex-m4 -T"../stm32f4_flash.ld" --specs=nosys.specs -Wl,-Map="${ProjName}.map" -Wl,--gc-sections -static --specs=nano.specs -mfpu=fpv4-sp-d16 -mfloat-abi=hard -mthumb -u _printf_float -u _scanf_float -Wl,--start-group -lc -lm -Wl,--end-group
As you can see, -u printf_float is added and in the map file ../arm-none-eabi/lib/thumb/v7e-m/fpv4-sp/hard\libc_nano.a(lib_a-nano-vfprintf_float.o gets included.
Scanf however is working and I can read a float from a string...
sscanf(tmpConstChar,"%f",&tmpFloat);
sprintf(print_string,"New temperature setpoint: %2.2f\n", tmpFloat);Prints:
New temperature setpoint: .2fI really appriciate any input on this topic...
Thank you very much and best regards
Daniel