WdfUsbTargetDeviceSelectConfig -> STATUS_INVALID_PARAMETER on Vista

Content-Type: text/plain; charset=ISO-8859-15; format=flowed
Content-Transfer-Encoding: 7bit

Hello,

I am writing a KMDF driver for a USB device for Windows Vista, but I’m
having problems selecting the only endpoint descriptor available
(WdfUsbTargetDeviceSelectConfig always returns
STATUS_INVALID_PARAMETER). The same driver works fine on Windows XP.

This is the code I’m using (taken from a WDK sample):


status = WdfUsbTargetDeviceCreate(Device, WDF_NO_OBJECT_ATTRIBUTES,
&pDeviceContext->UsbDevice);

WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_SINGLE_INTERFACE(&configParams);

status = WdfUsbTargetDeviceSelectConfig(pDeviceContext->UsbDevice,
WDF_NO_OBJECT_ATTRIBUTES, &configParams);


Since I read somewhere that Vista is much more strict regarding devices
following USB standards, I decided to “dump” all the descriptors and see
if everything was correct.

Here is the result:

*********** DEVICE_DESCRIPTOR ***********
bLength: 18 OK
bDescriptorType: 1 OK
bcdUSB: 100 OK
bDeviceClass: 0 OK
bDeviceSubClass: 0 OK
bDeviceProtocol: 0 OK
bMaxPacketSize0: 8 OK
idVendor: 4512 OK
idProduct: 1000 OK
bcdDevice: 100 OK
iManufacturer: 1 OK (?)
iSerialNumber: 0 OK
bNumConfigurations: 1 OK

*********** CONFIGURATION_DESCRIPTOR ***********
bLength: 9 OK
bDescriptorType: 2 OK
wTotalLength: 19 OK
bNumInterfaces: 1 OK
bConfigurationValue: 1 OK
iConfiguration: 4 OK (?)
bmAttributes: A0 OK
MaxPower: 10 OK

*********** INTERFACE_DESCRIPTOR ***********
bLength: 9 OK
bDescriptorType: 4 OK
bInterfaceNumber: 0 OK
bAlternateSetting: 0 OK
bNumEndpoints: 1 OK
bInterfaceClass: 0 INVALID
bInterfaceSubClass: 0 INVALID
bInterfaceProtocol: 0 INVALID
iInterface: 5 OK (?)

*********** ENDPOINT_DESCRIPTOR ***********
bLength: 7 OK
bDescriptorType: 5 OK
bEndpointAddress: 81 OK
bmAttributes: 3 OK
wMaxPacketSize: 15 OK (?)
bInterval: 2 OK (?)

  • The values marked as “OK” follow the USB specification
  • The values marked as “OK (?)” should follow the USB specification, but
    I don’t know if Vista is happy with them
  • The values marked as “INVALID” do NOT follow the USB specification

Do you have any idea why selecting the descriptor doesn’t work on Vista,
while it works flawless on XP? Are those values really ok, or is there
something wrong? Is my code fine, or is the device the problem?

Thanks,

  • AS

Is this a low-speed device? If wMaxPacketSize > 8 you will get INVALID_PARAMETER on a low-speed device.

Universal Serial Bus Specification Revision 2.0
5.7.3 Interrupt Transfer Packet Size Constraints
Low-speed devices are limited to eight bytes or less maximum data payload size.

*********** ENDPOINT_DESCRIPTOR ***********
bLength: 7 OK
bDescriptorType: 5 OK
bEndpointAddress: 81 OK
bmAttributes: 3 OK
wMaxPacketSize: 15 OK (?)
bInterval: 2 OK (?)

xxxxx@microsoft.com ha scritto:

Is this a low-speed device? If wMaxPacketSize > 8 you will get INVALID_PARAMETER on a low-speed device.

Universal Serial Bus Specification Revision 2.0
5.7.3 Interrupt Transfer Packet Size Constraints
Low-speed devices are limited to eight bytes or less maximum data payload size.

*********** ENDPOINT_DESCRIPTOR ***********
bLength: 7 OK
bDescriptorType: 5 OK
bEndpointAddress: 81 OK
bmAttributes: 3 OK
wMaxPacketSize: 15 OK (?)
bInterval: 2 OK (?)

Hello,

yes it is a low speed device, and forcing maximum packet size to respect
the standard (wMaxPacketSize = 8) made it work.

Thanks you very much!

  • AS

xxxxx@microsoft.com ha scritto:

Is this a low-speed device? If wMaxPacketSize > 8 you will get INVALID_PARAMETER on a low-speed device.

Now that I think of it, is there a way to set wMaxPacketSize to a fixed
value before calling WdfUsbTargetDeviceSelectConfig (thus avoiding
getting INVALID_PARAMETER)?

I have managed to do it with WDM, but actually have no clue about how to
do it with KMDF.

Thanks,

  • AS

How did you fix it in wdm? That will give me a hint as to if it is possible to do something similar in kmdf

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of Alessandro Sardo
Sent: Friday, January 25, 2008 4:34 PM
To: Windows System Software Devs Interest List
Subject: Re: [ntdev] WdfUsbTargetDeviceSelectConfig -> STATUS_INVALID_PARAMETER on Vista

xxxxx@microsoft.com ha scritto:

Is this a low-speed device? If wMaxPacketSize > 8 you will get INVALID_PARAMETER on a low-speed device.

Now that I think of it, is there a way to set wMaxPacketSize to a fixed
value before calling WdfUsbTargetDeviceSelectConfig (thus avoiding
getting INVALID_PARAMETER)?

I have managed to do it with WDM, but actually have no clue about how to
do it with KMDF.

Thanks,

  • AS

NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Doron Holan ha scritto:

How did you fix it in wdm? That will give me a hint as to if it is possible to do something similar in kmdf

d

Hello,

this is the code I used (note that I cleaned it up of error handling):

//------------------------------------------------

NTSTATUS StartDevice(…)
{
PDEVICE_EXTENSION pdx = (PDEVICE_EXTENSION)fdo->DeviceExtension;
URB urb;

UsbBuildGetDescriptorRequest(&urb,
sizeof(_URB_CONTROL_DESCRIPTOR_REQUEST),
USB_DEVICE_DESCRIPTOR_TYPE, 0, 0, &pdx->dd,
NULL, sizeof(pdx->dd), NULL);
NTSTATUS status = SendAwaitUrb(fdo, &urb);

USB_CONFIGURATION_DESCRIPTOR tcd;
UsbBuildGetDescriptorRequest(&urb,
sizeof(_URB_CONTROL_DESCRIPTOR_REQUEST),
USB_CONFIGURATION_DESCRIPTOR_TYPE, 0, 0, &tcd, NULL,
sizeof(tcd), NULL);
status = SendAwaitUrb(fdo, &urb);

ULONG size = tcd.wTotalLength;
PUSB_CONFIGURATION_DESCRIPTOR pcd =
(PUSB_CONFIGURATION_DESCRIPTOR)
ExAllocatePoolWithTag(NonPagedPool, size,
XXX_POOL_TAG);

UsbBuildGetDescriptorRequest(&urb,
sizeof(_URB_CONTROL_DESCRIPTOR_REQUEST),
USB_CONFIGURATION_DESCRIPTOR_TYPE, 0, 0, pcd,
NULL, size, NULL);
status = SendAwaitUrb(fdo, &urb);

UsbBuildGetDescriptorRequest(&urb,
sizeof(_URB_CONTROL_DESCRIPTOR_REQUEST),
USB_CONFIGURATION_DESCRIPTOR_TYPE, 0, 0, pcd,
NULL, size, NULL);
status = SendAwaitUrb(fdo, &urb);

PUSB_INTERFACE_DESCRIPTOR pid =
USBD_ParseConfigurationDescriptorEx(pcd, pcd, -1, -1,
-1, -1, -1);

USBD_INTERFACE_LIST_ENTRY interfaces[2] = { {pid, NULL},
{NULL, NULL}, };
PURB selurb = USBD_CreateConfigurationRequestEx(pcd,interfaces);

PUSB_ENDPOINT_DESCRIPTOR ped = (PUSB_ENDPOINT_DESCRIPTOR) pid;
ped = (PUSB_ENDPOINT_DESCRIPTOR) USBD_ParseDescriptors(pcd,
tcd.wTotalLength, ped, USB_ENDPOINT_DESCRIPTOR_TYPE);

PUSBD_INTERFACE_INFORMATION pii = interfaces[0].Interface;
ASSERT(pii->NumberOfPipes == pid->bNumEndpoints);

—> ped->wMaxPacketSize = 8;

status = SendAwaitUrb(fdo, selurb);


}

//------------------------------------------------

The instruction that did the trick is setting the
USB_ENDPOINT_DESCRIPTOR wMaxPacketSize to a fixed value (from 15 -> to
8). Without it, the following SendAwaitUrb returned an error.

How can I do something similar in KMDF?

Thanks,

  • AS

Alessandro Sardo wrote:

The instruction that did the trick is setting the USB_ENDPOINT_DESCRIPTOR
wMaxPacketSize to a fixed value (from 15 -> to 8). Without it, the
following SendAwaitUrb returned an error. How can I do something
similar in KMDF?

You’ll probably need to create a lower filter to your KMDF function driver that tweaks the URB on the way down.

No need for that. Create the config urb exactly as you had in your wdm driver and instead of calling
WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_SINGLE_INTERFACE call WDF_USB_DEVICE_SELECT_CONFIG_PARAMS_INIT_URB with the URB you created.

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Saturday, January 26, 2008 8:50 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] WdfUsbTargetDeviceSelectConfig -> STATUS_INVALID_PARAMETER on Vista

Alessandro Sardo wrote:

The instruction that did the trick is setting the USB_ENDPOINT_DESCRIPTOR
wMaxPacketSize to a fixed value (from 15 -> to 8). Without it, the
following SendAwaitUrb returned an error. How can I do something
similar in KMDF?

You’ll probably need to create a lower filter to your KMDF function driver that tweaks the URB on the way down.


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer