SAM-BA operation failed

i just had the "operation failed .... chip ID ... not supported" error, attempting to upload with DUE and Arduino 1.8.0, which had been succeeding just fine... uploading and serial monitor on the Programming USB port.

to make a long story short, it was caused by debug code that was spewing out a rapid stream of Serial.print() statements fairly soon after reset. i did have while (! Serial); in setup(). i suspected this was the case, so i changed the debug chatter to be silent on reset and require intervention to enable debug (my code has a command interpreter in it, but a toggle switch would do). problem immediately solved.

even with the "high chatter" sketch installed, i managed to get upload to work by pressing reset right before upload. took a number of tries to get it to upload. it immediately solved the problem.