EmbeddedRelated.com
Forums
The 2024 Embedded Online Conference

USB firmware programming

Started by hectorhg April 22, 2008
Hi there,

  I'm trying to programme a USB to behave like a mass storage device and a
network unit (rndis) as the same time (only one usb port), i mean, when i
plug it to a windows PC i would like to see two new devices plugged. The
only way i've found is to show the usb like a hub with virtual units
connected to it, all handled by software. Does anyone knows another way?

Thank you!!


> I'm trying to programme a USB to behave like a mass storage device and a > network unit (rndis) as the same time (only one usb port), i mean, when i > plug it to a windows PC i would like to see two new devices plugged. The > only way i've found is to show the usb like a hub with virtual units > connected to it, all handled by software. Does anyone knows another way?
Isn't it simply a matter of enumerating with two configurations, each of which enumerates to the two devices you described? JJS
John Speth wrote:

>> I'm trying to programme a USB to behave like a mass storage device and a >> network unit (rndis) as the same time (only one usb port), i mean, when i >> plug it to a windows PC i would like to see two new devices plugged. The >> only way i've found is to show the usb like a hub with virtual units >> connected to it, all handled by software. Does anyone knows another way? > > Isn't it simply a matter of enumerating with two configurations, each of > which enumerates to the two devices you described?
It is possible to have multiple configurations, but the host selects only one of them to be active at any given time. According to USB spec 2.0, section 5.2.3: "Multiple functions may be packaged together in what appears to be a single physical device. For example, a keyboard and a trackball might be combined in a single package. Inside the package, the individual functions are permanently attached to a hub and it is the internal hub that is connected to the USB. When multiple functions are combined with a hub in a single package, they are referred to as a compound device."
> I'm trying to programme a USB to behave like a mass storage device and a > network unit (rndis) as the same time (only one usb port), i mean, when i > plug it to a windows PC i would like to see two new devices plugged. The > only way i've found is to show the usb like a hub with virtual units > connected to it, all handled by software. Does anyone knows another way?
You need to present your USB device as a composite device, that is your (USB) configuration exposes the mass storage and RNDIS interface descriptors. So: Configuration / | \ | | | I/F MSC I/F CDC Control I/C CDC Data A hub with a device (permanently) attached to one of its ports is a compound device. Andrew
I think a cannot use two configurations, because in order to use rndis a
have to select a device descriptor, and for masss storage another one,
that's why i thought it wasn´t possible. How do i present my device as a
composite device? i couldn't find any device descriptor for that although i
have read something about them ( maybe i have skipped it by error....).

Thanks to all of you!!!!


>> I'm trying to programme a USB to behave like a mass storage device
and a
>> network unit (rndis) as the same time (only one usb port), i mean, when
i
>> plug it to a windows PC i would like to see two new devices plugged.
The
>> only way i've found is to show the usb like a hub with virtual units >> connected to it, all handled by software. Does anyone knows another
way?
> >You need to present your USB device as a composite device, that is your >(USB) configuration exposes the mass storage and RNDIS interface >descriptors. So: > > Configuration > / | \ > | | | > I/F MSC I/F CDC Control I/C CDC Data > >A hub with a device (permanently) attached to one of its ports is a >compound device. > > Andrew >
I think a cannot use two configurations, because in order to use rndis a
have to select a device descriptor, and for masss storage another one,
that's why i thought it wasn´t possible. How do i present my device as a
composite device? i couldn't find any device descriptor for that although i
have read something about them ( maybe i have skipped it by error....).

Thanks to all of you!!!!


>> I'm trying to programme a USB to behave like a mass storage device
and a
>> network unit (rndis) as the same time (only one usb port), i mean, when
i
>> plug it to a windows PC i would like to see two new devices plugged.
The
>> only way i've found is to show the usb like a hub with virtual units >> connected to it, all handled by software. Does anyone knows another
way?
> >You need to present your USB device as a composite device, that is your >(USB) configuration exposes the mass storage and RNDIS interface >descriptors. So: > > Configuration > / | \ > | | | > I/F MSC I/F CDC Control I/C CDC Data > >A hub with a device (permanently) attached to one of its ports is a >compound device. > > Andrew >
I've read a little more about composite devices, do you mean that just
adding a new interface to my CDC device with mass storage class should be
enough?? will the PC detect it? Is it not necessary a special device
descriptor to represent that, or a protocol, subclass or whatever??

Thank you again.


>> >>You need to present your USB device as a composite device, that is your
>>(USB) configuration exposes the mass storage and RNDIS interface >>descriptors. So: >> >> Configuration >> / | \ >> | | | >> I/F MSC I/F CDC Control I/C CDC Data >> >>A hub with a device (permanently) attached to one of its ports is a >>compound device. >> >> Andrew >> >
I've read a little more about composite devices, do you mean that just
adding a new interface to my CDC device with mass storage class should be
enough?? will the PC detect it? Is it not necessary a special device
descriptor to represent that, or a protocol, subclass or whatever??

Thank you again.


>> >>You need to present your USB device as a composite device, that is your
>>(USB) configuration exposes the mass storage and RNDIS interface >>descriptors. So: >> >> Configuration >> / | \ >> | | | >> I/F MSC I/F CDC Control I/C CDC Data >> >>A hub with a device (permanently) attached to one of its ports is a >>compound device. >> >> Andrew >> >
> I've read a little more about composite devices, do you mean that just > adding a new interface to my CDC device with mass storage class should be > enough?? will the PC detect it? Is it not necessary a special device > descriptor to represent that, or a protocol, subclass or whatever??
Your device descriptor would need to look something like: Device class 0 Device subclass 0 Device protocol 0 Then you'd have three interface descriptors: (CDC Abstract Control) Interface class 0x02 Interface subclass 0x02 Interface protocol 0xff (CDC Data) Interface class 0x0a Interface subclass 0x00 Intterface protocol 0x00 (MSC - not values depend on your implementation) Interface class 0x08 Interface subclass 0x06 Interface protocol 0x50 You may need an Interface Association Descriptor to bind the CDC interfaces together. Andrew
Thank you very much. I think that an IAD interface will be necessary since
data class and CDC class "work" as one (as far as i know, both interface
are intended for the same device, so they should be binded in some
way...).

Thank you again, you have helped me a lot


>> I've read a little more about composite devices, do you mean that just >> adding a new interface to my CDC device with mass storage class should
be
>> enough?? will the PC detect it? Is it not necessary a special device >> descriptor to represent that, or a protocol, subclass or whatever?? > >Your device descriptor would need to look something like: > > Device class 0 > Device subclass 0 > Device protocol 0 > > >Then you'd have three interface descriptors: > >(CDC Abstract Control) > Interface class 0x02 > Interface subclass 0x02 > Interface protocol 0xff >(CDC Data) > Interface class 0x0a > Interface subclass 0x00 > Intterface protocol 0x00 >(MSC - not values depend on your implementation) > Interface class 0x08 > Interface subclass 0x06 > Interface protocol 0x50 > >You may need an Interface Association Descriptor to bind the CDC >interfaces together. > > Andrew >

The 2024 Embedded Online Conference