Go Down

Topic: Uploding with avrdude (Read 25500 times) previous topic - next topic

horchi

Jan 27, 2008, 02:41 pm Last Edit: Jan 27, 2008, 02:42 pm by horchi Reason: 1
Hello,

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.

Code: [Select]
~/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:
Code: [Select]
avrdude: stk500_recv(): programmer is not responding

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

Regards
horchi

mellis

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?

horchi

The verbose output when it's not work:
Code: [Select]
~/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.
Greets
horchi

mellis

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


horchi

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.

horchi

mellis

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?

horchi

Quote
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 :(

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.

Regards
horchi

mellis

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.  

horchi

You are right! :D 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.

Regards
horchi

jarv

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

Code: [Select]

$ 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.

Code: [Select]

#!/usr/bin/perl -w
use Device::SerialPort;
Device::SerialPort->new("/dev/ttyUSB0")->pulse_dtr_on(100);

GrapeLabs

Hello,

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).

Code: [Select]

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


Lars Immisch

Hi,

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

I put it into the Makefile, like this:

Code: [Select]
upload: applet/$(TARGET).hex
     stty -F $(PORT) hupcl
     $(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH)

johannesk

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.

mwarning

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.

Mike T

Hi,

the patch for avrdude from http://www.mail-archive.com/avrdude-dev@nongnu.org/msg01815.html addresses exactly the mentioned problem.

  MikeT

Go Up