Panel For Example Panel For Example Panel For Example

MCU Debugging Without a Reset

Author : Adrian September 02, 2025

During product development, it's common to encounter program anomalies during testing or after a device has been shipped. Often, these issues cannot be reproduced when attempting to debug the device again, leaving developers to painstakingly analyze log files to determine the point of failure.

However, it is possible to debug a device in its live state. By connecting a debugger without re-downloading code or resetting the MCU, you can preserve the current program state, making it much easier to find and fix bugs.

Implementation Method

First, flash the compiled project to the MCU. It is critical that the code running on the MCU is identical to the project you intend to debug. This ensures that the program location from the MCU aligns with the debugging symbols of your project.

Different development environments have different procedures for attaching to a running target. Below are the steps for the MDK, IAR, and STM32CubeIDE environments.

MDK

  1. Create a new .ini file with the following content:

    LOAD %L INCREMENTAL. In the debug settings, load this as an "Initialization File" and uncheck the "Load Application at Startup" option.

  2. Uncheck the "Reset after Connect" option.
  3. Uncheck the "Update Target before Debugging" option.
  4. After applying these settings, you can start a debug session to set breakpoints and inspect the MCU without resetting it.

IAR

In IAR, no extra configuration is needed. You can use the built-in "Attach to Running Target" feature directly.

STM32CubeIDE

Configuration in STM32CubeIDE is flexible. It is recommended to duplicate an existing Debug configuration and then modify the copy.

  1. Under Debugger -> Reset behaviour, set the Type to "None".
  2. Under Debugger -> Misc, uncheck the "Verify flash download" option.
  3. Under Startup -> Load Image and Symbols, edit the settings to disable the "Download" option.

Conclusion

Using these methods to debug without resetting the MCU preserves the live operating state, allowing you to reconnect a debugger to set breakpoints, step through code, and inspect memory. This technique is highly effective for identifying and locating bugs, especially intermittent faults that are difficult to reproduce. Note that if the MCU's Read-Out Protection (RDP) is enabled (Level ≠ 0), this method will not work, as debug access is blocked.