On 2012.09.03 21:16, Chris McClelland wrote:
> Firstly thanks for the lively fork! It's great that libusb is being so
> actively developed.

Thanks. It's always nice to hear from more users making the switch.

> I'm in the process of debugging some host-side code and Cypress FX2LP
> firmware.

If you're dealing with the FX2LP, then I'll start with an aside: Do you 
know that we plan to introduce our own version of fxload, as a libusbx 
sample? This work is currently happening in one of my personal branches 
[1], but, bugfixes permitting, I'm hoping it will be included with full 
FX2/FX2LP support for libusbx v1.0.13, that is to be released soon. FX3 
support should follow shortly after.

> Things work fine on Linux and on MacOSX, but things go awry on
> Windows (using WinUSB driver). I coult show you traces of things
> actually going wrong on Windows, but I notice even when things go well,
> the Linux message-flow differs from the Windows message-flow; I'd like
> to understand there reason for these differences.

If you're dealing with set configuration, and trying to set a 
configuration that is different than the default one, then things are 
expected not to work on Windows when using WinUSB [2]. Currently we're 
not sending SET_CONFIGURATION on the bus unless it's for the default 
one, and if you run your app with libusbx logging set to at least 
warning (which you are strongly encouraged to do during development - 
see libusb_set_debug [3]), you should have seen a warning about it [4].

> On Linux, running my libusb-1.0 test program three times gives this:
>
> http://pastebin.com/raw.php?i=0jGbaAxM
>
> Notice that the message sequence is:
>
> 1) Write 0x00 bytes to EP0: SET_CONFIGURATION(0x0001, 0x0000)
> 2) Read 0x10 bytes from EP0: 0x80(0x0000, 0x0000)
> 3) Write 0x05 bytes to EP2: 0x00, 0x00, 0x00, 0x00, 0x01
> 4) Write 0x01 byte to EP2: 0x10
>
> And notice that this sequence is repeated three times (for three
> separate invocations of the test program).
>
> Now the same code built against libusbx-1.0.12 on Windows, running on
> the same host inside a VirtualBox VM:
>
> http://pastebin.com/raw.php?i=9dPb0uiC
>
> Notice that the message sequence is now:
>
> 1a) Read 0x09 bytes from EP0: GET_DESCRIPTOR(0x0200, 0x0000)
> 1b) Read 0x2E bytes from EP0: GET_DESCRIPTOR(0x0200, 0x0000)
> 2) Read 0x10 bytes from EP0: 0x80(0x0000, 0x0000)
> 3) Write 0x05 bytes to EP2: 0x00, 0x00, 0x00, 0x00, 0x01
> 4) Write 0x01 byte to EP2: 0x10
>
> Notice that, again, the message sequence is repeated three times (for
> three separate invocations of the test program). Also notice that 2, 3 &
> 4 are exactly the same as they were on Linux, but the call to
> SET_CONFIGURATION on Linux has been replaced with a pair of calls to
> GET_DESCRIPTOR on Windows.

Most likely that's because we can't set the configuration you request 
using WinUSB, so we don't bother sending that message to the device. 
This is a WinUSB limitation.

On the other hand, to conform with the Linux centric libusb enumeration 
model, we have to issue a few get_descriptor requests to external hubs 
get some of the data we need, and as the OS does not cache it, those 
queries will appear on the bus.

We've had a lengthy debate about what we could do to avoid sending these 
descriptor requests every time we re-enumerate on Windows, but for the 
time being, you should expect to see those.

> If I run the same code natively on a dedicated Windows machine (and use
> USBTrace to sniff), neither the SET_CONFIGURATION nor the GET_DESCRIPTOR
> are sent; it just goes straight into 2, 3 & 4.

That's strange. I'd expect to see some querying of descriptors for any 
external hub on Windows. As to SET_CONFIGURATION, unless you're trying 
for the default conf, it will not be sent on the bus.

Finally, note that 1.0.13 will also introduce support for the libusb0 
and libusbK Windows drivers, that are less limited as WinUSB, so we will 
hopefully be able to switch configurations in the future when using 
those. Most likely, this will happen in 1.0.14 rather than 1.0.13 though.

Regards,

/Pete

[1] https://github.com/pbatard/libusbx/commits/0K
[2] 
https://github.com/libusbx/libusbx/wiki/Windows-Backend#wiki-Known_Restrictions
[3] 
http://libusbx.sourceforge.net/api-1.0/group__lib.html#ga5f8376b7a863a5a8d5b8824feb8a427a
[4] 
https://github.com/libusbx/libusbx/blob/master/libusb/os/windows_usb.c#L2890


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
libusbx-devel mailing list
libusbx-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libusbx-devel

Reply via email to