I have a USB 2.0 peripheral device based on an STM32 development board with hand-crafted code in C. This device works when connected to a Windows 7 computer but fails when connected to a Windows 10 computer: on Windows 10 Device Manager sees the device but reports
"This device cannot start. (Code 10) An invalid parameter was passed to a service or function".
The device reports itself as a WCID device i.e. the host computer loads WinUSB.sys as the driver. This part works on both 7 and 10 i.e. Device Manager shows winusb.sys as the driver on both OS variants.
The transactions on the USB bus look like (number in parentheses is size of data packet in bytes):
* Windows 7 Windows 10
* ==================== ======================
* Device Descriptor(18) Device Descriptor(18)
* Set Address=1 Set Address=2
* Device Descriptor(18) Device Descriptor(18)
* Configuration Descriptor(32) Configuration Descriptor(32)
* string serial number = "100" "100"
* Feature Descriptor(16) Feature Descriptor(16)
* Feature Descriptor(40) Feature Descriptor(40) <== "WINUSB"
* Language IDs Language IDs
* string product = "ADA" "ADA"
* Get configuration Configuration Descriptor(9)
* Device Descriptor(18) Configuration Descriptor(32)
* Configuration Descriptor(9) Device Descriptor(18)
* Configuration Descriptor(32) Set address = 2
* Status Device Descriptor(18)
* Set Configuration = 1 Configuration Descriptor(32)
* SUCCESS string serial number = "100"
* Feature Descriptor(16)
* Feature Descriptor(40)
* Language IDs
* string product = "ADA"
* Device Descriptor(18)
* Configuration Descriptor(9)
* Configuration Descriptor(32)
* Status
* Set Configuration = 1
* FAILURE
Device descriptor (18 bytes):
18 length
1 type
0x0200 USB spec
0 class
0 sub-class
0 protocol
64 max packet size
0x0483 vendor ID (STM)
0xDEAD product ID
0x0001 device release number
1 index of manufacturer string
2 index of product string
3 index of serial number string
1 number of configurations
Configuration descriptor (32 bytes):
9 length of configuration section
2 config descriptor
0x0020 total length
1 number of interfaces
1 configuration number
4 index of configuration string
0x40 attributes = self-powered
0 zero mA
9 length of interface section
4 interface descriptor
0 interface number (zero based)
0 no alternate
2 number of endpoints
0xff class (vendor specific)
0x01 sub-class (vendor-specific)
0 protocol
5 interface string index
7 length of endpoint section
5 endpoint descriptor
0x01 endpoint address = 1 (bit 7 = 0 means OUT)
2 attributes (bulk transfer)
0x0040 max packet size = 64
0 interval (no polling)
7 length of endpoint section
5 endpoint descriptor
0x82 endpoint address = 2 (bit 7 = 1 means IN)
2 attributes (bulk transfer)
0x0040 max packet size = 64
0 interval (no polling)
Feature descriptor (40 bytes):
static BYTE winusb_data[] = { 0x28, 0x00, 0x00, 0x00, 0x00, 0x01, 0x04, 0x00, 0x01, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 'W', 'I',
'N', 'U', 'S', 'B', 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 };
It seems like the configuration descriptor is being accepted by WIndows 7 but is rejected ("An invalid parameter was passed to a service or function") on Windows 10. Why?
Problem is similar but not identical to this post, where the issue was an incorrect length.
Also similar to another question on Stack Exchange:
USB – SelectConfiguration request fails with Invalid Parameter error
where the issue was max packet size > 64.
Additional references:
https://github.com/pbatard/libwdi/wiki/WCID-Devices
https://docs.microsoft.com/en-us/windows-hardware/drivers/usbcon/winusb
Best Answer
So ten minutes after posting this question I did the following in Device Manager:
uninstalled the non-working device while it was still attached
then menu item: Action...Scan for hardware changes
and the device immediately began working, even though as far as I can see absolutely nothing has changed. Specifically, the device is using exactly the same version of the same driver as when the error was being reported!