Debugging issue - ItsyBitsy M0 Express - JLink

I am trying to set up JLink debugging on an Adafruit ItsyBitsy M0 Express (SAMD21). I have my JLink connected to the baord and I am able to flash a sketch and start debugging. The issue is that whenever a debug session is active, the Serial port from the board does not appear and this causes the sketch, which uses Serial, to hang.

This is my configuration:

platform = atmelsam
board = adafruit_itsybitsy_m0
framework = arduino
lib_deps = nrf24/RF24@^1.4.5
debug_tool = jlink
upload_protocol = jlink

Do I need to add something more?

Same as Launch debug template don't work with SAMD21 board with jlink and Arduino framework - #2 by maxgerhardt?

Thanks, however, moving the initial breakpoint to after the Serial.begin does not work for me. The USB port does not reappear in Device Manager.

Have you tried removing the bootloader? (like this)

I have not. I have an Adafruit ItsyBitsy M0 Express, not an M0 Feather. What are the ramifications of removing the bootloader, seems rather dramatic for future use of the board.

The bootloader is just an additional program loaded into the first section of flash. You can reflash it any time since the bootloader binary is available, so absolutely no non-reversible thing is done to the board.

Hi @maxgerhardt , excuse the delay, I have been having Community access issues.

Removing the bootloader and adjusting the sketch link address seems to have improved the situation. What I see now is that the sketch fails to detect the Serial attachment when I start debugging. In the following code:

void setup() {

  // delay(5000) ;
  while (!Serial) {
    yield() ;
    // some boards need to wait to ensure access to serial over USB

The code never exits the “while” loop. This only happens when starting the debugger. If I use Upload and Monitor the sketch works. It appears the monitor is not connecting to the serial output when run under the debugger.

Set a breakpoint after the while(!Serial) { yield(); } code as to never interrupt the MCU while it’s answering / setting up USB stuff. Use a separate terminal program like HTerm - der-hammer to conenct to the USB-Serial. Does that work?

@maxgerhardt That is what I have done, and the breakpoint never gets hit because the while loop never exits.

If I manually break execution, I see the lop being executed, never exits.


build_type = debug

in the platformio.ini and upload the firmware normally. Does the firmware still not get out of the while loop when connecting?

The USB-Serial device appears without problems?

Yes, with explicit debug build the serial works as expected, no issue.

I notice when start debugging the terminal window does not attempt to open a monitor connection.

And it never did that. “Start Debugging” via JLInk only connects via SWD, not to the USB serial.

However it’s not normal that the MCU still doesn’t detect connection to its virutal USB serial when the port is opened…

@maxgerhardt Well there was a subtle clue in your post. Platform IO does not open the monitor port (serial) when starting debugging. I attached a terminal emulator (external to VSCode) after starting debug and my breakpoint is now hit.

So, the question now is, can PIO and VSCode have an internal monitor window open? Is it possible to configure the launch conditions for the debugger to do that?

But that’s exactly what I asked if you did that with HTerm and you said


You should be able to create a new PlatformIO CLI and use the pio device monitor command as normal.

That is a little better, however, one still has to kill the Monitor terminal and create a new one when starting debugging.

Then maybe an issue should be filed for an option to start debugging + monitor together (or with a small delay since the virtual USB port won’t be open immediately) → Issues · platformio/platformio-vscode-ide · GitHub

@maxgerhardt Thank you for the help, I posted a feature request :slight_smile: