Skip to main content
SWoon
Associate II
March 15, 2019
Solved

HardFault_Handler from stm32 + Fatfs + USB

  • March 15, 2019
  • 3 replies
  • 1359 views

Hello,

A project created in truestudio generates a HardFault_Handler.

There are 2 PCBs I made. PCB A and PCB B are the same circuit and components. I have confirmed that the operation is correct while writing the code in PCB A.

However, there was a problem with PCB B. My program is Fatfs + USB HOST MSC.

It repeats until it becomes f_open with while statement.

If (f_mount == FR_OK) to f_mount seems to be no problem. However, f_open fails to pass, and the process goes to HardFault_Handler.

How do I debug HardFault_Handler?

This topic has been closed for replies.
Best answer by Carlos Diaz

You can use the Atollic Truestudio Fault Analyzer available while debugging, it should give to you the information required.

0690X00000883t7QAA.png

3 replies

Tesla DeLorean
Guru
March 15, 2019

Use one of the many fault handler examples posted and try to pin down exactly where the fault is occurring in your code. You want to look at the assembler in the context of the registers and at what memory access was being attempted. In non GNU/GCC implementations I would look at stack and heap sizes.​

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
AvaTar
Senior III
March 15, 2019

> However, there was a problem with PCB B.

Most probably a symptom of a bug in your firmware.

> How do I debug HardFault_Handler?

Check the SCB register settings for fault reasons.

And try more than once. Stack issues often show inconsistent symptoms, interrupts are often the final straw that break the camel's (stack's) back.

Carlos Diaz
Carlos DiazBest answer
Associate
March 15, 2019

You can use the Atollic Truestudio Fault Analyzer available while debugging, it should give to you the information required.

0690X00000883t7QAA.png