On Thu, Sep 11, 2014 at 3:14 PM, Paul Fertser <[email protected]> wrote:
> On Thu, Sep 11, 2014 at 12:56:26PM +0800, Xiaofan Chen wrote:
>> Under Windows, if using libusb-1.0 API, then the preferred driver
>> is WinUSB and it does not support setting non-default configuration
>> anyway. The other supported driver libusbK.sys is the same. Only
>> libusb0.sys supports setting non-default configuration but it is not
>> stable to be used with libusb (1.0 API).
>
> Do I understand it right that if we remove it altogether we'll break
> jlink support on windows when libusb-win32 driver is used (which some
> people prefer because it can be used as a filter driver)? JLinks are
> not composite devices anyway, so currently they can work just fine
> with libusb-1.0 + libusb-win32 backend, right?

No it is still not expected to work well, the filter driver support is broken
under libusb-1.0.

I will propose an easy change first. Just conditional compile line
1740 jtag_libusb_set_configuration(devh, 0);

The comment in line 1738 is quite clear that it is only for Win32
and only for libusb-0.1 API.

1738 /* usb_set_configuration required under win32 */
1739 struct jtag_libusb_device *udev = jtag_libusb_get_device(devh);
+++ #if IS_WIN32 == 1
1740 jtag_libusb_set_configuration(devh, 0);
+++ #endif
1741 jtag_libusb_claim_interface(devh, 0);

>
> Would a better solution be to call libusb_get_configuration() and only
> if it returns 0 in config proceed to set_configuration(), will it work
> universally?

It is more complicated since there is no usb_get_configuration
for libusb-0.1/libusb-win32. So you have to do that using
a control transfer which may crash some quirky USB device.
http://libusb.sourceforge.net/doc/ref.deviceops.html

https://github.com/libusb/libusb/blob/master/ChangeLog
2013-09-06: v1.0.17
* OpenBSD: Update OpenBSD backend with support for control transfers to
non-ugen(4) devices and make get_configuration() no longer generate I/O.
Note that using this libusb version on OpenBSD requires using
OpenBSD 5.3-current or later. Users of older OpenBSD versions are advised
to stay with the libusb shipped with OpenBSD (mpi)

So older version of OpenBSD may have similar issue as well
even with libusb-1.0 API. And NetBSD does not have
the improvement like OpenBSD 5.4 (5.3-current) so it
will likely have problems as well.

I think the latest version of libusb_get_configuration will not
generate I/O under Linux, Windows and Mac OS X. I believe
that is the case for FreeBSD as well but FreeBSD's libusb-1.0
implementation is not under the libusb project and I do not
quite know the details there.


-- 
Xiaofan

------------------------------------------------------------------------------
Want excitement?
Manually upgrade your production database.
When you want reliability, choose Perforce
Perforce version control. Predictably reliable.
http://pubads.g.doubleclick.net/gampad/clk?id=157508191&iu=/4140/ostg.clktrk
_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to