Selecting 2nd configuraion in USB Driver

xxxxx@gmail.com schrieb:

Hagen Patzke wrote:

>(2) The USB standard DOES support one device having multiple
>“personalities” (configurations). And different interfaces associated
>with these configurations. For some applications it is obviously very
>appealing to use this flexibility.
>
>Thank you all for making it crystal-clear to me that we all
>can NOT use such a functionality with the current Microsoft
>Windows driver system (all versions so far).

What? No one ever said that. In fact, Doron and others explained
>(in a “crystal-clear” fashion) that you absolutely can use the second
> configuration on a device, you just can’t use the KMDF USB DDI’s,
> or the Microsoft-supplied generic parent driver (<= XP),
> to access it.

Case in point - no one said that you cannot use multiple device
configurations in Windows.

As far as I understand, someone can use a device with multiple
configurations with Windows – but then they are pretty much on their own.

There is no clean way to use built-in Windows drivers for ‘standard’
functionality like MSD.

And for me this was an important issue/limitation to learn of (and it
was not clear to me before the discussion - hence the comment).

No amount of ™ signs or “rathole” namecalling changes this fact.

Please note that I quoted some OP mail and style here.

It’s also been explained in other threads that this decision was
> made because devices with more than one USB configuration are
> actually very rare, despite your assertion about it being
> “appealing for many applications”.

Let me explain what leads me to this “assertion” that (to quote what I
actually wrote) “for some applications it is … very appealing”:

Years ago I heard of a device being developed (at the company I worked
for at the time, but in a different department) that had two modes of
operation: one MSD mode (for bringing its own driver with it), and one
device mode (for the actual functionality).

This I found very appealing - and extrapolating a bit I found it even
more appealing to one day possibly have devices that bring their own
drivers with them.

Flash memory prices have been falling for some time, and so it does make
sense (at least to me) to use some ‘surplus’ memory to incorporate
drivers or configuration data or even an application - something like
real plug-and-play functionality, with even app and driver included.

Now that I had to deal with an existing USB driver for one of our
hardware interfaces (at a different company), I read the specs and found
that one USB device can have multiple configurations, selectable by a
relatively simple mechanism.

Well - to me at least - it sounds quite reasonable to have a USB device
with one MSD configuration (for the drivers and stuff) and one
“device-functional” configuration for the main task.

(Other applications could include e.g. a fingerprint reader and a secure
MSD device, or e.g. a smart card reader and secure audio device with mic
and speaker – with ultimate security, en/decrypting everything in the
device itself. Etc.)

From some OP mail I learned that obviously someone actually implemented
such a chip or device. They did not implement “two devices” (i.e.
different PIDs), but one device with two configurations, one of them a
MSC, one something different.

Of course I learned that Windows (usually) selects drivers according to
VID/PID (plus device class and what not), so I am hopefully not a
complete blank.

But I did not know that there is no standard way of switching over to
a different configuration at runtime or to use the “inbox drivers” (to
quote Doron) for such a device.

Let’s face it: if they are not supported by Windows, any chip designer
would be very ill advised to actually use multiple configurations for
the aforementioned purpose.

(BTW, anybody here who remembers the “bad old days” of MS-DOS where you
had to reboot for any new driver – until PnP arrived? :slight_smile: )

So before you go spouting off next time I recommend
> you educate yourself a little further…

Thank you for the good advice.

What triggered my response was the “automatic reaction” (at least it
looked to me like one) I noticed: “A device does something in a way
Windows does not handle well -> change your hardware.”

In the short term this is probably a very good piece of advice, but I
somehow don’t like where this alley might ultimately lead us: no new
functionality because nobody dares to implement it.
And this can not be good for any OS.

Thanks for your time. -H

Hagen Patzke schrieb:

There is no clean way to use built-in Windows drivers for ‘standard’
functionality like MSD.

Should read:

There is no clean way to re-use built-in Windows drivers for ‘standard’
functionality like MSD in this multi-configuration setup.

…tried to be brief. Too brief… :slight_smile:

On Sun, Jul 08, 2007 at 07:26:25PM +0200, Hagen Patzke wrote:

As far as I understand, someone can use a device with multiple
configurations with Windows – but then they are pretty much on their own.

There is no clean way to use built-in Windows drivers for ‘standard’
functionality like MSD.

It might be interesting to step back a moment and think about this
situation. If you were king, how would you implement this support in a
clean way? A multi-configuration device can only have one configuration
active at any given time. When you switch configurations, it is
essentially the same as an unplug/replug: the system has to tear down
all of the existing drivers and build a new set.

How would the system know which configuration to choose? Certainly the
generic parent doesn’t have the knowledge to make such a decision. The
upper layer drivers (like mass storage) won’t know that it is multi-
configuration. Assuming you come up in configuration 1, what would be
the trigger to request a change to configuration 2? I suppose you could
have a registry entry that tells the generic parent to select
configuration 2, but then what good is configuration 1?

I can certainly see having a physical switch on the device to switch
between configurations, but that can be done in firmware without using
the USB multiconfiguration stuff.

I just don’t think the problem has an immediate, obvious, and universally
satisfying answer.

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

xxxxx@probo.com wrote:

How would the system know which configuration to choose?
Certainly the generic parent doesn’t have the knowledge
to make such a decision.

Is it possible to insert a driver above the bus driver that knows how to
handle the device (including the configuration switches) and which can
start the proper higher-layer configuration? (If I understand correctly,
it is possible, but strongly regarded as a “bad hack”.)

The upper layer drivers (like mass storage) won’t know that
it is multi-configuration.

And you would not want them to know or care. If your lower-level driver
could request one or more higher-level drivers loaded on top of it, a
MSD request would come ‘down’ to it, the source be recognized, and the
USB device configuration switched as needed.

Assuming you come up in configuration 1, what would be
the trigger to request a change to configuration 2?
I suppose you could have a registry entry that tells
the generic parent to select configuration 2, but then
what good is configuration 1?

As far as I understand, the trigger to switch configurations would come
from higher driver layers - so you would need two device stacks that
merge “down” on the same driver (like bus drivers).

If someone talks to the device as MSD, the driver switches to config#1,
if someone talks to it as (e.g.) Video device, switch to config#2.

I can certainly see having a physical switch on the device to switch
between configurations, but that can be done in firmware without using
the USB multiconfiguration stuff.

The problem is IMHO not at the device side - it could switch
configurations via a physical switch or via USB configuration request.

The problem - as I see it - is how you handle this in Windows, when you
want to re-use standard drivers like MSD to handle that part of the
functionality.

I just don’t think the problem has an immediate, obvious,
and universally satisfying answer.

Certainly not immediate and obvious, otherwise the MS designers would
have incorporated it already. But my guess is that an answer exists.
Remember MSCDEX anyone? (Did also something ‘impossible’ to the OS.) :slight_smile:

Hagen Patzke wrote:

And you would not want them to know or care. If your lower-level
driver could request one or more higher-level drivers loaded on
top of it, a MSD request would come ‘down’ to it, the source be
recognized, and the USB device configuration switched as needed.

Yes, you would write a bus driver that would enumerate different hardware IDs based on which USB configuration is selected.

Of course, since hardware IDs for USB are the VID and PID, you could save yourself the time and effort by just changing the VID/PID on the device for each operating mode, and let the system USB bus driver do the work for you.

Which is what we all suggested a long time ago.

xxxxx@gmail.com wrote:

Yes, you would write a bus driver that would enumerate different hardware IDs based on which USB configuration is selected.

Of course, since hardware IDs for USB are the VID and PID, you could save yourself the time and effort by just changing the VID/PID on the device for each operating mode, and let the system USB bus driver do the work for you.

Dynamically? Within the current session? Windows can do that?

Cool!

Hi all

Thanks for your support & calrifying a the issue .

AMit Shahi

----- Original Message -----
From: “Hagen Patzke”
> To: “Windows System Software Devs Interest List”
> Subject: Re:[ntdev] Selecting 2nd configuraion in USB Driver
> Date: Tue, 10 Jul 2007 09:42:10 +0200
>
>
> xxxxx@gmail.com wrote:
> > Yes, you would write a bus driver that would enumerate different
> > hardware IDs based on which USB configuration is selected.
> >
> > Of course, since hardware IDs for USB are the VID and PID, you
> > could save yourself the time and effort by just changing the
> > VID/PID on the device for each operating mode, and let the system
> > USB bus driver do the work for you.
>
> Dynamically? Within the current session? Windows can do that?
>
> Cool!
>
> —
> Questions? First check the Kernel Driver FAQ at
> http://www.osronline.com/article.cfm?id=256
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer

>


______________________________________________
IndiaInfo Mail - the free e-mail service with a difference! www.indiainfo.com
Check out our value-added Premium features, such as an extra 20MB for mail storage, POP3, e-mail forwarding, and ads-free mailboxes!

Hi All ,

I opted for the second option : I created a filter driver & load it below the USB Hub driver.
Here I am trapping the IRP/URB pair & modified the Get_Configuration request .In? Lower filter driver I am checking the Number of the configuration of the device & if it is 2 then I modify the URB data to select the second configuration .

The good thing is that It is working properly as for rest of the enumeration the configuration handle is used (which I modifed in filter driver) & it load the device as composite device & enumerate the Interface .I tested it with my applicaiton & it is working fine .

For this I have to modify value in registry .
My Filter Driver position is : Lower Filter in USB Class
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Class{36FC9E60-C465-11CF-8056-444553540000}

Also I have to delete the entry from the ENUM key in HKLM related to the USB MASS storage relate to my driver when I am installing my filter driver.
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Enum\USB\

If I leave the mass storage mode data here my device appear as MSC device but its second configuration is selected(due to my filter driver) So Windows display the Error Device is not configured.

Problem :
But there comes another problem that when I am checking the Configuration related URB/IRP pair on USBTrace and other S/W then first it send the configuration request with index 0 & later it call the AddDevice function of my Filter Driver.Now It send the configuration request with index 1 (What I desired).

Since first time it send the configuration request with index 0 , so If there is no ENUM data in the registry related to the 2nd Configuration , device malfunction.

I think this is due to the first request with configuration index 0 .
Once my driver is loaded it modify the configuration request with 1 , so the basic problem is the loading of the driver . When it load it start working & change he index.

Is any other driver send the configuratiion request to the device before BUS driver(and my filter driver)

I suspect on USBD.sys as it come below the USB BUs driver.

So I think I should place my driver below the usbd.sys instead of the USBHUB.sys to modify the configuration index in the first configuration request .Please let me know this approach can work or not.
USBD.sys use IRP/URB pair or it only use URB pair .

Also if anyone can give a direction that How can i attach a lower filter to the USBD.sys in case it is following the same method(IRP/URB)

Thanks
Amit Rajkumar Shahi

----- Original Message -----
From: “Amit Shahi”
To: “Windows System Software Devs Interest List”
Subject: Re:[ntdev] Selecting 2nd configuraion in USB Driver
Date: Mon, 16 Jul 2007 10:29:41 +0530

Hi all

Thanks for your support & calrifying a the issue .

AMit Shahi

----- Original Message -----
From: “Hagen Patzke”
To: “Windows System Software Devs Interest List”
Subject: Re:[ntdev] Selecting 2nd configuraion in USB Driver
Date: Tue, 10 Jul 2007 09:42:10 +0200

xxxxx@gmail.com wrote:
> Yes, you would write a bus driver that would enumerate
different > hardware IDs based on which USB configuration is
selected.
>
> Of course, since hardware IDs for USB are the VID and PID, you
> could save yourself the time and effort by just changing the >
VID/PID on the device for each operating mode, and let the system
> USB bus driver do the work for you.

Dynamically? Within the current session? Windows can do that?

Cool!


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

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



IndiaInfo Mail - the free e-mail service with a difference! www.indiainfo.com
Check out our value-added Premium features, such as an extra 20MB for mail storage, POP3, e-mail forwarding, and ads-free mailboxes!