Skip to main content
GS1
Senior III
December 22, 2020
Question

Hardfault (Usage Fault INVSTATE) on STM32H743 - how can I find the position where the fault happened?

  • December 22, 2020
  • 4 replies
  • 3260 views

I have a system with several SPIs and logging of data to SD Card. During a test which logged data over night the system ran into a Hard Fault (INVSTATE) after some hours.

My questions:

What is the reason for an INVSTATE Hard Fault?

How can I detect, where the fault occurred?

I dumped the Memory of the Stack (MSP = 0x2406DB20) and the registers - see screen0693W000006GbHoQAK.pngI see adresses like 0x0808C3E9 in the stack, but not at the address where MSP is pointing to.

How do I have to interpret this?

This topic has been closed for replies.

4 replies

waclawek.jan
Super User
December 22, 2020

0693W000006GblZQAS.pngStacked PC is zero but that's consequence of the faulty code. LR is 0x0808C3E9, it means that instruction which called the routine which caused the fault, is at address jus before 0x0808C3E8 (bit 0 being set means Thumb mode).

JW

GS1
GS1Author
Senior III
December 22, 2020

Thank you very much, Jan! Now I already assume the reason for the Hard Fault... Will check for a solution.

Tesla DeLorean
Guru
December 22, 2020

Calling a NULL pointer? Should check callback or stucture elements are non-zero or assert if not within expected ranges.

See previous routines to dump registers​ often quicker than debug view.

Tips, Buy me a coffee, or three.. PayPal VenmoUp vote any posts that you find helpful, it shows what's working..
GS1
GS1Author
Senior III
December 22, 2020

Hm... I can see from the linker list that the area where 0x0808C3E8 is located must be within HAL_SPI_IRQ_Handler:

  i.HAL_SPI_IRQHandler                    0x0808c30c  Section       0 stm32h7xx_hal_spi.o(i.HAL_SPI_IRQHandler)

  i.HAL_SPI_Init                          0x0808c548  Section       0 stm32h7xx_hal_spi.o(i.HAL_SPI_Init)

How could it happen that the HAL is calling a NULL pointer?

The address of my HAL_SPI_RxCpltCallback/TxCpltCallback is not taken from an address pointer in RAM! I am not using DMA, where this would apply.

NULL pointers are checked in the HAL as far as I can see.