Eclipse and avrdude issues

I've searched through this forum and read all the relevant posts that I've been able to find, but I'm still at a loss, so I'm hoping somebody out there can help.

I've set up Eclipse so that I can develop code for my Duemilanove w/ 328, and I can compile code to .hex just fine. I've followed the directions to set up avrdude, but it only works intermittently, and I one of two responses when it doesn't. Sometimes I get the "out of sync" error, the Rx light blinks three times on the board, then I get nothing. Other times it just doesn't respond and avrdude hangs and I have to kill it. In this case, it strikes me as the arduino thinking it's connected to a serial monitor, as it transmits data constantly (the Tx light blinks rapidly or is solid, which seems to directly correspond to what sketch is on the board) and doesn't respond to received data, but this is just my best guess. The directions I followed came from the playground page detailing how to set up eclipse, but I found that it worked most reliably if I changed the baud to 57600 (same baud as the Arduino IDE).

I know that my settings can work, as I've successfully uploaded numerous sketches. Also, the Arduino IDE works reliably. One other odd thing I've found... When uploading from Eclipse won't work, I go to the Arduino IDE and upload any sketch (I just use one that counts up from 0 forever!), then go to Eclipse when it's done and avrdude will work! It'll then work for a short period of time, then go back to not working if I don't upload a sketch for a while. I can repeat this process over and over again reliably!

Any thoughts on how to get avrdude to work reliably through Eclipse?

Thanks
Billy

I'm using Eclipse with a Duemilanove 328p and don't have any issues.

What OS/CPU are you using?

I'm using OSX 10.5 with a Core Duo (32bit only). It seems the java rxtx libraries have problems on 64bit architectures ( http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1244869368 )

What Arduino are you using? and if you are using a USB<->serial adapter, which one?

As I said above, I'm using a Duemilanove w/ 328. It has USB on the board, so I don't need a serial adapter.

Sorry, I meant to talk about the OS, but forgot! I'm using Win 7 RC1 32-bit (not 64-bit, so that's not the issue) and have the latest FTDI drivers installed (I'm sure of this, I just downloaded them a few days ago).

I know that somebody is going to suggest that it's just windows 7 because it's a new OS, but I'm disinclined to blame my problem completely on Microsoft. The Arduino IDE works reliably, it's just calling it from Eclipse that's odd. Could it be something with different versions of avrdude? The avrdude exe that winAVR installed is a different size than the one included with arduino-0016.

It may be an auto-reset problem.

The arduino-IDE will bring the DTR pin on the serial-adapter low to force the arduino to reset and allow for a program to be uploaded. Avrdude doesn't do this on it's own.

Some serial ports will bring DTR low when opened and some don't. Famously, the FTDI adapter doesn't normally bring DTR low in Windows, but does on OSX and Linux. Windows 7 may be doing something weird with DTR.

Try hitting the reset button on the arduino immediately AFTER hitting upload in Eclipse. (really I mean AFTER, not before). I would think this would always be required on Windows though, unless you have a patched avrdude.

I wondered about the reset issue. On this page (Arduino Playground - Eclipse), about halfway down the page, under the title "A couple more things to do..." is a section that talks about this:

A couple more things to do...

The Arduino environment issues a reset command prior to uploading. Newer versions of AVRDude (such as the one shipped with CrossPack) will also do this. If you have an older version and are using Windows, you can overcome this problem with this little app. Attach:newavrdude.exe

To use this, you need to:

  1. rename the avrdude.exe that is currently being used by eclipse to "realavrdude.exe" 2) Make sure that in the eclipse configuration for avrdude, you specify the port override. This should add something like "-P//./COM7" and it needs to be argument #3 (if this causes a problem for anyone, let me know and I'll build in some configuration stuff). 3) copy newavrdude.exe into the same directory as realavrdude.exe, and rename it to avrdude.exe

I've followed this, hoping to eliminate that possibility, but I'll have to see if it is in fact resetting the Arduino. I'll try to reset it manually each time and see if that works, too.

The issue is a bit muddier than is spelled out on that page.

The facts:- if the DTR line on the FTDI chip of the Duemilanove goes low, it will restart the Duemilanove.

  • avrdude doesn't try to reset the arduino prior to uploading(even the newest versions). The page was wrong about that... you can check the avrdude source.
  • the eclipse plugin doesn't try to reset the arduino prior to uploading
  • DTR has no defined level when a program doesn't have control of it. DTR could be low, high, or floating. It is almost always floating.
  • Mac and Linux computers will USUALLY bring DTR low while opening a serial port. This will cause an Arduino to reset.
  • Windows USUALLY leaves DTR floating while a port is opened. Which has no effect on an Arduino.

The problem is those "USUALLY"s... there is no reason to believe that a new version of the FTDI driver or a new OS version won't change the behavior of the DTR line. It's possible that Windows 7 randomly sets the DTR line when a port is opened... which wouldn't be an incorrect behavior.

the newavrdude program is quite old... you are probably better off just manually uploading if that works reliably.

I was actually the last person to edit Arduino Playground - Eclipse . If you figure out what is going wrong you can just add it to that page; it's a wiki.

Oh, remember to reset the arduino AFTER launching avrdude when manually uploading. The arduino is only in upload mode for a split second after being restarted.

Ok, I get it! I should be able to try doing it manually later tonight (I haven't been home all day). Just out of curiosity, what exactly does newavrdude.exe do, then?

I didn't make newavrdude, or use it. I believe newavrdude just brings DTR low for a couple milliseconds and then calls the real avrdude. After looking at it, newavrdude was made relatively recently, so I wouldn't fear it... too much.

I use a Mac... so I have the opposite auto-reset problem that you have. Eclipse and avrdude will always cause an auto-reset before trying to upload... stopping the auto-reset means physically disabling the DTR line >:(

The auto-reset feature is a bit of a mess...

Hi,

there is a feature request and patch for Avrdude which implements the auto-reset feature for the Windows and posix platforms. You are welcome to test whether it fixes your problems.

The more people test it, the higher is the chance to get it into a next official version of Avrdude.

Here is the feature request: AVR Downloader/UploaDEr - Bugs: bug #26703, [Feature Request] Support device... [Savannah]
and here the patch against the avrdude V5.8 source: AVR Downloader/UploaDEr - Patches: patch #6866, bug #26703: [Feature Request]... [Savannah]

gabebear wrote:
Some serial ports will bring DTR low when opened and some don't. Famously, the FTDI adapter doesn't normally bring DTR low in Windows, but does on OSX and Linux.

The DTR signal under Windows is never "floating" when the serial port is opened. Avrdude explicitly clears the DTR signal when opening the port:

From ser_win32.c:

      dcb.fDtrControl = DTR_CONTROL_DISABLE;
      dcb.fRtsControl = RTS_CONTROL_DISABLE;

The DTR signal may either keep its state or clear it when closing the port. This depends on the serial port driver and the other end of the line (FTDI USB chip, WT-11 Bluetooth chip). I ran into problems with the Bluetooth driver and the Arduino-BT which keeps the state on closing.

Michael

Ya, DTR will never be floating on the FT232R... oops. The FTDI driver on OSX always brings the DTR line low briefly(no matter what it was set to on the last close), I don't use Windows much. The termios settings are supposed to be maintained between closing/opening the serial port, but it seems many drivers don't to it.

The DTR line on some serial chips (like the FTDI FT2232D) are general purpose IO pins.