Suddenly cannot upload sketch to arduino

Hi,

I was developing as usual, and suddenly the IDE / uploading process starts beahving strangely.

I am able to compile the program.

But when i upload it to my arduino mega, it flashes the leds normally and when it stops the flashing, in the IDE nothing happens, it keeps with the phrase "Uploading to I/O Board" it doesn´t passes to Uploaded state.

When i hit the STOP button it shows the following error message:

Could not delete C:\DOCUME~1\LUISSO~1\LOCALS~1\Temp\build3476415830577345086.tmp\Wiseware_it1_17_05_2011.cpp.hex

This phrase appeared a little later:

avrdude: stk500_2_ReceiveMessage(): timeout avrdude: stk500_2_ReceiveMessage(): timeout...

Does anyone has any idea, whar might be the problem.

Thank you!

Hold Shift while you click the upload button, and it'll give you a lot more info as to what's being exchanged to/from the board.

My money's on the wrong COM port selected... :sweat_smile:

Hi,

I was doing some more testing, and the problem doesn´t happen with other sketches i have.

Only happens with this one...

Any ideas

Only happens with this one...

So it happens with a sketch that you are not going to show us and you ask why? If I was that good I would pick lottery numbers.

Grumpy_Mike:

Only happens with this one...

So it happens with a sketch that you are not going to show us and you ask why? If I was that good I would pick lottery numbers.

OK, you guys (not just you) have really got to quit being that rude around here... it's generally understandable that someone posting their first question here wouldn't immediately realize that we can't help them without seeing what the code is, and would generally be protective of their code by default :P

That said, yeah, it just being "that one sketch", um... hmm. Ya'think it has something to do with that one sketch itself? Hmm... ;)

Check your board selection under Tools->Board?

Just by sheer dumb luck, I happened to stumble across the same exact issue OP's having... the sketch is actually causing the upload to fail.

I'll explain why in a minute, but first, here's the solution: 1) open Windows device manager. 2) Properties on your USB serial port for the Arduino (it must be plugged in first) 3) Port settings. 4) Advanced. 5) Uncheck "Serial Enumerator". 6) OK, OK, close. 7) Upload your sketch with no more trouble.

Problem is that Windows tries doing Plug-N-Play detection on the device attached to the new serial port. It quickly opens the port, waits a blip of a second for a response, and closes it. It just so happens that it's also possible to hang Windows PnP detection if the sketch crashes really quickly and hangs the CPU that's supposed to be processing serial data. :zipper_mouth_face:

Found this out when I had a sketch running some program-testing ("porting" and testing FastLZ, basically), and the thing just crapped too much data out and crashed too quick. So it hung Windows' PnP detection. I picked PnP out when I saw a "Found new hardware" thing pop up saying it found a new Microsoft serial mouse. laff.

Windows then keeps the serial port held open, and since there's no way to "unplug" the serial device from the USB serial port, it'll just stay hung.

So yeah, chalk that one down in the knowledgebase... =P

really got to quit being that rude around here

It's not rudeness it is sarcasm

Hi,

I liked the sarcasm, it only hit me that i hadn´t post the code when you told me…
But i thought the problem wasn´t the code, because it compiles with no problem or warning, main reason why i hadn´t post it.

After a lot of hiting with the head, i copy pasted the all sketch to a new .pde and it seems to be uploading normally now :slight_smile:
Really really strange.

I´m going to read carefully your alternative FalconFour, just in case it happens to me.

Thank you guys!

But i thought the problem wasn´t the code, because it compiles with no problem or warning, main reason why i hadn´t post it.

Just because a sketch can compile without errors does not mean it does not have logical errors in it. If only that wasn't true. ;)

Lefty

... Could not delete C:\DOCUME~1\LUISSO~1\LOCALS~1\Temp\build3476415830577345086.tmp\Wiseware_it1_17_05_2011.cpp.hex ...

I would try manually deleting that file and see where that gets you!

mmcp42, basically that´s what i did…

cheers

First of all: “Sorry for my suboptimal english!”
I have the same problem.
But neither changing the USB Properties nor copying the content to another file helps me.
Arduino runs on my msi Laptop with Windows XP. My Arduino is a Mega 2560.
Everything worked fine, until I wrote a sketch for reading a Keypad Matrix.
I compiled it … fine. Upload worked, but several mistakes had to be found out.
So I put in some Serial.print to find out, where the problems happen.
After discovering the first problems, suddenly the upload problem dissapears:

Message:

Could not delete C:\DOKUME~1\Michael\LOKALE~1\Temp\build4989676371445933903.tmp\sketch_aug23a.cpp.hex

(It’s not possible to delete the file manually. )

After that, it’s not possible to upload any sketch.

Message:

processing.app.SerialException: Serial port ‘COM4’ already in use. Try quiting any programs that may be using it.
at processing.app.Serial.(Serial.java:144)
at processing.app.Serial.(Serial.java:76)
at processing.app.debug.Uploader.flushSerialBuffer(Uploader.java:75)
at processing.app.debug.AvrdudeUploader.uploadViaBootloader(AvrdudeUploader.java:93)
at processing.app.debug.AvrdudeUploader.uploadUsingPreferences(AvrdudeUploader.java:56)
at processing.app.Sketch.upload(Sketch.java:1603)
at processing.app.Sketch.exportApplet(Sketch.java:1568)
at processing.app.Sketch.exportApplet(Sketch.java:1524)
at processing.app.Editor$DefaultExportHandler.run(Editor.java:2293)
at java.lang.Thread.run(Thread.java:619)
processing.app.debug.RunnerException: Serial port ‘COM4’ already in use. Try quiting any programs that may be using it.
at processing.app.debug.Uploader.flushSerialBuffer(Uploader.java:99)
at processing.app.debug.AvrdudeUploader.uploadViaBootloader(AvrdudeUploader.java:93)
at processing.app.debug.AvrdudeUploader.uploadUsingPreferences(AvrdudeUploader.java:56)
at processing.app.Sketch.upload(Sketch.java:1603)
at processing.app.Sketch.exportApplet(Sketch.java:1568)
at processing.app.Sketch.exportApplet(Sketch.java:1524)
at processing.app.Editor$DefaultExportHandler.run(Editor.java:2293)
at java.lang.Thread.run(Thread.java:619)

Only after reboot it’s possible to upload the other sketches.
There is no program using COM4. I deinstalled the bluetooth drivers, the phonetools, and deaktived the AVGuard.

Could this be a Java problem?

sketch_aug23a.pdf (8.15 KB)

STRANGE SOLUTION!

I removed all "Serial.prints". ... upload ... ok ...

I inserted several new "Serial.prints". ... upload ... ok ...

Happy but a little perplexed!!!