Hardfault debugging with S32DS_3.4

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Hardfault debugging with S32DS_3.4

Jump to solution
575 Views
OliverTian
NXP Employee
NXP Employee

Hello,

If you met hardfault when debugging with S32DS 3.4, you can do the follow steps and find the information where triggered the hardfault.

 

  1. Copy the follows data into notepad and save as ‘.gdbinit’


    define armex

      printf "EXEC_RETURN (LR):\n"

      info registers $lr

     

      if (((unsigned int)$lr & 0x4) == 0x4)

      printf "Uses PSP 0x%x return.\n", $psp

      set $armex_base = (unsigned int)$psp

      else

      printf "Uses MSP 0x%x return.\n", $msp

      set $armex_base = (unsigned int)$msp

      end

      printf "xPSR            0x%x\n", *($armex_base+28)

      printf "ReturnAddress   0x%x\n", *($armex_base+24)

      printf "LR (R14)        0x%x\n", *($armex_base+20)

      printf "R12             0x%x\n", *($armex_base+16)

      printf "R3              0x%x\n", *($armex_base+12)

      printf "R2              0x%x\n", *($armex_base+8)

      printf "R1              0x%x\n", *($armex_base+4)

      printf "R0              0x%x\n", *($armex_base)

       

      printf "Return instruction:\n"

      x/i *($armex_base+24)

      printf "LR instruction:\n"

      x/i *($armex_base+20)

    end

     document armex

    ARMv7 Exception entry behavior.

    xPSR, ReturnAddress, LR (R14), R12, R3, R2, R1, and R0

    end

     



  2. Place the file into the folder of S32DS_3.x, like C:\NXP\S32DS_3.4\S32DS\build_tools

  3. In S32DS, S32DS –> Window –> Performances –> Debug –> GDB –> GDB command file
    Set as below
    OliverTian_2-1744856832689.png

     

  4. Debug as general and when meet hardfault, you can input armex in Debugger Console to get more information from stack
    OliverTian_3-1744856832740.png

 

Cheers!

Oliver

 

0 Kudos
Reply
1 Solution
573 Views
OliverTian
NXP Employee
NXP Employee

Hope this will help you.

View solution in original post

0 Kudos
Reply
1 Reply
574 Views
OliverTian
NXP Employee
NXP Employee

Hope this will help you.

0 Kudos
Reply