Skip to main content
PMath.4
Senior III
February 6, 2020
Solved

STM32H743: sprintf not working in newlib_nano after upgrade from HAL 1.3 to 1.6

Not a question but a statement. I've just upgraded a very large project from HAL V1.3 to V 1.6. The code uses sprintf in a couple of places. This worked fine under 1.3 using newlib_nano. Under 1.6 the same statement gives a NULL return. Swapping to newlib_standard fixes the issue. It appears that the version of newlib_nano distributed under 1.6 has changed and is no longer reliable, at least for floats.

This topic has been closed for replies.
PMath.4
PMath.4Best answer
Senior III
February 6, 2020

Seems to be a CubeMX change - Just been through the project properties and the old version had "-u _printf_float" in Project -> Properties -> C/C++ Build -> Settings -> MCU Linker -> Miscellaneous.

The new version didn't. I'm pretty sure I didn't put it there

Anyway the solution is to put "-u _printf_float" in Project -> Properties -> C/C++ Build -> Settings -> MCU Linker -> Miscellaneous

4 replies

berendi
Principal
February 6, 2020

newlib is not part of HAL, it's distributed with the toolchain.

PMath.4
PMath.4AuthorBest answer
Senior III
February 6, 2020

Seems to be a CubeMX change - Just been through the project properties and the old version had "-u _printf_float" in Project -> Properties -> C/C++ Build -> Settings -> MCU Linker -> Miscellaneous.

The new version didn't. I'm pretty sure I didn't put it there

Anyway the solution is to put "-u _printf_float" in Project -> Properties -> C/C++ Build -> Settings -> MCU Linker -> Miscellaneous

berendi
Principal
February 6, 2020

newlib is not part of STMCubeMX either. There are no C/C++ build settings in CubeMX.

You mean STM32CubeIDE, don't you?

PMath.4
PMath.4Author
Senior III
February 6, 2020

"You mean STM32CubeIDE, don't you?"

No, I use Attolic, but the project was created by CubeMX which sets the project properties THUMB2, FP, etc.

I now understand the newlib library was "provided" by the toolchain but it is CubeMX that sets the default properties when you create a project from scratch