Upload Timeout Error on Mega 2560 - Not Sure What Changed

I had the same problem, and searching I found that:

In one comment it says:

Another possible reason for this error for the Mega 2560 is if your code has three exclamation marks in a row. Perhaps in a recently added string.

3 bang marks in a row causes the Mega 2560 bootloader to go into Monitor mode from which it can not finish programming.

"!!!" <--- breaks Mega 2560 bootloader.

To fix, unplug the Arduino USB to reset the COM port and then recompile with only two exclamation points or with spaces between or whatever. Then reconnect the Arduino and program as usual.

Yes, this bit me yesterday and today I tracked down the culprit. Here is a link with more information: String with three exclamations - Programming Questions - Arduino Forum

So in my code were strings with "!!!". I deleted them and now the program uploads with no problems.

I am experiencing this with a UNO board.
Serial Comm is working fine to the UNO.
Upload to another MEGA board is fine so i assume its not my PC thats a problem.
But upload to the UNO board gives me this timeout problem.
Could it be possible that the boards programmer itself is faulty?

I noticed that some of you had a similar scenario that I experienced where it seemed like no posted solution online helped the problem. I managed to unbrick the mega 2560 by a few steps and two sources that I will provide credit to.

I followed Nick Gammon's guide to flashing both the ATmega 2560 and the 16u2 chips using an Uno through the arduino IDE. Follow his instructions here:

and the source codes are provided on his git page. His programmer can be saved into your sketchbooks

After flashing the 16u2, the USB will be unrecognizable. This is mentioned on Nick Gammon's section about the 16u2. As I was flashing off of Windows 8.1 I instead used Atmel Flip as my dfu programmer http://www.atmel.com/tools/FLIP.aspx.

The "L" led on the mega should be flashing if you're in dfu mode. Disconnect the wires to the Uno if it is. Next I recommend following this youtube video on how to use Flip with the 16u2.

When selecting the hex file to load locate the arduino folder on your C drive (for windows) then go to /hardware/arduino/avr/firmwares/atmegaxxu2/arduino-usbserial and select the Arduino-usbserial-atmega16u2-Mega2560-Rev3.hex file.

Before I did this I flashed the combined file and turns out the address was out of range.

Unplug and plug in the mega after and a new com port should appear in your device manager/IDE

hello guys...

i started my own arduino for my project..

after the assembly of entire board, i successfully uploaded the firmware to both atmega16u2 using atmel's FLIP software and atmega2560 as guide from gammon's forum Gammon Forum : Electronics : Microprocessors : Atmega bootloader programmer...

when i tried to upload blink code to my board it shows timout error...

Sketch uses 1,554 bytes (0%) of program storage space. Maximum is 253,952 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 8,183 bytes for local variables. Maximum is 8,192 bytes.
C:\Program Files\Arduino\hardware\tools\avr/bin/avrdude -CC:\Program Files\Arduino\hardware\tools\avr/etc/avrdude.conf -v -patmega2560 -cwiring -PCOM16 -b115200 -D -Uflash:w:C:\DOCUME~1\Krishna\LOCALS~1\Temp\build08e4957f02c018eb579e11ddc64f9701.tmp/Blink.ino.hex:i

avrdude: Version 6.0.1, compiled on Apr 15 2015 at 19:59:58
Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
Copyright (c) 2007-2009 Joerg Wunsch

System wide configuration file is "C:\Program Files\Arduino\hardware\tools\avr/etc/avrdude.conf"

Using Port : COM16
Using Programmer : wiring
Overriding Baud Rate : 115200
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 done. Thank you.

can anyone help me in solving this problem weather it is hardware or software side
........

firmware for atmega16u2 is "arduino_dfuserial.hex"

Hi,

Thanks yampilop

I remove !!! and WORKS :slight_smile:

Regards

Joao

I was having the same issue for a couple days on a custom PCB with an ATMEGA2560 chip on it. After trying many different things, re-installing the FTDI drivers fixed the problem for me.

I think that when I started using those cheap Chinese Arduinos, the ones with the CH430 USB to serial converter IC, the drivers for the CH430 conflicted with the drivers for the FTDI chip. Also, upgrading my OS could have caused the FTDI drivers to stop working as well, though I am not sure.

I hope this works for you guys!

In my case, the solution for "avrdude: stk500v2_ReceiveMessage(): timeout " error was to remove any connectors plugged in the digital pins 0 and 1 (I had an Arduino Mega 2560 shielded with RAMPS 1.4 and a servo connected to D1). These pins are reserved for Tx/Rx and having any device connected to them will mess the normal communication between PC and the board. I wish you good luck!

If your RX ,TX of arduino is connected to any circuit,,uplaoding will be failed,,cause it needs RX,TX pin for uploading programme,so First remove the RX,TX connection,uplaod the code ,then connect again to your as usual circuit

pkrakow:
I recently started prototyping a new system with a Mega 2560. This is my 4th arduino system, and my 1st one using a Mega.

I have a simple program that I have successfully loaded on the Mega (it toggles some digital pins and sends some serial messages). Something's changed, and now I can't upload new images to the board. When I try to upload, I get the following error messages:


Binary sketch size: 4560 bytes (of a 258048 byte maximum)
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_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 0x10
avrdude: initialization failed, rc=-1
Double check connections and try again, or use -F to override
this check.

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_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 0x11
avrdude: stk500v2_disable(): failed to leave programming mode

I'm trying to track down the source of the problem. Here's what I know:

  1. The Green "on" light is on when the board is powered up.
  2. The "L" light flashes when I power up the board (indicating that the bootloader is present).
  3. The code that I loaded on the board still runs (I can see the digital pins toggling).
  4. I have the arduino IDE pointing to the correct COM port and setup for the Mega board
  5. I have tried two different PCs
  6. I have disconnected all of the external circuits that were attached to the Mega

Does anyone have any debug ideas? I have a scope, so I can capture an image of the serial lines during upload if that would help.

Hi,

I am also getting the same error but till now unable to fix it.I have arduino mega2560 board which is showing the same error as mentioned abobe.

I have tried the Resetting while compiling and tried to dump the arduino usb serial code also and tried even stk500boot_V2_mega2560.hex.

But it is showing in device manager for the Board detection but unable to dump the code.While dumping it is showing me the same error.

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

If somebody please help regarding this it will be great as i have spend almost 1 week on this issue but still no success

Regards,
Vipin

vipinmishra:
Hi,

I am also getting the same error but till now unable to fix it.I have arduino mega2560 board which is showing the same error as mentioned abobe.

I have tried the Resetting while compiling and tried to dump the arduino usb serial code also and tried even stk500boot_V2_mega2560.hex.

But it is showing in device manager for the Board detection but unable to dump the code.While dumping it is showing me the same error.

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

If somebody please help regarding this it will be great as i have spend almost 1 week on this issue but still no success

Regards,
Vipin

I just started working on this similiar problem today and am trying to figure it out. Looking through this thread would be a good place to start.

I'm experiencing the same issue with the timeout error for my Arduino Mega on a MacBook. And no it's not in the '!!!' because I don't have that. The Arduino Uno is still working but the Arduino Mega isn't. I'm looking for an answer for so long now! Please someone help :(!

I am getting the same error when i try to upload something to my Arduino mega 2560 rev3 + EMW3162 WiFi Shield. When i disconnect the shield it works fine ? Did someone heave solution for this ?

yampilop:
I had the same problem, and searching I found that:
arduino - avrdude: stk500v2_ReceiveMessage(): timeout - Stack Overflow

In one comment it says:
So in my code were strings with "!!!". I deleted them and now the program uploads with no problems.

The above was exactly the problem in my Sketch, changed it as outlined and it downloaded just fine.

Thanks for the help

What worked for me...
I had this error time after time.
Finally, I unplugged one of the 3 devices I had plugged into the USB ports on my laptop and moved the Arduino USB cable to this vacant port.
Worked! - I have no idea whether this was coincidence or not.

Elchickeno:
When i disconnect the shield it works fine ?

Hey Elchickeno,

I don't know, you tell me.

I've been having this problem too

I figured out it was because of an (addhandler) within some code i wrote using visual studio, Since the system has absorbed the port handler and is constantly using it and didn't close, i resorted to closing down the process that was abusing the handler (GTAV) yes, I'm a game modder....

Anyway, If you have any programs that are auto booting from windows which take over the comport with handlers, you should close the process down, Reconnect the board after 5 seconds, It will work perfectl

(Not related to the problem above)
(just a tutorial on how to reflash the firmware on the sainsmart mega2560):
If you've burned another hex file to your sainsmart 2560 Make sure you have atmel flip to burn the bootloader of your specific chip, You will need to use Genuino-usbserial-atmega16u2-Mega2560-R3.hex if you're using a sainsmart 2560 (which is what i use) the firmware hex is inside the arduino firmware folders, Just do a search for it and you're good to go.

  1. Short the two top most pins near the usb socket of your board to enter DFU
  • Before you can use atmel flip to flash the bootloader, you need to install the dfu drivers for your board
  • To do this follow these instructions
  • After entering DFU, go to device manager and update the drivers for your [libusb-win32 devices]
  • To do this look for the file usb in Flip 3.4.7 folder and click next, This will install the dfu driver
  1. Select your chip AT90USB82
  2. Open the port (USB CABLE BUTTON)
  3. Click the red book with the arrow pointing towards it
  4. Find Genuino-usbserial-atmega16u2-Mega2560-R3.hex
  5. Press the reset button on the board (YOU MUST DO THIS)
  6. click run
  7. (WHEN THE PROCESS HAS FINISHED CLICK [start application]
  8. RESET THE BOARD AGAIN WITH THE ON BOARD RESET SWITCH (YOU MUST DO THIS)
  9. UNPLUG THE ARDUINO
  10. REPLUG IT BACK IN

SUCCESS!

I was having this problem too in one of my 2 arduino mega boards and only with a program that is > 1000 lines of code.

The work around I found was to let the source coding uploading while grab a cup of coffe...

It seams that after some time, lets say 5 minutes, the code ends up uploaded.

I hope that this work around works for you too.

Thanks.

@ jascf

Problems like that tend to be associated with an antivirus program or similar.

I have a Dell notebook with Windows 10 Pro 64 bits and Arduino 1.8.3.

When I upload a simple code (17 lines) the task finish successful, as seem below:

Arduino: 1.8.3 (Windows 10), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"
.......
Sketch uses 5970 bytes (2%) of program storage space. Maximum is 253952 bytes.
Global variables use 873 bytes (10%) of dynamic memory, leaving 7319 bytes for local variables. Maximum is 8192 bytes.
......
Writing | ################################################## | 100% 0.98s
......
Reading | ################################################## | 100% 0.77s
....
avrdude: verifying ...
avrdude: 5970 bytes of flash verified
avrdude done. Thank you.

When I upload a medium size code (190 lines) the task get lot of time and finish unsuccessful:

Arduino: 1.8.3 (Windows 10), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"
........
Sketch uses 22130 bytes (8%) of program storage space. Maximum is 253952 bytes.
Global variables use 1564 bytes (19%) of dynamic memory, leaving 6628 bytes for local variables. Maximum is 8192 bytes.
.........
Writing | #################################################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

| 100% 214.64s

avrdude: stk500v2_ReceiveMessage(): timeout
.......
avrdude: stk500v2_getsync(): timeout communicating with programmer
avrdude: stk500v2_ReceiveMessage(): timeout
avrdude: stk500v2_getsync(): timeout communicating with programmer
avrdude: stk500v2_ReceiveMessage(): timeout
.........
avrdude: stk500v2_ReceiveMessage(): timeout
An error occurred while uploading the sketch

May someone have a hint how cam I solve this issue?

I had this problem and I solved it, Solution is so simple if you have another Arduino. I change the board from tool>board then programmed another Arduino, then I came again to my required mega Arduino and it worked.