Arduino Mega 2560 + avrdude + cmd = stk500v2_ReceiveMessage(): timeout


I am trying to use the command line to upload hex files to an arduino Mega 2560. Trouble is that it just times out.

I can upload the file using the IDE and that works, but if I use exactly the same command in cmd (copied from the verbose output), i just get:

avrdude: Send: . [1b] . [01] . [00] . [01] . [0e] . [01] . [14]
avrdude: Recv:
avrdude: stk500v2_ReceiveMessage(): timeout

Interestingly, if I press the reset button just at the right moment, it uploads fine (but that usually takes 10-15 tries to get right).

Is there a way to fix this that doesn't involve burning a newer bootloader version?


(p.s. it has nothing to do with exclamation marks.).

I am able to copy and paste the command line from the IDE to cmd and it works fine with my Mega 2560.

Is your IDE using the “wiring” protocol instead of “stk500v2”? There was recent changes to the IDE to use “wiring”, because it supported the auto-reset better or something.

I have noticed that, on my installation at least, I use differnt version of AVRDude, 5.10 and 5.11, when using the IDE and the commandline
They act a bit different some times, although I don’t remember how :smiley:

Avrdude v5.10 does not support the wiring protocol. You need to use v5.11 that comes with the Arduino IDE.

It is 5.11, and I am using nothing different from the IDE, I literally copied this line:

E:<path removed>\arduino-1.0\hardware/tools/avr/bin/avrdude -CE:<path removed>\arduino-1.0\hardware/tools/avr/etc/avrdude.conf -v -v -v -v -patmega2560 -cstk500v2 -P\.\COM6 -b115200 -D -Uflash:w:C:<path removed>\AppData\Local\Temp\build3892705149468659154.tmp\AstroEQ5.cpp.hex:i

I should mention I am using arduino 1.0.1

You should update to v1.0.4, it has fixes for what you are having by using the "wiring" protocol instead of "stk500v2" for Mega2560s.

Or you could edit your boards.txt and change the line to,


But I still recommend updating to v1.0.4.

Yup, that fixed it.

Not sure why the other one works in the IDE, but not in command prompt. I suppose it doesn't matter now there is one which works in both.