Trying to debug on SAMD21-based board, using arduino framework. Have tried several boards: Arduino MKR ZERO, Adafruit Trinket M0 (both SAMD21). Have also tried on Adafruit Feather M4 Express (SAMD51) - same result on all.
My goal to start is to get a functioning debug environment using the USB Serial CDC connection.
Starting with a very simple setup() and loop() as follows:
#include <Arduino.h>
void setup() {
Serial.begin(115200);
while(!Serial);
}
void loop() {
int ch;
ch = Serial.read();
if(ch > 0)
{
Serial.write(ch);
}
}
Start the debugging session, wait for it to land on the startup breakpoint, then simply click “Continue” - the USB connection fails with Windows “Unknown USB Device (USB Device Descriptor Request Failed)”. Debug single-stepping through startup inside int main(void): the USB attach attempt happens after executing “usbd.attach()” within “bool: USBDeviceClass::attach()” in USBCore.cpp, which is called from main() as USBDevice.attach().
I have tried powering the board from an external power supply and keeping the USB cable disconnected until after I start the code running in the debugger, same result.
Tried with the exact same debugger setup and simple Arduino setup() and loop() functions on an Arduino Nano33 BLE board (Nordic nRF52480 processor) and the USB CDC enumerated successfully.
Wanting to have the same success on the SAMD21/SAMD51 parts.
Any help would be much appreciated.
platformio.ini (for the MKR ZERO board):
[env:mkrzero]
platform = atmelsam
board = mkrzero
framework = arduino
debug_tool = jlink
upload_protocol = jlink
Tools:
OS: Win11
VSCode v1.89.1
PlatformIO v3.3.3