2020-05-14 04:21 AM
Hello Everybody!
[MCU] STM32F446RE
[FreeRTOS] 10.2.1
[CMSIS-RTOS] 2.00
[IDE] STM32CubeIDE 1.3.1
[FATFS] R0.12c
I am developing an application and I experience some strange hard fault errors. The applications does some basic logging on SD card (approximately at every second). The program has been running for about 2.5 days without any problem, but after 60 hours of running I encountered a hard fault exception. The Fault Analyzer states it is a FORCED and an IMPRECISERR error. I have checked that the tasks' stacks had not overflowed. The PC according to the Fault Analyzer is pointing to the middle of a function called "memmove" and the LR register is pointing to the "__ssputs_r" function. I assume the error could be caused by the file I/O functions or some standard string manipulating functions. The heap usage is at around 70% so there is plenty of free space remaining.
In fact I log everything into a single log.txt file(just appending new lines) and I have been thinking maybe some internal variable could overflow during file I/O? But it is just a guess.
In the log.txt file there are 22030 lines and its size is about 1MB.
The states of the registers are the following according to the Fault Analyzer:
SP (PSP): 0x20004e18
R0: 0xa5a5a5a5
R1: 0x97
R2: 0xa5a5a5a5
R3: 0x162
R12: 0xccccccc
LR: 0x800bb79
PC: 0x800c0b0
XPSR: 0x81000000
I have also attached the assembly codes where the LR and the PC points to.
Has anybody encountered with such problem?
This is the first time when I try to debug an error on register level.
Thank you for your help in advance.
Tamás
2020-05-16 08:28 AM
An IMPRECISERR means the instruction it points to is not the source of the fault, which makes it more difficult to debug.
Might be a failing malloc call somewhere, or writing to something out of bounds.
2020-05-16 11:14 AM