"Uploading to I/O board" never finishing

I have been making changes and uploading things for several weeks with no trouble. Arduino build 0021, MEGA 2560 via USB. Binary sketch size is now 29444 bytes (of a 258048 byte maximum). It compiles and gets to the message "Uploading to I/O bard" and never completes the upload.

The IDE is still responsive and I can cancel it, but then I get a message about it being unable to delete a temp file. If I try upload again, I get a message the COM port is in use. I have to either reboot or unplu/plug the USB to clear that, but then upload will fail again and again and... after that.

Update - I loaded a smaller sketch as a sanity check. That works fine. I commented out some currently unused code in the big project but the size stayed the same and it still failed.

I commented out some currently unused code in the big project but the size stayed the same and it still failed.

I think this proves that the compiler already knew the stuff was unused, and optimized it away. The used stuff stayed the same size, because nothing really changed.

Actually, it seems to have block sizes or something. I did more changes and got it back to 27600, which I am almost certain it had been up to or over before and it is still failing. Something else seems to trigger this besides just size. As mentioned earlier, old smaller projects do work.

You know, I presume, that there are 3 kinds of memory on an Arduino - flash, where the code goes, SRAM, where the variables and strings and stacks go, and EEPROM.

The only size that is reported is flash. The only use of EEPROM is in your code, so presumably you know how much of that you are using.

It is possible that you are overflowing SRAM, even though the sketch size is still relatively small. Do you have large arrays in the sketch? Or a lot of smaller ones?

No, I have a reasonable sized working set. I log operations to SD and move on. If there is a leak somewhere, that would be run time and not affect this.

Here is something bizarre...

On another attempt:

Binary sketch size: 27496 bytes (of a 126976 byte maximum)
avrdude: stk500_getsync(): not in sync: resp=0x00
avrdude: stk500_disable(): protocol error, expect=0x14, resp=0x51

Where did the additional 96 bytes come from? No changes were made.
But this time I got an error instead of an endless wait.

BTW, this is on a Win7 Started edition netbook. No changes were made to anything other than source code in my project from when it worked and other projects still work.

No changes were made to anything other than source code in my project from when it worked

Might I suggest, then, that this sketch is not compatible with the Mega, for some reason. If you post the sketch, perhaps we can help spot the difficulties.

Latest changes were purely program logic, not hardware related. No, for proprietary reasons and practicality (it is very large and complex; I would be answering well meaning but irrelevant questions for days).

However, because I need to do some testing today, I tried uploading what worked a few days ago and now it fails to upload.

So something has changed, hardware wise. I am going to power off everything for a few minutes and look close for anything that could have pulled loose (but why does it setill load small sketches?)...

That last result where I got an error was from downloading an older version then seeing I could not select a MEGA 2560 and scraping that idea. It changed what board is selected.

Please note that this just invalidated the one test, it did not fix my problem. Nor did powering down. Now I have people about to arrive with hardware to go do a field test and I will look like an idiot unless something happens very quickly.

I just thought about that last test; it wasn't valid, so I did it again making sure the board was selected properly. It worked - I have code from a few days ago that will give me meaningful test results. I still have to figure out the issue later.

I will have to do some diffs and see what caused the problem. I actually added back a lot of the code on the fly today making adjustments to to the code from a couple of days ago that works during testing.Testing went very well and I didn’t look like an idiot even if I felt like a lucky one…

Testing went very well and I didn't look like an idiot even if I felt like a lucky one...

It's a great feeling when you can keep a secret. ;D

I"m having the exact same problem, my mega arduino never finished uploading, and the uploading button remains orange even after I get the timeout message.

I'm completely new to arduino and currently I can't even upload the "Blink" sketch-which is extremely frustrating.

What did you do to get it to work?

I went back to an earlier version of the code. Something about that specific code tripped up the IDE or loader. I have since worked back in all the changes with other tweaks and it is different enough that it didn't hit the obscure problem. you have something more basic wrong if you can't load demo/tutorial code.