Upload Timeout Error on Mega 2560 - Not Sure What Changed

Time-Out problem here also..

Name is Luc, first post here..

Noticed that once connected, my AtMege2560 has no problem with the first Sketch Upload.
But the second one starts giving problems.

After trying a couple of times, I've found that unplugging the USB-cable (power from iMac USB port) allows me to upload a sketch without any problem.
So for now, just unplug USB-cable before I upload....

Hope this benefits some more people.

Regards,
Luc

tonysnark's answer worked for me, looks like the USB hub wasn't providing clean enough power, plugging directly into the computer fixed the issue.

I have with the same problem with Mega2560. I have 3 pieces. Suddenly, I`ve got the same:
avrdude: stk500v2_getsync(): timeout communicating with programmer
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout

on 2 of them.
As it was the the problem was in '!!!' in the scketch!

The problem exists about 3 years already and still have not fixed.

Interesting that is appears on 2 of 3 my Mega 24560. The boards are same, was bought during last few monthes.

I have the same problem. In my case it only occurs in GNU/Linux, whereas in Windows everything works fine. It also worked fine before in GNU/Linux. I don't know why this suddenly started to happen.

Lucky me! I'm working on a fairly large project (9 peripherals) and my megas have started succcumbing to this bug. I'm an experienced programmer, and a bit manic about incremental backups, so I usually test frequently and zip my source every time I get something else working.

Last night it started. avrdude: stk500v2_ReceiveMessage(): timeout after adding some code. I noticed that after the failed upload, the mega was double-flashing at me. I suspect that means "corrupt program, upload it again". Trying the upload again, I notice the process looks normal for the first 1/2 of the time, the usual blinks, followed by the steady fast flashing of the upload. But then led13 just STOPS flashing. And a few sec later I get that error.

Unfortunately, when I try to upload again.. upload ANYTHING, it fails in the same manner. Looks to work for the first 1/2 of the time, then fails. On any short sketch I pull up, it doesn't matter.

I have to pull the USB cable from the mega for a sec to power cycle it. Plugging it back in again, it's back to doubletapping LED13, but I can upload to it again. Any other sketch is fine. But then I try to upload my big project again, and it's back to doubletapping LED13.

One of the sketches I was testing with at this point dumps a ton of hardware information as well as a bit of EEPROM, and I noticed this at the start of this mega's EEPROM. I don't know if it put it there when it got stuck, or if I just never wrote anything to EEPROM on this mega before. (I have quite a few here) Usually EEPROMs come from the factory as all FF's.

Flash Dump $100 bytes from $0 to $FF
$0000:  41 72 64 75 69 6E 6F 20  65 78 70 6C 6F 72 65 72  20 73 74 6B 35 30 30 56  32 20 62 79 20 4D 4C 53    Arduino explorer stk500V2 by MLS
$0020:  00 42 6F 6F 74 6C 6F 61  64 65 72 3E 00 48 75 68  3F 00 43 6F 6D 70 69 6C  65 64 20 6F 6E 20 20 3D    .Bootloader>.Huh?.Compiled on  =
$0040:  20 00 43 50 55 20 54 79  70 65 20 20 20 20 20 3D  20 00 5F 5F 41 56 52 5F  41 52 43 48 5F 5F 20 3D     .CPU Type     = .__AVR_ARCH__ =
$0060:  20 00 41 56 52 20 4C 69  62 43 20 56 65 72 20 3D  20 00 47 43 43 20 56 65  72 73 69 6F 6E 20 20 3D     .AVR LibC Ver = .GCC Version  =
$0080:  20 00 43 50 55 20 73 69  67 6E 61 74 75 72 65 3D  20 00 4C 6F 77 20 66 75  73 65 20 20 20 20 20 3D     .CPU signature= .Low fuse     =
$00A0:  20 00 48 69 67 68 20 66  75 73 65 20 20 20 20 3D  20 00 45 78 74 20 66 75  73 65 20 20 20 20 20 3D     .High fuse    = .Ext fuse     =
$00C0:  20 00 4C 6F 63 6B 20 66  75 73 65 20 20 20 20 3D  20 00 53 65 70 20 20 39  20 32 30 31 30 00 31 2E     .Lock fuse    = .Sep  9 2010.1.
$00E0:  36 2E 37 00 34 2E 33 2E  33 00 56 23 20 20 20 41  44 44 52 20 20 20 6F 70  20 63 6F 64 65 20 20 20    6.7.4.3.3.V#   ADDR   op code

A bit of googling shows people using "!!!" have been having this problem for the past several years. If the version infomation in that EEPROM is accurate, I probably should get my bootloader updated. I've never done that before. I did find several places that dance around the issue, and one or two that actually provide a bit of a walkthrough on the process. I'd like to know how long that process takes. I recall at least once in the past someone saying buring a bootloader on an arduino can take an hour or more. I have a number of them to update. I'd rather a workaround for the time being.

Anyway back to my problem. Since I had only changed a very small focused bit of code and figured something had to be wrong with it, I started trimming back. I found that changing the ORDER of a few Serial.print commands fixed it. This took me quite awhile to find, even though I had a small area to look through. Anyone that's been through the process of whittling down a sketch to find a hard lock bug knows how this goes. Slow. Having to physically unplug the arduino ever time? even MORE slow.

More googling. "Remove !!! from your serial prints!" Ok. That's nice. But I don't HAVE any of that. More googling. OK here's the HEX file. Checked it. I cannot find any occurrance of "!!!". I was hoping to be able to identify a bad HEX file before uploading it. All this plugging and unplugging of USB cables is getting hard on my gear while I troubleshoot. I'd like to know if a HEX file is bad beforehand. Earlier in the thread someone said there were different symptoms showing. I'd agree this does look like a class of problems rather than one specific bug. My lack of !!! in my code suggests I have a variation on the problem.

I assume that something else I am doing in the programming is causing "!!!" or its ilk to be generated in the sketch and causing the upload to be interrupted, or perhaps the verification step that I believe occurs after the upload. But I can't find $21 21 21 anywhere in my HEX file.

This bug is repeatable on three bare mega2560s

Does anyone have any new information on this problem? I was able to "hack" my way around the bug last night, but it's come up again today and I have a much wider front to search this time. I guess all I can do is get out the knife and start carving until I narrow down the cause, or more specifically, find a place I can make any change to the code to shift whatever it is into some other form that doesn't confuse the bootloader.

little bit of an update: the last one I got around by changing a Serial.println("") to Serial.println()
THIS time I commented out Serial.print("M"); and it uploads now. So terribly frustrating having computers using $RANDOM to figure out if they're going to work today.

Hi All,

After some testing here is what I found (or at least what I am experiencing)... and what I did to resolve this...

You would get the (Timeout) error when there is a condition in your code that causes the loop() function not to finish (the loop goes into a loop from within) and not come back to the main control, where the serial is waiting.

Inside my loop() function , if I tell the function to either:

  1. (do... while()...) and this does not come out, or,
  2. There a serial device is causing the loop() to re-read back on itself i.e. indefinitely calling itself back, then:

The loop() function will not come out, and you would get this error.

Try to disable all your code from the loop() function, upload, you should not see the error (should work), try then to un-remark chunks of the your until you get to the culprit bit.

I hope this helps.

Kind Regards
Heider Sati

Hi everybody, I'm Spanish, my English isn't very good but I will try to explain my problem.

My Arduino Mega 2560 doesn't work fine because that:

avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout

I try with 4 PC (Linux and Windows), with 2 wires and with 2 Arduino Mega 2560

I did all I see in this forum, and impossible, always the same "timeout" I can't do more that I see and I don't want to buy other Arduino again because i have two and bouth doesn't work

Help me, please!

I'd like to know how long that process takes. I recall at least once in the past someone saying buring a bootloader on an arduino can take an hour or more. I have a number of them to update. I'd rather a workaround for the time being.

If you have a spare Uno or Mega lying around, and a few hookup wires, you can reprogram the bootloader in a second or two.

My timing there is one second for the Uno, three seconds for the Mega.

Having said that, I have been having problems with my Mega recently, particularly on Ubuntu, for reasons that are not obvious.

I try with 4 PC (Linux and Windows), with 2 wires and with 2 Arduino Mega 2560

What sketch are you uploading? Can you post it please? Inside code tags.

It seems my Mega had old firmware on the Atmega8U2 (USB) chip. I replaced that - with considerable effort - and it seems to work better now.

See: http://arduino.cc/en/Hacking/DFUProgramming8U2

I'm uploading Blink but I tried with personal sketch:

/*
Blink
Turns on an LED on for one second, then off for one second, repeatedly.

This example code is in the public domain.
*/

// Pin 13 has an LED connected on most Arduino boards.
// give it a name:
int led = 13;

// the setup routine runs once when you press reset:
void setup() {
// initialize the digital pin as an output.
pinMode(led, OUTPUT);
}

// the loop routine runs over and over again forever:
void loop() {
digitalWrite(led, HIGH); // turn the LED on (HIGH is the voltage level)
delay(1000); // wait for a second
digitalWrite(led, LOW); // turn the LED off by making the voltage LOW
delay(1000); // wait for a second
}

AND THAT IS THE RESULT:

Tamaño binario del Sketch: 1.542 bytes (de un máximo de 258.048 bytes)
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer
avrdude: stk500v2_command(): failed miserably to execute command 0x13
avrdude: stk500v2_paged_write: write command failed
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_ReceiveMessage(): timeout

Could I suggest that you read the troubleshooting thread at the top of the forum and then if you still have issues post a new thread?

Hi,

I am totaly arduino newbie with some mega2560 boardclone and the same issue "avrdude: stk500v2_ReceiveMessage(): timeout". when try upload sketch (IDE 1.6.3) via USB-com port (CH340g onboard)

I have USBasp programmer too, but upload via programmer get stuck mega with both power- and L- led on. (ide write no error mesage - upload is done) Reset doesnot help.

I found one solid way how to upload new sketch.

  1. Connect USBasp and write bootloader (every time befor upload new sketch).
  2. Disconect USBasp and connect USB from PC (Win7) to board. (edit - USBasp can stay connected)
  3. Upload sketch (IDE 1.6.3) via USB/(com port)

Sketch is runing - so USBasp programmer and board is fine (echo test is ok too).

I have no idea why it works this way, can anybody explain? Still looking for more elegant solution for uploading sketch.

(Sorry for my english - have a nice day)

This can also be caused by user error, if you select ATmega2560 when your board is actually an ATmega1280, as was the case for me. :-[

ATMEGA2560 16AU 0731 is printed on chip - can it be 1280 ?

Terakon:
ATMEGA2560 16AU 0731 is printed on chip - can it be 1280 ?

Where did you buy it? Is 1280 laser-printed onto the chip, and 2560 written on top in crayon?

He He - Nick been buying on eBay again. . . . :grinning:

its from ebay - i know and write its clone - print on chip looks like this one

I am having the same problem with my mega 2560

It says:


Arduino: 1.6.4 (Windows 7), Board: "Arduino Mega or Mega 2560, ATmega2560 (Mega 2560)"

Sketch uses 6,916 bytes (2%) of program storage space. Maximum is 253,952 bytes.

Global variables use 468 bytes (5%) of dynamic memory, leaving 7,724 bytes for local variables. Maximum is 8,192 bytes.

avrdude: ser_open(): can't open device "\.\COM8": Access is denied.
avrdude: ser_drain(): read error: The handle is invalid.

Problem uploading to board. See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.

This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.

or it remains uploading forever...

I checked the firmware info and I have rev 0001. Arduino website says that there is no need to update the firmware if you have rev 0001.

I also replaced the avr folder of my IDE 1.6.4 with the avr folder of 0023. Also nothing...

I am out of ideas!

Hi everybody,

i often had the same problem: ...timeout...

By chance I found in one of my programs a line where I can switch the error on or off...

I show you a small part of my program. (The whole program has more than 2000 lines)

Please look to the comment-lines:

void parameter_holen(){
Serial.println(server);
if (client.connect(server,80)){ // Verbindung zum Server aufbauen
Serial.println("Parameter vom Server holen...");
http_request("parameter");
parameter_auslesen();
}else{

// If i uncomment the following line, i can't upload the program due to the timeout-error

//Serial.println("Parameter holen: Keine Serververbindung gefunden...");

resetFunc();
}
}

I think the timeout-error has also to be seen in combination with the rest of the program.

For me it is a very strange behavior of the IDE.

Good luck for all of you seeing the timeout error!

A mi me pasaba igual y no sabia la razón... la cosa era que en alguna parte del código tenia una línea de este tipo...

Serial.println("ENVIAR LLAMADA DE EMERGENCIA...!!!");

"LA SOLUCIÓN" fue quitar los símbolos de exclamación y listo...

Serial.println("ENVIAR LLAMADA DE EMERGENCIA..");

PRUEBEN ESTO Y ESPERO LES HAYA AYUDADO EN SOLUCIONAR SU PROBLEMA.