2019-05-27 08:04 AM
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:
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: .2f
I really appriciate any input on this topic...
Thank you very much and best regards
Daniel
Solved! Go to Solution.
2019-05-27 08:32 AM
Perhaps look at a disassembly to see why it is using the wrong code.
2019-05-27 08:32 AM
Perhaps look at a disassembly to see why it is using the wrong code.
2019-05-27 08:49 AM
Well thanks for this input. There is a file from Atollic studio called tiny_printf.c which overwritte the functions even though they were linked correctly... Removing the file and using the libs directly solved the issue.
Thanks and best regards
Daniel