WinUSB support in device firmware

I am trying to configure a USB device to automatically use WinUSB as a driver when it is connected to a Windows 8 machine, as described here .

It says:

In order for the USB driver stack to know that the device supports extended function descriptors, the device must define an OS line descriptor, which is stored in the 0xEE line index.

What I mean is that I need to create a structure containing a descriptor in memory cell 0xEE. How do I do this in C?

Here is what I tried:

// The struct definition typedef struct { uint8_t bLength; uint8_t bDescriptorType; uint8_t qwSignature[14]; uint8_t bMS_VendorCode; uint8_t bPad; } usb_os_str_desc_t; // Create a pointer to a struct located at 0xEE volatile usb_os_str_desc_t* const extended_feature_support = (usb_os_str_desc_t*) 0xEE; // Create a new struct at the location specified in "extended_feature_support" (*extended_feature_support) = { .bLength = 0x12, .bDescriptorType = 0x03, .qwSignature = "MSFT100", .bMS_VendorCode = 0x04, .bPad = 0x00 }; 

But the compiler does not like this, complaining that the data definition is not of type. Is there a way to do this in C? Do I understand the article correctly?

Any help would be considered.

+4
source share
1 answer

This is not at all what he is saying. You should respond to USB requests, not place structures in specific places on the internal system memory.

Windows, seeing VID: PID: Serial for the first time, will request the OS string descriptor at index 0xee. The device should respond with a data packet that matches the structure format you specified. If everything in the returned descriptor is correct (your example looks good), Windows will then issue a device provider request with bReq set to what you specified in the string descriptor response as MS_VendorCode (0x04 in your example).

If your device responds with the correct OS function descriptor, then magic happens. The magic that people usually want is that their device uses the winusb driver without providing the .inf file.

Please note that this request is executed only once. If you are designing a device, you usually want to do this many times. To do this, you need to remove the device from the device manager, and then in regedit, find your VIDPIDRELEASE under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\usbflags and delete it. Now, when you reconnect your device, it will execute this operating system descriptor request again.

For more information, refer to https://github.com/pbatard/libwdi/wiki/WCID-Devices , this is much clearer than the documents provided by MS.

+3
source

Source: https://habr.com/ru/post/1491545/


All Articles