This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

How to trace back hard fault handler

What's the proper way to debug what's causing my eval board to reset? I'm assuming I need to put a breakpoint in the hard fault handle, but how do I trace that back to the source of the error? Or should I modify the handler?

I also noticed that the breakpoint in the hardfault handler isn't triggered unless I step through the code line-by-line. Is this expected?

image description

Parents
  • You said that something causes your eval board to reset. Hardfault handler given by Nordic SDK does not cause reset. Search your project for NVIC_SystemReset and put a breakpoint there. You should see the call stack in Keil to tell you how it ended up there. If the call stack isn't pointing to anything sensible then check go to memory (after hitting th breakpoint) and type 'SP+0x14' It will give you exact code address of the function (stack push operation of LR register) that caused it. infocenter.arm.com/.../index.jsp

    once you get the code address from the memory (value at SP+0x14) you can look into .map file generated for you application and find out which function is located at that code address

    If there are no soft reset in your project then check if the board is getting enough power. There is a register NRF_POWER->RESETREAS, which should tell you the reason of current reset.

    If you are using softdevice, then you cannot step through the code without doing some tricks. below are the search results for more information on that. This one, and this one.

Reply
  • You said that something causes your eval board to reset. Hardfault handler given by Nordic SDK does not cause reset. Search your project for NVIC_SystemReset and put a breakpoint there. You should see the call stack in Keil to tell you how it ended up there. If the call stack isn't pointing to anything sensible then check go to memory (after hitting th breakpoint) and type 'SP+0x14' It will give you exact code address of the function (stack push operation of LR register) that caused it. infocenter.arm.com/.../index.jsp

    once you get the code address from the memory (value at SP+0x14) you can look into .map file generated for you application and find out which function is located at that code address

    If there are no soft reset in your project then check if the board is getting enough power. There is a register NRF_POWER->RESETREAS, which should tell you the reason of current reset.

    If you are using softdevice, then you cannot step through the code without doing some tricks. below are the search results for more information on that. This one, and this one.

Children
Related