why no request of microsoft OS descriptors for a USB 2.0 FS device - Page 1
Forum section: electronics / general

author: metebalci
author_rank: Frequent Contributor
timestamp: November 24, 2023, 06:45:12 am
content: I am thinking of using the WinUSB driver (and/or libusb). Onhttps://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 ?

author: ataradov
author_rank: Super Contributor
timestamp: November 24, 2023, 07:09:24 am
content: 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_samd11And the same, but for the new BOS methodhttps://github.com/ataradov/free-dap/tree/master/platform/samd11And 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.

author: metebalci
author_rank: Frequent Contributor
timestamp: November 24, 2023, 07:21:27 am
content: Quote from: ataradov on November 24, 2023, 07:09:24 amThanks 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.

author: ataradov
author_rank: Super Contributor
timestamp: November 24, 2023, 07:22:20 am
content: 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.

author: ataradov
author_rank: Super Contributor
timestamp: November 24, 2023, 07:24:10 am
content: Quote from: metebalci on November 24, 2023, 07:21:27 amYou 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.

author: metebalci
author_rank: Frequent Contributor
timestamp: November 24, 2023, 09:54:38 am
content: Quote from: ataradov on November 24, 2023, 07:22:20 amThanks 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.

author: metebalci
author_rank: Frequent Contributor
timestamp: November 24, 2023, 10:05:41 am
content: Quote from: ataradov on November 24, 2023, 07:24:10 amYou 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.

author: abyrvalg
author_rank: Frequent Contributor
timestamp: November 24, 2023, 10:47:23 am
content: On Linux you don’t need a driver to be associated with device to use libusb.

author: metebalci
author_rank: Frequent Contributor
timestamp: November 24, 2023, 11:15:35 am
content: Quote from: abyrvalg on November 24, 2023, 10:47:23 amOK I see, thanks.

author: ataradov
author_rank: Super Contributor
timestamp: November 24, 2023, 04:41:57 pm
content: Quote from: metebalci on November 24, 2023, 10:05:41 amYou 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.