cancel
Showing results for 
Search instead for 
Did you mean: 

unable to debugg Hardfault error on STM32F412ZG

AVK.1
Associate

Hello community,

I am trying to write time critical code which involves an STM32f412ZG Nucleo 144 board and a RPi communicating over SPI protocol. I have an IMU sensor communicating to STM32 board via I2C interface.

I have 3 tasks, which function as follows,

  1. Task 1 - Keep reading data from RPi via SPI 4 (DMA enabled). This task has been scheduled for 1 KHz , with Highest priority
  2. Task 2 - Read a certain flag which when true should execute a certain function and delete the task. This task has been scheduled for 25Hz, with lowest priority.
  3. Task 3 - Read the data from IMU sensor and find the Orientation. Task is scheduled for 100 Hz, with in medium priority.

The tasks 1 & 3 when executed, run smoothly and outputs expected behavior. The task 2 when executed individually also runs smoothly and outputs expected data. However, when these tasks are integrated, there is a hardfault error which occurs as soon as the code is executed.

I am new to this kind of programming and finding it very hard time to debug the issue.

I suspect that the DMA is causing the issue after looking in to the call graph of stack analyzer.

Below is the call graph snapshots.

0693W000007BZzEQAW.png0693W000007BZzJQAW.png0693W000007BZz9QAG.png 

I request the community to help me debug the issue. Please let me know if more details are required.

Thanks,

Ashish Kumar

3 REPLIES 3

Really doesn't look like a call tree at the fault

Instrument the Hard Fault Handler (I've posted code dozens of times)

Have it output fault state to serial console.

Inspect the disassembled code at and prior to the faulting PC, see what it is doing, determine if the fault address is relatively consistent or not.

Check things like adequate stack depth.

For consistent failure check C code at site, if pointers can be checked or qualified.

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

Hi @Community member​ ,

Thanks for your quick response.

I request you to kindly provide a link to the topic. Since, I am a newbie with the real time programming, I am not sure how to inspect disassembled code. Could you also help me with any general documentation to do it.

https://community.st.com/s/global-search/hardfault_handler_c

ARM has Technical Reference Manuals

Here mostly we're looking to see the instruction flow, likely to be failing on a LDR/STR (load or store), look also a C code at failing address.

Debugger should have a "Show code at Address" type interface

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