From: Ludovic R. <lud...@gm...> - 2009-03-31 08:42:59
|
2009/3/30 Alan Stern <st...@ro...>: > On Mon, 30 Mar 2009, Mike Nuss wrote: > >> Ludovic Rousseau wrote: >> > > >> > > The driver works fine the first time I launch it. The problem is >> when >> > > I restart it. Using a USB hardware spy I discovered that each time I >> > > start my driver the first USB frame sent is always using DATA0 (USB >> > > toggle bit). The problem is my USB device may be expecting a DATA1 >> > > frame and will not answer this DATA0 frame. > > 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. > >> Try set_configuration. The USB 2.0 spec requires the device to reset the >> data toggle for any non-zero set_configuration request (section >> 9.1.1.5). > > Set-Config is also rather heavy-handed. Furthermore, the USB spec also > requires devices to reset the data toggle in response to Set-Interface > or Clear-Halt (section 9.4.5) -- devices don't always follow the spec. My USB device does not support the CLEAR_FEATURE and respond with an error. It looks like this behavior is supported by USB 2.0 specification: 9.4.1 Clear Feature "A ClearFeature() request that references a feature that cannot be cleared, that does not exist, or that references an interface or endpoint that does not exist, will cause the device to respond with a Request Error." Maybe the Linux kernel could NOT reset its toggle bit if the ClearFeature(ENDPOINT_HALT) fails? > The best answer may be to upgrade to 2.6.28 or 2.6.29. That would be a long term solution. I am using Linux 2.6.26 from Debian stable and need to support a lot of other Linux distributions. Note that I have the same problem on Mac OS X. So I have to "correct" my code or the device firmware. Thanks a lot for the very informative answers. -- Dr. Ludovic Rousseau |