Arduino Nano 33 IOT Debug: Why do I always have to start my code twice?

When I load my Arduino code in the debugger, using my Segger J-Link module, I get an automatic temporary breakpoint at Init(). Then I click the continue button in VS Code, and the code resumes but breaks again at some random location where there is no breakpoint set. It will not resume from this location. I have to hit the “restart” button, then I get another breakpoint hit at Init(), then if I resume it a second time the code will run correctly.

This happens 100% of the time whenever I load new code.

This is really painful to have to go through this process Every. Single. Time. What’s up here? Am I doing something wrong? Is there a configuration option I need to set? Somebody reassure me that the debugger isn’t just complete junk.


Problems like these have been obseved with the JLink + USB-enabled microcontrollers for a long time, e.g., Problems starting debug session with jlink on feather M0 and Hang Starting nRF52840 Feather Express Under Segger Debugger - #10 by geeksville.

As far as I know, nobody ever figured out why that happens in this configuration. Other microcontroller combinations with JLink do not have that problem.

That is mighty disappointing.