Debugging hard fault (bummer)

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Debugging hard fault (bummer)

3,554件の閲覧回数
lokuate
Contributor III

I'm working on a project using MQX lite and KL15, I've been stuck in a hard fault for several days now...

I've obtained the following code to extract the PC from the stack and figure-out what is causing the hard fault (thank you Freescale):

__attribute__((naked))

PE_ISR(Cpu_ivINT_Hard_Fault)

{

  __asm volatile (

    " movs r0,#4       \n"

    " movs r1, lr      \n"

    " tst r0, r1       \n"

    " beq _MSP         \n"

    " mrs r0, psp      \n"

    " b _HALT          \n"

  "_MSP: \n"

    " mrs r0, msp      \n"

  "_HALT: \n"

    " ldr r1,[r0,#20]  \n"

    " bkpt #0          \n"

  );

  }


But saw the following code in an other forum (Cortex-M3: Tips/Tricks to debug a Hard Fault?)

The Cortex-M pushes 8 registers on the stack on Hard Fault exception. Here is a code to read the memory address that caused it:

MRS     R0,PSP                  ; Read PSP LDR     R1,[R0,#24]             ; Read Saved PC from Stack



In either case, both the #20 and the #24 offset returns 0x0 to R1 (supposed to be the PC that generated the hard fault)... A PC of 0x0 is either wrong or my code (along with MQX) has gone off on to the weeds big time.


I suppose the SP offset may be a different value but I have looked around the SP vicinity and have found a few probable code addresses related to MQX code blocks (Stack LIFO and 32 bit registers are easy to follow)... thus I suspect a problem with my MQX lite configuration... but I do not think I have messed with the MQX lite configuration outside of what Processor Expert allows me to... so could it be that Processor Expert has some potential MQX Lite kill switches available that it shouldn't have open to newbies like me?


I'm using serial port interrupts, 9600 bauds, I beak on the string composing routine and looks fine, I dunno if the serial port ISR is conflicting with OS Interrupts... But I have messed with priorities from 0 to 3 and all fail...


Any assistance will be much appreciated.


Kindest Reagards,

Carlos






0 件の賞賛
返信
6 返答(返信)

1,094件の閲覧回数
c0170
Senior Contributor III

Hello Carlos Rodrigues,

could you please read this article to get familiar with hard fault:

http://blog.feabhas.com/2013/02/developing-a-generic-hard-fault-handler-for-arm-cortex-m3cortex-m4/

Could you implement the approach which published in the following link. I am not familiar with the code from PE, therefore I would personally write my own hard fault handler.  DebugHardFault - ** Code Red Support Site **

Regards,

c0170

0 件の賞賛
返信

1,094件の閲覧回数
lokuate
Contributor III

Thank you Martin!!!

I did advance on this... I activated the trace (learning to use CW 10.3) and saw the following...

trace.png

So my problem seems to see a bad initialized pointer (*kernel_data->TIMER_COMPONENT_ISR)(); That has on itself Target address = 0x20000568 pointing deep in the weeds...

I never mingle with that pointer since to me it appears to be an internal MQX Lite pointer I that don't know how to change (If I knew how to change it I could fix it, but then again I'm learning how to use MQX Lite and CW), so if that pointer is the problem then a MQX Lite configuration setting is messed up, please help me out to figure out which one...

Thanks,

Carlos

0 件の賞賛
返信

1,094件の閲覧回数
c0170
Senior Contributor III

Hello Carlos Rodriguez,

how is your timer component set? What timer do you use? It might be helpful to share your project (if possible at least small portion of it with that timer component active), or share more details.

Without any deep details, just step through init phase and check where is timer isr pointer set. Why is an address 0x20000568 assigned to it?

Regards,

c0170

0 件の賞賛
返信

1,094件の閲覧回数
lokuate
Contributor III

Processor Expert automatically configures a SystemTimer1 for MQX Lite, I assume I do not have to set it manually, If I should set it manually please help me figure out how.

0 件の賞賛
返信

1,094件の閲覧回数
lokuate
Contributor III

I'm attaching the configuration of MQX Lite SystemTimer1 (created by default by PE) in PE's Component Inspector for your reference...

syst.png

Is there some additional steps I need to take to correctly configure the MQX Lite System Timer?

0 件の賞賛
返信

1,094件の閲覧回数
dave408
Senior Contributor II

Hi Lokutas​, did you ever figure this out?  I'm currently trying to debug a new hard fault exception and came across your post, and was curious.

0 件の賞賛
返信