Skip to contentSkip to conversation

USB Gadget via ConfigFS; define custom String Descriptors

DISCUSSION Ingo Rohloff 1 participant 1 message Dec 22, 2020 USB

lore
Share & tools
lore
#0 lore raw

Hello,

before trying to implement something I would like to get some opinions if what I am thinking of seems to be useful, or if I am on the wrong track.

I am implementing a USB Gadget.
To configure the gadget I use ConfigFS.
Now what I would like to do is to configure some device specific string descriptors, which have a fixed, custom index.

Now I know that if you for example create a gadget in configFS at directory
usb_gadget/g1

you will get the following standard device string descriptors:
usb_gadget/g1/strings/0x409
manufacturer
product
serialnumber

You might set the content of these string descriptors by writing to these files.
The indexes of these string descriptors gets auto-assigned as far as I understand the Linux source code.
These indexes are then put into the USB device descriptor, which is how a USB host finds out which indexes to use.

What I now want to do is to define additional string descriptors, with some fixed, custom indexes.

Questions:

* Is this simply not intended by the USB spec ?

* Is there already a way to do that via ConfigFS,
which I am not aware of ?

* Does a mechanism to define such custom string descriptors sound useful ? So is it worth the effort to implement it ?

Just a super simple proposal how to do that; since I have no experience what's best for ConfigFS, please advise if you think there is a better way!
If a user creates a file
usb_gadget/g1/strings/0x0409/

      custom_34

Then this will be accessible as USB device string descriptor, with index 0x34. So the two characters after the "_" are interpreted as two hex digits, which define the index.

Does this sound like a viable strategy to allow custom string descriptors ?

Ingo