I’m using the Arduino IDE 1.8.16 on OSX to program my Seeed Xiao SAMD21. When I upload code, it runs immediately, no problem. However if I unplug the USB and attach power or reattach the USB the chip just sits there until I either reprogram it or use the tweezers to manually trigger a reset. What’s going on?
Seems like the yellow LED and the bootloader is somehow related to this, so I’ll mention that the only time the yellow LED goes on is if I trigger the reset myself or reprogram. I’m not doing anything at all with pin 0 (since someone somewhere suggested that may be relevant).
Any guidance appreciated.
Hi there,
SO , not uncommon. Really 
can you post the code you are trying? use the code tags above “</>” paste it in there . 
chances are you have the While Serial in the init or Setup.
void setup() {
Serial.begin(9600);
while (!Serial); // <--- THE CULPRIT!
// ...
}
void setup() {
Serial.begin(9600);
// Wait up to 3 seconds for serial monitor, then proceed anyway
uint32_t timeout = millis();
while (!Serial && (millis() - timeout < 3000));
// rest of setup code...
}
remove or comment it out , use a timer.
HTH
GL
PJ 
The code I’m running is quite big, and I will work on getting a minimal example, but my serial code is all switched using the preprocessor.
#define SERIAL_LOG false
#if SERIAL_LOG
#define LOG Serial.print
#else
#define LOG while(false)
#endif
void setup() {
#if SERIAL_LOG
Serial.begin(9600);
uint32_t timeout = millis();
while (!Serial && (millis() - timeout < 3000));
#endif
}
void loop() {
...
LOG("this and that...");
...
}
I just verified that the Blink code fails to reproduce this problem (though I’m not convinced it ALWAYS fails to reproduce the problem).
I’ve convinced myself that it’s a problem with my own code, so that’s nice I guess. I’ll spend some time pinpointing the problem.
It seems the problem was caused by operating on some nan values. I don’t know why the startup condition changed that, but it was reading zeros from some other hardware, an accelerometer. Clearly my fault, but the seeed studio deciding to abandon the fight and stop talking to the USB port every three minutes made the whole thing a headache, not to mention the mountain of “Disk Not Ejected Properly” messages that seem to have no meaning.