STM32 Goes into HardFault_Handler() before going into HAL_Init()
Dear Community,
I am currently facing this issue where my STM32 Black Pill F411CE suddenly went into hard fault during runtime. The MCU was permanently gone and was not able to be re-programmed, and four others that I connected to the same hardware were also gone. After waiting some time, I replaced the Black Pill on my hardware with the same firmware. It was working; and it has been working fine for a couple of hours now. Note that the hardware is thoroughly tested and has been used for past few years, so I don't know if it could be a problem. Also, one of the MCUs that got damaged, is able to upload and even verify the code, but in the debug mode, it goes into Hard Fault Handler at start even before HAL Init. My understanding is that the flash got corrupted in all of them all at once. I have no RTOS in the firmware, and it uses STM32 HAL Libraries, and it is doubtful that there was any memory access issue, because the firmware is tested properly, and I really don't know how five microcontrollers flash corrupted all of a sudden. There is usage of DMA, and also, interrupts. Has anyone faced a similar issue?
I tried running the debugger. It directly starts in the hard fault handler instead of main. Here is the register info:
sp -> 0x2001ffd4
pc -> 0x8005408 <HardFault_Handler + 4>
Debugger Console:
Program received signal SIGTRAP, Trace/breakpoint trap.
HardFault_Handler () at ../Core/Src/stm32f4xx_it.c:95
95 {
warning: Could not fetch required XPSR content. Further unwinding is impossible.
Program received signal SIGINT, Interrupt.
HardFault_Handler () at ../Core/Src/stm32f4xx_it.c:99
99 while (1)
warning: Could not fetch required XPSR content. Further unwinding is impossible.
Regards,
Kunaal
