26. April 2021 · Categories: Software

Sometimes it is very useful to attach a debugger to an already running target. With the STM32CubeIDE, the ability exists but is a bit convoluted to activate. This turns out to work:

  • start with your existing debug configuration, under Run|Debug Configurations…

  • Duplicate it and rename it to “Attach”

  • In Main, disable auto build

  • In Debugger, uncheck “Verify flash download”, and set the reset behavior to “None”.

  • In Startup, edit all the load images to no longer download

The option Debugger|Reset behaviour tells GDB what to do after it attaches:

  • Connect Under Reset will put the device in reset, then connect

  • Software System Reset will connect, then trigger a software reset

  • None will keep the device running