SW4STM32 and SW4Linux fully supports the STM32MP1 asymmetric multicore Cortex/A7+M4 MPUs

   With System Workbench for Linux, Embedded Linux on the STM32MP1 family of MPUs from ST was never as simple to build and maintain, even for newcomers in the Linux world. And, if you install System Workbench for Linux in System Workbench for STM32 you can seamlessly develop and debug asymmetric applications running partly on Linux, partly on the Cortex-M4.
You can get more information from the ac6-tools website and download (registration required) various documents highlighting:

System Workbench for STM32

why trace_printf("%f",x); triggers a HARD FAULT on a stm32 MCU?

I’m using a stm32 F413ZH microncontroller with HAL libraries (mainly written to be used with c but can also be used with c++) in eclipse, actually I managed to completely configure eclipse including semihosting and debug mode(openOCD), the basic project files and also I managed to manually adapt the basic project files given by STM32CubeMX to work with c++. So... now I can use HAL libraries in a c++ eclipse environment and test my code via OpenOCD and trace_printf trace_puts using semihosting.

Now, again, after struggling too much setting up an stm32 environment, I find myself stuck, but this time is different.

These last 7 days I have been looking for a solution to my problem and I have tried many suggestions from similar issues online but none of them has solved my problem.

Well, the thing I’m facing is a HARD FAULT when using trace_printf() in semihosting while debugging, if I use this function to print via semihosting an integer (%d) everything is okay and I can read the printed value in the OpenOCD console but when I tried to print a value with the %f formater the supposedly printed data wasn’t being shown in the OpenOCD console, then I read that in order to enable the printing of floating point values I needed to add -u _printf_float to the linker flags, so after adding the flag I tried to trace_printf() a floating value, an integer value or whatever data type but all of them using the %f formater but I keep getting a HARD FAULT using %f in trace_printf().

Stack frame:
R0 = 00666E69
R1 = 2004FE78
R2 = 2004FF00
R3 = 00666E69
R12 = F642D800
LR = 08005DE7
PC = 08006586
PSR = 01000000
CFSR = 00008200
HFSR = 40000000
DFSR = 0000000A
AFSR = 00000000
BFAR = 00666E69

By debugging step by step the HARD FAULT handler is triggered after this function is called: vsnprintf()

I’m using this LINKER FLAGS -T mem.ld -T libs.ld -T sections.ld -Xlinker gc-sections -L”../ldscripts” -Wl,-Map,”ThreePhaseSignals.map” specs=nano.specs -u _printf_float

My project settings are:

[Project toolchains

[Target processor settings

[C++ preprocessor

[Linker settings and flags

My _sbrk.c is:

my linker files are:

mem.ld is:

and sections.ld is:
the attached file in this post

On internet many people says that this is because printing floats consumes a lot of memory and probable the MCU is crashing due to memory overflow, so many suggestions aim to modify the linker script where stack and heap assignations are made, some others say that this hard faut is related to_sbrk.c in newlib.

I tried to adapt these solutions to my particular case but till now my problem still is not solved. I don’t know if I’m badly implementing the suggestions or simply my problem is different.

Can someone help me with this?



Also you seem not being using System Workbench for STM32, you may try suppress the --specs=nano.specs flag from your linker flags.

Bernard (Ac6)

I’m using eclipse which basically is SWSTM32. I tried supressing --specs=nano.specs countless times but it makes the problem worse, when removed the debugger doesn’t start correctly.

What other ideas do you have?


You might need “-specs=rdimon.specs -lc -lrdimon” on the linker command.