XIAO MG24 USB not enumerating after reconnecting

Connecting the battery and USB and then loading the sketch works just fine, running fine after unplugging USB with S_R now at 2v34. After reconnecting USB doesn’t enumerate now. dmesg -w output → ([11422.887358] usb 1-2: new full-speed USB device number 8 using xhci_hcd) and then no more messages.

After the battery is disconnected and reconnected firmware is not running, S_R is sitting at 2v27 now, plugging USB back in doesn’t help, S_R goes to 3v3 and USB enumerates, but firmware not running, just red led blinking.

When reloading a different sketch the previous one briefly runs before the new one.

Turns out the firmware not running is probably due to ezWS2812 debug counter not running again.
Firmware runs fine when this library is not used. I’ll use a timer instead.

USB enumeration issue goes away when not using Serial.print… This is a common issue I’ve encountered before when trying to output data on a CDC port that is not connected breaks the device’s USB stack/hw until power is cycled. The SAMD11 firmware will need updating to block UART access when VUSB is not present. A workaround would be to detect VUSB somehow and not output any serial data, but can still end in a race condition.