Debugging: Why does the green Restart Icon always rebuild entire project?

When debugging a project and stepping through code, sometimes I want to just reset and start the code over again. But if I click the green Restart icon, it goes through the whole compile-upload sequence and writes to the target all over again. This is with NO changes made to the source code. Is there any way to just Restart the code without going through all those steps? The code is already loaded in the target, I just want to restart it.


If no code files have changed and no macros have changed, the rebuild should be a no-operation not changing the .elf. The usual case is that the restart button starts a build which finishes without recompiled anything at all.

With what exact project are you experiencing a different behavior?

I’m debugging a Marlin build with STLink debugger. What seems to be happening is this:

  1. Start debug session with PIO Debug (green arrow).
    -Project compiles in terminal window, then
    -compiles again(?) in Debug Console window, then
    -Debug Console programs target ready to debug

    -Start debugging, hit a breakpoint, continue, etc. all work fine. But if I click the green Restart icon,
    everything listed in #1 above happens all over again.

  2. If the target has been programmed via #1 above, AND I switch the selection in the upper left
    pulldown to PIO Debug(without uploading), clicking the Restart icon during debugging will NOT
    recompile everything and just perform a restart as expected.

So, it seems that the only way to do a simple restart (without recompiling everything) is to switch to
PIO Debug(without uploading) after the target has first been programmed with the latest code with PIO Debug.

Is it supposed to work that way?

Do you use the “Skip pre-debugging” option in VSCode?