Arduino Due: JTAG and SWD do not work after pressing erase button
After uploading via Microchip Studio, go to the GPNVM bits section of &quot;device programming&quot; window. Make sure boot mode is set to &quot;boot from flash&quot;. Also check that GPNVMBITS register is set to 0x00000002. Then press &quot;program&quot;. The sketch you uploaded to the MCU should now work.
So it seems what happens is that pressing the erase button resets the GPNVM bits so that the MCU boots from ROM, but then Atmel ICE + JTAG/SWD does not set the boot mode back to flash after (succesfully) programming the MCU.