How to debug STM32 startup code

Sysprogs forums Forums VisualGDB How to debug STM32 startup code

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #24326
    JimEli
    Participant

    I’m evaluating VisualGDB. Using STM32f4 Discovery board with HAL blinky program. How does one execute a breakpoint on the startup code prior to reaching main()?

    #24327
    support
    Keymaster

    Hi,

    Please simply set the breakpoint before starting debugging with F5 and VisualGDB will be able to handle this automatically.

    You can also modify the behavior of the “Step into new instance” command (F10 instead of F5) to stop as soon the program is loaded into the MCU (i.e. at the reset handler) via VisualGDB Project Properties -> Embedded Debug Tweaking.

    #24328
    JimEli
    Participant

    Sorry, but neither of those techniques are working for me. The program is halting on first line of main. I’m using USB STLink v2.1 and BP set inside system_stm32f4xx.c/SystemCoreClockUpdate function immediately turns white when I select F5.

    #24332
    support
    Keymaster

    Thanks for the update. This looks like a different issue. If the breakpoint circle is hollow inside, the code where the breakpoint is set is not a part of the debugged binary (e.g. it is not actually called from any other code and was hence discarded).

    You can double-check this by inserting the following line into the functions that don’t seem to work:

    asm("bkpt 255");

    It will trigger a breakpoint each time the line gets executed. If it doesn’t happen, the function is actually not called and using the “find references” command should help understand why this happens.

    If the breakpoint does trigger and you see the “bkpt 255” instruction in Disassembly, but the source code doesn’t appear, the problem is due to missing/mismatching debug symbols. If this is the case, we can provide more detailed instructions on diagnosing it.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.