Author Topic: why no request of microsoft OS descriptors for a USB 2.0 FS device  (Read 1055 times)

0 Members and 1 Guest are viewing this topic.

Offline metebalciTopic starter

  • Frequent Contributor
  • **
  • Posts: 451
  • Country: ch

I am thinking of using the WinUSB driver (and/or libusb). On https://learn.microsoft.com/en-us/windows-hardware/drivers/usbcon/microsoft-defined-usb-descriptors, it says Windows will request a string descriptor at 0xEE and expects certain information to load the WinUSB driver for the device. However, I do not see any such request when I plug it to Windows. Is there any pre-requisite ? Also, libusb refers to the same documents, and it sounds like they use the same idea, but I also do not see any such request on Linux. What am I missing ?
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11261
  • Country: us
    • Personal site
Re: why no request of microsoft OS descriptors for a USB 2.0 FS device
« Reply #1 on: November 24, 2023, 07:09:24 am »
You need to have USB version to be set at least to 2 in the device descriptor.  Also, 0xEE string is the old method. The new one is to use BOS descriptor (required bcdUSB value is 0x0210).

And Linux will not request 0xEE, it is purely Microsoft thing. Linux will request BOS, but it will ignore WinUSB part, since it is not really needed under Linux.

Example set of descriptors and handling of them that is known to work - https://github.com/ataradov/bootloaders/tree/master/firmware/usb_dfu_samd11 And the same, but for the new BOS method https://github.com/ataradov/free-dap/tree/master/platform/samd11

And libusb is not really involved in requesting any of the descriptors, it just works with the resulting WinUSB device. It can't do anything unless OS enumerates it.
« Last Edit: November 24, 2023, 07:15:33 am by ataradov »
Alex
 

Offline metebalciTopic starter

  • Frequent Contributor
  • **
  • Posts: 451
  • Country: ch
Re: why no request of microsoft OS descriptors for a USB 2.0 FS device
« Reply #2 on: November 24, 2023, 07:21:27 am »
You need to have USB version to be set at least to 2 in the device descriptor.  Also, 0xEE string is the old method. The new one is to use BOS descriptor (required bcdUSB value is 0x0210).

And Linux will not request 0xEE, it is purely Microsoft thing. Linux will request BOS, but it will ignore WinUSB part, since it is not really needed under Linux.

Example set of descriptors and handling of them that is known to work - https://github.com/ataradov/bootloaders/tree/master/firmware/usb_dfu_samd11 And the same, but for the new BOS method https://github.com/ataradov/free-dap/tree/master/platform/samd11

And libusb is not really involved in requesting any of the descriptors, it just works with the resulting WinUSB device. It can't do anything unless OS enumerates it.

Thanks a lot for the clarification. I saw the use of BOS descriptor in the documents but I thought it is only if bcdUSB>0200, and if bcdUSB=0200 the string descriptor still works. So, if WinUSB or libusb is going to be used, bcdUSB has to be 0210 and BOS descriptor should be returned, I will try.
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11261
  • Country: us
    • Personal site
Re: why no request of microsoft OS descriptors for a USB 2.0 FS device
« Reply #3 on: November 24, 2023, 07:22:20 am »
Also, one huge pain with the 0xEE version - Windows will only request this once for a new device. If device does not respond the first time, there will be no followup requests.

To clear the flag, delete the following path in the registry "HKLM\SYSTEM\CurrentControlSet\Control\UsbFlags\vvvvpppprrrrr". The last part is the VID/PID if your device.

Or keep changing VID/PID every time you rebuild while debugging. Then delete all the junk devices all at once.
« Last Edit: November 24, 2023, 07:25:13 am by ataradov »
Alex
 
The following users thanked this post: metebalci

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11261
  • Country: us
    • Personal site
Re: why no request of microsoft OS descriptors for a USB 2.0 FS device
« Reply #4 on: November 24, 2023, 07:24:10 am »
So, if WinUSB or libusb is going to be used, bcdUSB has to be 0210 and BOS descriptor should be returned, I will try.
You can use WinUSB and libusb with the 0xEE string, it is just an ugly hack. But in practice, it works and actually needs less code and fewer descriptors.  BOS stuff sucks.
Alex
 

Offline metebalciTopic starter

  • Frequent Contributor
  • **
  • Posts: 451
  • Country: ch
Re: why no request of microsoft OS descriptors for a USB 2.0 FS device
« Reply #5 on: November 24, 2023, 09:54:38 am »
Also, one huge pain with the 0xEE version - Windows will only request this once for a new device. If device does not respond the first time, there will be no followup requests.

To clear the flag, delete the following path in the registry "HKLM\SYSTEM\CurrentControlSet\Control\UsbFlags\vvvvpppprrrrr". The last part is the VID/PID if your device.

Or keep changing VID/PID every time you rebuild while debugging. Then delete all the junk devices all at once.

Thanks again for pointing this out. I actually read about this and tried removing a key but it was under another tree not this one you said and I guess that one is a read-only one I could not delete it. After removing the key you mentioned, I saw the string descriptor request for 0xEE.  :-+
 

Offline metebalciTopic starter

  • Frequent Contributor
  • **
  • Posts: 451
  • Country: ch
Re: why no request of microsoft OS descriptors for a USB 2.0 FS device
« Reply #6 on: November 24, 2023, 10:05:41 am »
So, if WinUSB or libusb is going to be used, bcdUSB has to be 0210 and BOS descriptor should be returned, I will try.
You can use WinUSB and libusb with the 0xEE string, it is just an ugly hack. But in practice, it works and actually needs less code and fewer descriptors.  BOS stuff sucks.

You mean I can use (WinUSB and) libusb under Windows with 0xEE method, right ? Because Linux does not request and check 0xEE string, using libusb under Linux require the BOS thing.
 

Offline abyrvalg

  • Frequent Contributor
  • **
  • Posts: 824
  • Country: es
Re: why no request of microsoft OS descriptors for a USB 2.0 FS device
« Reply #7 on: November 24, 2023, 10:47:23 am »
On Linux you don’t need a driver to be associated with device to use libusb.
 
The following users thanked this post: metebalci

Offline metebalciTopic starter

  • Frequent Contributor
  • **
  • Posts: 451
  • Country: ch
Re: why no request of microsoft OS descriptors for a USB 2.0 FS device
« Reply #8 on: November 24, 2023, 11:15:35 am »
On Linux you don’t need a driver to be associated with device to use libusb.

OK I see, thanks.
 

Online ataradov

  • Super Contributor
  • ***
  • Posts: 11261
  • Country: us
    • Personal site
Re: why no request of microsoft OS descriptors for a USB 2.0 FS device
« Reply #9 on: November 24, 2023, 04:41:57 pm »
Because Linux does not request and check 0xEE string, using libusb under Linux require the BOS thing.
You should not need any of this on any OS.  Microsoft are apparently incapable of coming up with obvious trivial solutions (or copying good solutions from others).

On Linux, a device that is not claimed by any drivers is available for generic access from libusb. There is no need for drivers, the OS just lets you send and receive arbitrarily formatted packets to the device.
This makes it possible to  create user-land device drivers for devices that have unique functionality and work only with one application anyway.

On Windows, if device is not claimed by any drivers, you get errors and device is not available. So, instead of just installing WinUSB driver automatically, they came up with this nonsense.

BOS is not just for installing drivers, it is a generic storage of arbitrary binary data. Linux asks for it to extract other useful information. All that WinUSB stuff will be ignored by Linux.
Alex
 


Share me

Digg  Facebook  SlashDot  Delicious  Technorati  Twitter  Google  Yahoo
Smf