Thanks for the rescue. I too have been having this problem after a small edit to the program and assumed it was related to the watchdog functions I was using. However, I had added a literal string printing to the serial post ending with !!!. Removal of the exclamation marks solved the problem.
It's a bit bizarre but I always thought that, aside from escape characters, the contents of a literal string were basically ignored.
It's been 5 years and this problem is still actual.
I'm zero in programming, so I use maxuino to do my projects!
Was just trying to upload the standard firmata on my arduino atmega 2560.
The usual mistake:
avrdude: stk500v2_ReceiveMessage(): timeout
keeps coming out.
I read the whole thread and tried to do anything I had a decent understanding about: like installing different firmware (0023 ecc).
But the mistake stays.
I see here really experienced people.
Is there anybody, that could help me on this one?
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.
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
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"
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.
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:
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 ?
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.
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.
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
Select your chip AT90USB82
Open the port (USB CABLE BUTTON)
Click the red book with the arrow pointing towards it
Find Genuino-usbserial-atmega16u2-Mega2560-R3.hex
Press the reset button on the board (YOU MUST DO THIS)
click run
(WHEN THE PROCESS HAS FINISHED CLICK [start application]
RESET THE BOARD AGAIN WITH THE ON BOARD RESET SWITCH (YOU MUST DO THIS)