Skip to main content
Graduate
November 26, 2023
Solved

Get witch line has called Error_Handler(void)

  • November 26, 2023
  • 3 replies
  • 2169 views

Hi, I'm trying to develop a FW for one of my custom boards that has an ethernet interface.
I'm using STM32CubeIDE, I generated the code with the configurator, and without even writing a line of code, if I go into debug, during the initialization of the HAL the code immediately jumps to:

 

void Error_Handler(void){

 

I wanted to ask, Is there a way to know at which point the code jumped to Error_Handler(void), so as to try to understand where the problem is.
In other words, is it possible to run the code backwards or see from which line a certain function was called?

    This topic has been closed for replies.
    Best answer by TDK

    Sometimes the IDE parses things wrong. Look for the LWIP_ARP or LWIP_ETHERNET defines and ensure they're defined somewhere prior to the posted code.

    3 replies

    Graduate II
    November 26, 2023

    The more effective version would be to use the one that passes file and line, ie Error_Handler(__FILE__, __LINE__)

    Otherwise you'll need to fish out the LR register to understand where it was called from, or step out via a return. Via LR you can perhaps use the .MAP or .LST file, or disassembly

    Super User
    November 27, 2023

    If you set a breakpoint in there, you can examine the call stack in the debugger to see where it came from. Unwinding the stack at runtime can be done but is compiler-dependent and isn't very well supported on microcontrollers.

    FMass.1Author
    Graduate
    November 27, 2023

    Through your heIp I managed to get to the point where Error_Handler() is called. Here:

    FMass1_1-1701077571364.png

    But I can't explain one thing, the point in question is this, but that whole block of code is grayed out, as if none of the LWIP_ARP or LWIP_ETHERNET macros were defined
    How should I interpret this situation, should that code not be executed?
    Did I do something wrong in the configurator?

    TDKAnswer
    Super User
    November 27, 2023

    Sometimes the IDE parses things wrong. Look for the LWIP_ARP or LWIP_ETHERNET defines and ensure they're defined somewhere prior to the posted code.