cancel
Showing results for 
Search instead for 
Did you mean: 

STM32H742VG HardFault()

APlot.1
Associate II

Dear comrades!

I have encountered a problem while debuging my STM32H742VG project.

I am falling into HardFault just after system init and do not know any reason why it is happening.

I am starting my MCU with HSI clock and debugign with a STLink v2 debugger.

Could anyone help me with solving the problem please?

6 REPLIES 6

Use a Handler that outputs actionable data, and with an understanding of the registers/state inspect the offending code in a disassembly.

Super early check stack alignment and RAM used.

T​urn off "run to main" and walk in the code.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..

Thank you - I will try this.

But first I would like to ask you if there is an easier way 'cause I have never tried to solve problems via disassembly.

Maybe a blank-default way to start th MCU? I just think that there is something very simple I am forgeting to turn on at the start...

You could walk your code and look for errant pointer. Check malloc/new​ don't fail, returning NUL pointers.

Check alignment issues.

Check the FPU is enabled.

Check it is linking the right libraries.​

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..

Well I have looked through the dissassembly and it seems that nothing is written to the flash.

Could it be due to StLink V2 do not support STM32H7 cores?0693W000008xXlKQAU.png

The code does seem oddly placed in memory. It is at the 1MB deep point, and the vector table is some place else.

You'd probably want to review the memory model employed in the project, the scatter file (.SCT) and the map file (.MAP)

Make sure the check box item to download before debug is checked.

If using a debug script, make sure that LOADs the file or you flash it manually prior to debugging

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..

I have solved this problem just using the J-Link debugger ^^