Uploding with avrdude


uploading a file from the commandline to the arduino (diecimila) works only once, independent if i use tho following command or the Makefile (make upload). After this the next trys are failing until i reconnect the arduino to the usb port.

~/devel/source/linslot/avr> /data/devel/arduino-0010/hardware/tools/avrdude -C/data/devel/arduino-0010/hardware/tools/avrdude.conf  -pm168 -cstk500v1 -P/dev/ttyUSB0 -b19200 -D -Uflash:w:/net/gate/home/wendel/sketchbook/linslot/applet/linslot.hex

Error Message:

avrdude: stk500_recv(): programmer is not responding

With the IDE it works ever. Any idea wats my mistake


Hmm... can you add "-v -v -v -v" to the end of the avrdude command line command and post the full output (when it doesn't work)? What sketch are you uploading? Try one that doesn't do any serial communication.

Does it always work or never work from the IDE?

The verbose output when it's not work:

~/devel/source/linslot/avr> /data/devel/arduino-0010/hardware/tools/avrdude -C/data/devel/arduino-0010/hardware/tools/avrdude.conf  -pm168 -cstk500v1 -P/dev/ttyUSB0 -b19200 -D -Uflash:w:/net/gate/home/wendel/sketchbook/linslot/applet/linslot.hex -v -v -v -v

avrdude: Version 5.4-arduino, compiled on Oct 22 2007 at 13:15:12
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/

         System wide configuration file is "/data/devel/arduino-0010/hardware/tools/avrdude.conf"
         User configuration file is "/home/wendel/.avrduderc"
         User configuration file does not exist or is not a regular file, skipping

         Using Port            : /dev/ttyUSB0
         Using Programmer      : stk500v1
         Overriding Baud Rate  : 19200
avrdude: Send: 0 [30]   [20] 
avrdude: Send: 0 [30]   [20] 
avrdude: Send: 0 [30]   [20] 
avrdude: ser_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding
avrdude: Send: Q [51]   [20] 
avrdude: ser_recv(): programmer is not responding
avrdude: stk500_recv(): programmer is not responding

With the IDE it's always working fine.
A reset of the arduino dosn't help, only a disconnect/connect of the usb cable fix the problem but again only for one upload. The sketch is the same which i can upload with the ide.

If you unplug and replug the USB, do you have to upload right away for it to work? Or can you wait a while?

i can wait (i tested 30 minutes now), it seems not depending on the time.
If i upload a sketch with serial communication the sketch AND the communication are working fine constantly.
The upload problem appears even if i use a sketch without any serial communication.


Weird. I'm not sure really sure what to suggest. You might try the avrdude mailing list. Does it help if you press the reset button on the board before trying to upload for the second time?

Does it help if you press the reset button on the board before trying to upload for the second time?

no reset don't help. The loaded sketch works fine before an after reset but due to the upload issue it don't change anything. I tried avrdude delivered with arduino-0010 and avrdude from the kubuntu package but it doesn't matter :frowning:

I will have some additional trys like upload with the IDE after uploading from the command line, the try to upload from the command line again, ...
After this i will contact the mailing list.


Hmm, my guess would be that the auto-reset of the Diecimila isn't being triggered by avrdude after the first time. The Arduino IDE explicitly toggles the DTR line before uploading (which resets the board) whereas using avrdude from the command line relies on the fact that the standard Linux driver for the FTDI chip sets DTR when you open the serial connection. It is, however, possible to set a bit on the port (HUPCL) that prevents the line from being reset when you close the connection, meaning that nothing happens to the line when you re-open the connection (i.e. the board doesn't get reset). I don't know why/how HUPCL would be getting set, but it's possible (maybe the FTDI driver for your kernel works differently than the ones I've tried).

Try playing with the timing of the reset vs. the avrdude command. That is, try pressing the reset button a couple seconds before, or just before, or just after, or a couple seconds after (etc.) when you press enter on the avrdude command line.

You are right! :smiley: Many thanks!
Pressing the reset direct before ore direct after starting the command works. Best result when pressing the same time.

I can use this as a workaround until it will be fixed in avrdude or the ftdi_sio module.

BTW: I'm using kernel 2.6.22-14.


If you want to pulse the DTR right before using avrdude on linux it is pretty simple. On ubuntu first get the perl serial module

$ sudo apt-get install libdevice-serialport-perl

And then make a small script to pulse the dtr and run it prior to avrdude, this allows me to reliably flash every time.

#!/usr/bin/perl -w
use Device::SerialPort;


thanks for this DTR pulse tip! Here is a slightly enhanced version of the Perl code, that automatically determines the serial port from the -P avrdude parameter and calls the avrdude program after the DTR pulse. Rename the original avrdude to avrdude.org and store the Perl script under the name avrdude. Don't forget to make it executable.

Now programming with the Eclipse AVR-plugin always works without any problems. Another advantage: if no Arduino is connected to USB, the script immediately returns with an error (instead of having avrdude waiting for a timeout).

#!/usr/bin/perl -w
use Device::SerialPort;
use FindBin qw($Bin);
foreach (@ARGV)
    if ($_ =~ /-P(\/dev\/.+USB.+)/)
        print (STDERR "Resetting DTR on " . $1 . "\n");
select(undef, undef, undef, 0.1);
print (STDERR "Executing avrdude\n");
system($Bin . "/avrdude.org " . join(" ", @ARGV));


for me it was enough to do a stty -F /dev/ttyUSB0 hupcl

I put it into the Makefile, like this:

upload: applet/$(TARGET).hex
      stty -F $(PORT) hupcl

I had to change the UPLOAD_RATE in the Makefile to 57600. The DTR reset or stty command don't seem to be necessary for me. Using Ubuntu 8.04.

I have the same problem.
It works when I do both, set the speed to 57600 and hit the reset button on the arduino board right before.


the patch for avrdude from [avrdude-dev] [patch #6866] bug #26703: [Feature Request] Support device reset for 'arduino' programmer type addresses exactly the mentioned problem.


How to I download and apply the patch on a Mac?



Hi Glynton,

You might need to install some required packages, if you don't already have them: subversion bison flex automake libusb-dev

The patch made it in the latest svn version (r845). You can get it using subversion:

svn co svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude
cd avrdude
make all

There is currently a bug which prohibits compiling this version under Windows, but it shouldn't hurt on the Mac.


Can someone post a current Makefile? I have a duemilanove so I changed all the settings per the comments

PORT = /dev/ttyUSB0
MCU = atmega328p
F_CPU = 16000000

It tries to compile but errors out on core.a? I also have issues compiling anything that has a external module in it. Like the etherShield library. Do I need to move the library files into the applet dir? Or is there some ENV variable I need to set?

/usr/bin/avr-gcc -mmcu=atmega328p -I. -gstabs -DF_CPU=16000000 -I/home/bakers/arduino-0018//hardware/arduino/cores/arduino -Os -Wall -Wstrict-prototypes -std=gnu99  -o applet/Button.elf applet/Button.cpp -L. applet/core.a -lm
cc1plus: warning: command line option "-Wstrict-prototypes" is valid for C/ObjC but not for C++
cc1plus: warning: command line option "-std=gnu99" is valid for C/ObjC but not for C++
applet/core.a(Print.o):(.data+0x6): undefined reference to `__cxa_pure_virtual'
collect2: ld returned 1 exit status
make: *** [applet/Button.elf] Error 1