I have an occasional (but very annoying) error with arduinos that suddenly refuse to accept a new upload. What seems to happen is this, occasionaly I will produce a dodgy sketch that will run maybe the first couple of lines, and then 'reboot' and start again. The first line is normally something like Serial.println("starting sketch abcd"); so what I see when I monitor the serial port is just the phrase "starting sketch abcd" re-cursing up the screen ad-infinitum. Not a big deal in itself, but the problem is that this recursing code seem to lock the arduino and somehow prevent a working sketch from uploading. If I fix my sketch (or find a sketch known to work) and attempt an upload, then the sketch will compile ok, start uploading and then just hang before eventually producing a time-out error if I leave it long enough. There seems to no cure except for infinite patience, after maybe a couple of dozen attempts, constant unplugging and re-plugging of the arduino, or maybe even a re-boot of the computer then I eventually get lucky and the uploads start to work again. Since this has happened on both my arduinos I guess this is some sort of system error rather than just a faulty unit.
So, my first question is is my diagnosis correct, is the recusive re-booting of the arduin preventing it accepting uploads, and if so, is there a cure for it?