avrdude-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [avrdude-dev] [bug #34339] back to back avrdude commands fail on dra


From: Xiaofan Chen
Subject: Re: [avrdude-dev] [bug #34339] back to back avrdude commands fail on dragon_isp on Ubuntu 10.10
Date: Thu, 8 Dec 2011 15:52:28 +0800

On Thu, Dec 8, 2011 at 3:20 PM, Joerg Wunsch <address@hidden> wrote:
> Follow-up Comment #10, bug #34339 (project avrdude):
>
> For those reasons, I'll probably add another commandline option to
> activate the hack (like, -x usb_wait_time=3).  Obviously, this
> requires Arduino users to change their Makefiles then in order to
> benefit from the hack, which poses the question why they could not
> change their Makefiles for a single avrdude command in the first place

I think the root cause of the issue is the following codes
in usb_libusb.c.

#if !( defined(__FreeBSD__) ) // || ( defined(__APPLE__) &&
defined(__MACH__) ) )
  /*
   * Without this reset, the AVRISP mkII seems to stall the second
   * time we try to connect to it.  This is not necessary on
   * FreeBSD.
   */
  usb_reset(udev);
#endif

I believe the above usb_reset() is no longer needed for most of
the Linux users now. It is usually only required for kernel versions
up to 2.6.28.
http://libusb.6.n5.nabble.com/Why-does-Linux-forget-the-USB-toggle-bit-of-my-device-td6829.html
>From Alan Stern, one of the leading Linux USB kernel developer.
"Kernel versions prior to 2.6.28 will always send a Set-Interface
request when your program releases its interface (or when it closes the
device file).  If the device doesn't support this request then the
kernel sends Clear-Halt for each endpoint in the interface.  These
requests are supposed to set the data toggle back to 0, but many
devices don't support them properly."

The symptom for these older kernels is usually the program
runs fine the first time and then failed in the second time
because data toggle becomes wrong after the first operation.
Then usb_reset() is added as a workaround to reset()

usb_reset() itself is a hack in this case. I think it is probably easier
to make the above codes optional, probably by adding an extra
command line option to enable the codes for older kernel versions
and problematic device which really needs it. This should make
avrdude faster and reliable for most of the users for back to
back operation.

To Bill: you can always try to rebuild avrdude without the
above usb_reset() code and see if it works for you or not.

-- 
Xiaofan



reply via email to

[Prev in Thread] Current Thread [Next in Thread]