Eclipse, Arduino 2560 and AVRDude – timeout

I’m in the process of restructuring the polargraph firmware, and the first thing I’m doing is moving most of the functions out to a library that can be used by all polargraph firmwares (uno, mega etc).  So that’s easy, you’d think.  I’m a fairly naive c++ programmer so don’t be surprised that I’m trying to get it working in eclipse so as to have a decent overview of things, function names and whathaveyou.  I find it useful when making cross-cutting changes.

So I came across Eclipse/Arduino tutorial page,  which is really good, and got it working on a Duemilanove I have – beautiful!  That said, I can quite see why the Arduino IDE is popular even though it lacks functions.  Eclipse is the archetypal jack of all trades and master of none, and requires a load of configuration to even get started on things.

But the MEGA? Not so much.  I got stuck so went to see how the Arduino IDE does it, and pulled out the AVRDude command it was using (turn verbose output on for the uploading in preferences):

c:\Dev\arduino-1.0\hardware\tools\avr\bin>avrdude -CC:\Dev\arduino-1.0\hardware/
tools/avr/etc/avrdude.conf -v -v -v -v -patmega2560 -cstk500v2 -P\\.\COM55 -b115
200 -D -Uflash:w:C:\Users\sandy\AppData\Local\Temp\build4894098567197191708.tmp\
Blink.cpp.hex:i

That’s what it emits, but when I put that same text in at the command line, I am faced with

avrdude: stk500v2_ReceiveMessage(): timeout

Which is the same problem I was bumping into in Eclipse.  Well.

The fix

Turns out using the arduino or stk500v2 programmer, the board doesn’t get reset before programming.  I could get around this just by pressing the reset button and then uploading that same instant, mostly, but it’s not very clever.  Then I came across a better solution at this page discussing the error in avrdude 5.10 (I’m using 5.11 that comes with the Arduino IDE so I guess it’s still an issue), and that solution is just to use the Wiring programmer instead of the Arduino programmer that works fine on the Duemilanove, or the stk500v2 programmer that the Arduino IDE uses.

That worked fine.