cstm32newlib

Hard fault on sprintf() with float after toolchain update


I have an opensource project (https://github.com/WhiteFossa/yiff-l), where I use STM32F103 MCU.

In firmware I have a lot of sprintf's with float parameters, for example:

char buffer[32];
sprintf(buffer, "Power: %.1fW", power);

I used to use pretty old arm-none-eabi xpack for a long time (IIRC it was 9.3.1 version) and everything was fine.

Then I had to reinstall my fedora, and of course I've got a newer version of arm-none-eabi. My project stopped to compile, I fixed some code and now it compiles again, but produces hardfaults on any sprintf with float.

If I exclude -u _printf-float linker flag, then hardfaults are gone, but of course I don't get float representations in my strings.

I'm pretty sure that problem is not in mine code, I've even tried to put sprintf as a first line in a main(), and still have the same problems.

What can cause such weird behaviour? How can I debug it? (never used to debug ARM disassembly).

P.s. I've tried to install older arm-none-eabi xpacks, but without any luck - the problem remains.

P.p.s. I've tried to play with optimization settings/changed release to debug and vice versa, set 4x more stack in sections.ld - everything without success.

Any help will be appreciated much.


Solution

  • Finally I was able to get my firmware running, with help of https://github.com/mpaland/printf

    I.e. I've just get rid of Newlib's sprintf() in my code.

    enter image description here