cancel
Showing results for 
Search instead for 
Did you mean: 

HardFault_Handler from stm32 + Fatfs + USB

SWoon
Associate II

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?

1 ACCEPTED SOLUTION

Accepted Solutions
Carlos Diaz
Associate II

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

0690X00000883t7QAA.png

View solution in original post

3 REPLIES 3

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 Up vote any posts that you find helpful, it shows what's working..
AvaTar
Lead

> 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
Associate II

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

0690X00000883t7QAA.png