J-Link debugger gets stuck during init() method

I am trying to use a J-Link EDU Mini to debug a MKR WIFI 1010.
I wired up the two boards based on this information https://wiki.segger.com/Arduino_MKR_WiFi_1010

I tried to follow the method outlined https://medium.com/@manuel.bl/arduino-in-circuit-debugging-with-platformio-9f699da57ddc but found out that I needed to use a custom server as outlined here J-LINK — PlatformIO latest documentation

my platforio.ini looks like

[env:mkrwifi1010]
platform = atmelsam
board = mkrwifi1010
framework = arduino
lib_deps = arduino-libraries/WiFiNINA@^1.8.14
debug_port = :2331
debug_tool = jlink
debug_server =
/home/hangstrap/opt/SEGGER/JLink_Linux_V810h_x86_64/JLinkGDBServer
-singlerun
-if
SWD
-select
USB
-port
2331
-device
ATSAMD21G18A

I am used the MKR WIFI 1010 ‘Blink’ program which is running fine.

When I try to debug the application, the debugger stops in the arduino main.cpp method on the init() with a temporary breakpoint

The applicaton then runs to another temporary breakpoint at writing_digital.cpp, method diginalRead() line 113

  if ( (PORT->Group[g_APinDescription[ulPin].ulPort].IN.reg & (1ul << g_APinDescription[ulPin].ulPin)) != 0 )

The debug log contains

Program
received signal SIGTRAP, Trace/breakpoint trap.

The debugger is now stuck at this point.

Another application will stop in the one of the internal methods called from the delay() function

Program
received signal SIGTRAP, Trace/breakpoint trap.
Removing breakpoint @ address 0x000025B4, Size = 2
Read 4 bytes @ address 0x00004774 (Data = 0x18E40123)
0x00004774 in micros () at /home/hangstrap/.platformio/packages/framework-arduino-samd/cores/arduino/delay.c:58
58 return ((count+pend) * 1000) + (((SysTick->LOAD - ticks)*(1048576/(VARIANT_MCK/1000000)))>>20) ;

Please help

I’ve seen some stuff with SAMD21 debugging where, after debugging starts up, you actually need to press the green “Restar” button for it to function correctly.