USB Device with multiple, mutually exclusive interface

Hello All,

We are developing a USB device that has ISO endpoints. The is such that it
has two mutually exclusive interfaces: a low-bandwidth interface with two
endpoints and a second interface with 6 endpoints (2-ISO, 2-Bulk, 2-Int). We
are having trouble getting the device to enumerate (the call to
WdfUsbTargetDeviceSelectConfig() returns imediately with 0xC0000001) and
suspect the problem is with the descriptors.

Below is the entire descriptor – could someone please take a look to if
this is correct.

Thanks.

*Descriptors*

Device Descriptor
Length: 0x12
Descriptor Type: 0x1
bcdUSB: 0x200
Device Class: 0x0
Device Subclass: 0x0
Protocol: 0x0
Max Packet: 0x40
idVendor: 0x4004
idProduct: 0x1
bcdDevice: 0x0
iMan: 0x1
iProduct: 0x2
iSerialNum: 0x0
Num Config: 0x1

Config Descriptor
bLength: 0x9
bDescriptorType: 0x2
wTotalLength: 0x53
bNumInterfaces: 0x2
bConfigurationValue: 0x1
iConfiguration: 0x0
MaxPower: 0x0

Interface Descriptor: 1
bLength: 0x9
bDescriptorType: 0x4
bInterfaceNumber: 0x0
bAlternateSetting: 0x0
bNumEndpoints: 0x2
bInterfaceClass: 0xff
bInterfaceSubClass: 0xff
bInterfaceProtocol: 0x0
iInterface: 0x0

EndPoint Descriptor
bLength: 0x7
bDescriptorType: 0x5
bEndpointAddress: 0x81
bmAttributes: 0x3
wMaxPacketSize: 0x200
bInterval: 0x4

EndPoint Descriptor
bLength: 0x7
bDescriptorType: 0x5
bEndpointAddress: 0x1
bmAttributes: 0x3
wMaxPacketSize: 0x200
bInterval: 0x4

Interface Descriptor: 2
bLength: 0x9
bDescriptorType: 0x4
bInterfaceNumber: 0x0
bAlternateSetting: 0x1
bNumEndpoints: 0x6
bInterfaceClass: 0xff
bInterfaceSubClass: 0xff
bInterfaceProtocol: 0x0
iInterface: 0x0

EndPoint Descriptor
bLength: 0x7
bDescriptorType: 0x5
bEndpointAddress: 0x81
bmAttributes: 0x3
wMaxPacketSize: 0x200
bInterval: 0x4

EndPoint Descriptor
bLength: 0x7
bDescriptorType: 0x5
bEndpointAddress: 0x1
bmAttributes: 0x3
wMaxPacketSize: 0x200
bInterval: 0x4

EndPoint Descriptor
bLength: 0x7
bDescriptorType: 0x5
bEndpointAddress: 0x82
bmAttributes: 0x2
wMaxPacketSize: 0x200
bInterval: 0x4

EndPoint Descriptor
bLength: 0x7
bDescriptorType: 0x5
bEndpointAddress: 0x2
bmAttributes: 0x2
wMaxPacketSize: 0x200
bInterval: 0x4

EndPoint Descriptor
bLength: 0x7
bDescriptorType: 0x5
bEndpointAddress: 0x83
bmAttributes: 0x1
wMaxPacketSize: 0x400
bInterval: 0x1

EndPoint Descriptor
bLength: 0x7
bDescriptorType: 0x5
bEndpointAddress: 0x3
bmAttributes: 0x1
wMaxPacketSize: 0x400
bInterval: 0x1

Jimmy James wrote:

Hello All,

We are developing a USB device that has ISO endpoints. The is such that it
has two mutually exclusive interfaces: a low-bandwidth interface with two
endpoints and a second interface with 6 endpoints (2-ISO, 2-Bulk, 2-Int).

Your terminology confused me for a bit. You do not have “two mutually
exclusive interfaces”. What you have is one interface with two
alternate settings. That leads to your real problem: your configuration
descriptor has bNumInterfaces == 2, when it should be 1.

We
are having trouble getting the device to enumerate (the call to
WdfUsbTargetDeviceSelectConfig() returns imediately with 0xC0000001) and
suspect the problem is with the descriptors.

Other than the bNumInterfaces issue, there is one other problem. In
Windows, alternate setting 0 (which is the default alternate setting) is
not supposed to consume any isochronous bandwidth. The issue is, what
happens if there isn’t enough bandwidth left to satisfy your alternate
setting? In that case, the select_configuration request has to fail,
which means basically that your device cannot enumerate. You should
create an alternate setting 0 with no endpoints, then move your two
current settings to AS1 and AS2.

I do not know if WdfUsbTargetDeviceSelectConfig is actually enforcing
this rule or not; the error you’re getting is almost certainly because
the interface count is wrong.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

This terminalogy, “multiple mutually exclusive interfaces…” comes from
“USB Complete” (check out the verbiage under bAlternateSetting on page
107) – so I think the terminology is in fact correct.

If the config desciptor reports an itnerface number of 1, the device still
needs to return two interface descriptors – is this correct?

I realize that the purpose of having altnernate interfaces is to prevent
bandwidth from being using by the default configuration. For our device, the
default configuration defines 2-bulk endpoints – thus I believe we are ok
here – do you agree?

“Tim Roberts” wrote in message news:xxxxx@ntdev…
> Jimmy James wrote:
>> Hello All,
>>
>> We are developing a USB device that has ISO endpoints. The is such that
>> it
>> has two mutually exclusive interfaces: a low-bandwidth interface with two
>> endpoints and a second interface with 6 endpoints (2-ISO, 2-Bulk, 2-Int).
>
> Your terminology confused me for a bit. You do not have “two mutually
> exclusive interfaces”. What you have is one interface with two
> alternate settings. That leads to your real problem: your configuration
> descriptor has bNumInterfaces == 2, when it should be 1.
>
>> We
>> are having trouble getting the device to enumerate (the call to
>> WdfUsbTargetDeviceSelectConfig() returns imediately with 0xC0000001) and
>> suspect the problem is with the descriptors.
>>
>
> Other than the bNumInterfaces issue, there is one other problem. In
> Windows, alternate setting 0 (which is the default alternate setting) is
> not supposed to consume any isochronous bandwidth. The issue is, what
> happens if there isn’t enough bandwidth left to satisfy your alternate
> setting? In that case, the select_configuration request has to fail,
> which means basically that your device cannot enumerate. You should
> create an alternate setting 0 with no endpoints, then move your two
> current settings to AS1 and AS2.
>
> I do not know if WdfUsbTargetDeviceSelectConfig is actually enforcing
> this rule or not; the error you’re getting is almost certainly because
> the interface count is wrong.
>
> –
> Tim Roberts, xxxxx@probo.com
> Providenza & Boekelheide, Inc.
>
>

Jimmy James wrote:

This terminalogy, “multiple mutually exclusive interfaces…” comes from
“USB Complete” (check out the verbiage under bAlternateSetting on page
107) – so I think the terminology is in fact correct.

Jan is a very talented and prolific author, but she has invented her own
terms here that conflict with the USB specification, and I wish she
would not have done so. The phrase “alternate interface” is just
wrong. I’ve seen it many times, and its use causes confusions like this
one. The correct term is “alternate setting”, and that phrase gives you
the proper connotation. Your configuration has one interface. That
interface has two alternate settings.

It just so happens that alternate settings are declared by using an
interface descriptor.

If the config desciptor reports an itnerface number of 1, the device still
needs to return two interface descriptors – is this correct?

You will, yes, because you have two alternate settings for your
interface. bNumInterfaces tells the number of different
bInterfaceNumbers that will be encountered, not the number of interface
descriptors.

I realize that the purpose of having altnernate interfaces is to prevent
bandwidth from being using by the default configuration. For our device, the
default configuration defines 2-bulk endpoints – thus I believe we are ok
here – do you agree?

No, your default configuration defines 2 interrupt endpoints
(bmAttributes = 3). They consume bandwidth. For bulk, you want
bmAttributes to be 2.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Ok thanks Tim. Ya those endpoints should be bulk.
“Tim Roberts” wrote in message news:xxxxx@ntdev…
> Jimmy James wrote:
>> This terminalogy, “multiple mutually exclusive interfaces…” comes from
>> “USB Complete” (check out the verbiage under bAlternateSetting on page
>> 107) – so I think the terminology is in fact correct.
>>
>
> Jan is a very talented and prolific author, but she has invented her own
> terms here that conflict with the USB specification, and I wish she
> would not have done so. The phrase “alternate interface” is just
> wrong. I’ve seen it many times, and its use causes confusions like this
> one. The correct term is “alternate setting”, and that phrase gives you
> the proper connotation. Your configuration has one interface. That
> interface has two alternate settings.
>
> It just so happens that alternate settings are declared by using an
> interface descriptor.
>
>> If the config desciptor reports an itnerface number of 1, the device
>> still
>> needs to return two interface descriptors – is this correct?
>>
>
> You will, yes, because you have two alternate settings for your
> interface. bNumInterfaces tells the number of different
> bInterfaceNumbers that will be encountered, not the number of interface
> descriptors.
>
>> I realize that the purpose of having altnernate interfaces is to prevent
>> bandwidth from being using by the default configuration. For our device,
>> the
>> default configuration defines 2-bulk endpoints – thus I believe we are
>> ok
>> here – do you agree?
>>
>
> No, your default configuration defines 2 interrupt endpoints
> (bmAttributes = 3). They consume bandwidth. For bulk, you want
> bmAttributes to be 2.
>
> –
> Tim Roberts, xxxxx@probo.com
> Providenza & Boekelheide, Inc.
>
>

Jimmy James wrote:

Ok thanks Tim. Ya those endpoints should be bulk.

By the way, please let us know if this solves the problem. I’m pretty
sure I’m right, but it’s nice to get a confirmation.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Yes it does solve the problem. I am able to select the configuration as well
as select the alternate setting.
Thanks again for your help.
“Tim Roberts” wrote in message news:xxxxx@ntdev…
> Jimmy James wrote:
>> Ok thanks Tim. Ya those endpoints should be bulk.
>>
>
> By the way, please let us know if this solves the problem. I’m pretty
> sure I’m right, but it’s nice to get a confirmation.
>
> –
> Tim Roberts, xxxxx@probo.com
> Providenza & Boekelheide, Inc.
>
>