Discussion:
About gadget configfs
Peter Chen
2014-05-04 07:48:51 UTC
Permalink
Hi Sebastian & Andrzej,

I have tried configfs today, and have some puzzled about its
behaviour, hope I can get answers from your both, thanks.

I am running the latest usb-next tree (3.15-rc3), and build
configfs as module, and enabled mass storage and serial, I follow
the instruction of ocumentation/usb/gadget_configfs.txt

The step at the board:

***@freescale ~$ modprobe libcomposite
***@freescale ~$ mount none /sys/kernel/config/ -t configfs
***@freescale ~$ mkdir /sys/kernel/config/usb_gadget/g1
***@freescale ~$ cd /sys/kernel/config/usb_gadget/g1/
***@freescale /sys/kernel/config/usb_gadget/g1$ echo 0x15a2 > idVendor
***@freescale /sys/kernel/config/usb_gadget/g1$ echo 0x0054 > idProduct
***@freescale /sys/kernel/config/usb_gadget/g1$ mkdir strings/0x409
***@freescale /sys/kernel/config/usb_gadget/g1$ echo 123456ABCDEF >
strings/0x4
09/serialnumber
***@freescale /sys/kernel/config/usb_gadget/g1$ echo Freescale >
strings/0x409/
manufacturer
***@freescale /sys/kernel/config/usb_gadget/g1$ echo "FSL i.mx6q
sabreSD Board"
strings/0x409/product
***@freescale /sys/kernel/config/usb_gadget/g1$ echo 5 >
configs/c.1/MaxPower
***@freescale /sys/kernel/config/usb_gadget/g1$ mkdir
functions/mass_storage.1
Number of LUNs=8
Mass Storage Function, version: 2009/09/11
LUN: removable file: (no medium)
***@freescale /sys/kernel/config/usb_gadget/g1$ echo
"/dev/mmcblk0p1" > functio
ns/mass_storage.1/lun.0/file

***@freescale /sys/kernel/config/usb_gadget/g1$ mkdir
functions/gser.1
***@freescale /sys/kernel/config/usb_gadget/g1$ cat
functions/gser.1/port_num
0

***@freescale /sys/kernel/config/usb_gadget/g1$ lsmod
Module Size Used by
usb_f_serial 2974 2
u_serial 10032 1 usb_f_serial
usb_f_mass_storage 38373 2
libcomposite 37503 10 usb_f_serial,usb_f_mass_storage

***@freescale /sys/kernel/config/usb_gadget/g1$ ls /sys/class/udc/
ci_hdrc.0
***@freescale /sys/kernel/config/usb_gadget/g1$ echo "ci_hdrc.0" > UDC
***@freescale /sys/kernel/config/usb_gadget/g1$ configfs-gadget gadget:
high-speed config #2: c

At Linux PC:

***@nchen-desktop:~$ lsusb -d 15a2:0054 -v

Bus 001 Device 064: ID 15a2:0054 Freescale Semiconductor, Inc.
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 0.00
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x15a2 Freescale Semiconductor, Inc.
idProduct 0x0054
bcdDevice 3.15
iManufacturer 1 Freescale
iProduct 2 FSL i.mx6q sabreSD Board
iSerial 3 123456ABCDEF
bNumConfigurations 2
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 32
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x80
(Bus Powered)
MaxPower 6mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 0
bInterfaceProtocol 0
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x01 EP 1 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 32
bNumInterfaces 1
bConfigurationValue 2
iConfiguration 0
bmAttributes 0x80
(Bus Powered)
MaxPower 2mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 8 Mass Storage
bInterfaceSubClass 6 SCSI
bInterfaceProtocol 80 Bulk (Zip)
iInterface 5 Mass Storage
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x01 EP 1 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 1
Device Status: 0x0000

My questions:

- Why mass storage has been chosen at PC, but not gserial?
- Is it possible both two configurations can be seen at PC?
If possible, how to do?
- How to choose gserial? I tried to remove the configuration
of mass storage, but both of configurations have been removed

***@freescale /sys/kernel/config/usb_gadget/g1$ rm -rf
configs/c.2/mass_storage
.1/
configfs-gadget gadget: unbind function 'gser'/be822b80
configfs-gadget gadget: unbind function 'Mass Storage Function'/be822d80
--
Best Regards,
Peter Chen
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-***@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Peter Stuge
2014-05-04 10:31:40 UTC
Permalink
Hi Peter,
I guess this step is unneccessary, and that all neccessary modules
are loaded automatically on demand.
I guess you also did a "mkdir configs/c.1" step here?
Post by Peter Chen
Number of LUNs=8
Mass Storage Function, version: 2009/09/11
LUN: removable file: (no medium)
0
So far so good! You've created two functions in the gadget, following
gadget_configfs.txt up to and including section 3.

Section 4. comes next, which wasn't included in your list of commands.
"Associating the functions with their configurations"

ln -s functions/<name>.<instance name> configs/<name>.<number>

I assume that this results in having only a single configuration with
two interfaces.
Post by Peter Chen
- Why mass storage has been chosen at PC, but not gserial?
Probably because the host (PC) doesn't have a driver for gserial with
your chosen vid+pid.
Post by Peter Chen
- Is it possible both two configurations can be seen at PC?
If possible, how to do?
Both configurations *are* seen by the host - but only one
configuration of a USB device can be selected at any one time.

If you want both functions available simultaneously then they must be
two different interfaces within a single configuration. I believe the
symlink described in gadget_configfs.txt section 4. accomplishes that.
Post by Peter Chen
- How to choose gserial? I tried to remove the configuration
of mass storage, but both of configurations have been removed
I guess that you will need to add your vid+pid to the host driver.
Where does configs/c.2 come from? It wasn't mentioned before in your steps?


Best regards

//Peter
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-***@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Andrzej Pietrasiewicz
2014-05-05 08:50:13 UTC
Permalink
Hello,
Post by Peter Stuge
Hi Peter,
I guess this step is unneccessary, and that all neccessary modules
are loaded automatically on demand.
This one is necessary. The code which implements the function registration
interface is located in libcomposite. Once libcomposite is loaded
all other modules are requested automatically, indeed.
Post by Peter Stuge
I guess you also did a "mkdir configs/c.1" step here?
Definitely yes.
Post by Peter Stuge
Post by Peter Chen
Number of LUNs=8
Mass Storage Function, version: 2009/09/11
LUN: removable file: (no medium)
0
So far so good! You've created two functions in the gadget, following
gadget_configfs.txt up to and including section 3.
Section 4. comes next, which wasn't included in your list of commands.
"Associating the functions with their configurations"
ln -s functions/<name>.<instance name> configs/<name>.<number>
I assume that this results in having only a single configuration with
two interfaces.
Configurations can provide a number of functions. To tell the kernel
which functions you want in a configuration you make symbolic links -
the links point at the functions you want and the links themselves
are located in your configuration's directory.
The same function can be exposed in more than one configuration.
It is ok, because only one configuration can be active at a time.
Post by Peter Stuge
Post by Peter Chen
- Why mass storage has been chosen at PC, but not gserial?
Probably because the host (PC) doesn't have a driver for gserial with
your chosen vid+pid.
A likely cause.
Post by Peter Stuge
Post by Peter Chen
- Is it possible both two configurations can be seen at PC?
If possible, how to do?
Both configurations *are* seen by the host - but only one
configuration of a USB device can be selected at any one time.
If you want both functions available simultaneously then they must be
two different interfaces within a single configuration. I believe the
symlink described in gadget_configfs.txt section 4. accomplishes that.
That's right. Please see above.
Post by Peter Stuge
Post by Peter Chen
- How to choose gserial? I tried to remove the configuration
of mass storage, but both of configurations have been removed
I guess that you will need to add your vid+pid to the host driver.
At a linux host you need to use vendor and product parameters of the
usbserial module.


AP

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-***@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Peter Chen
2014-05-06 01:01:15 UTC
Permalink
Post by Peter Chen
Hi Sebastian & Andrzej,
<snip>
<snip>
Post by Peter Chen
- How to choose gserial? I tried to remove the configuration
of mass storage, but both of configurations have been removed
configs/c.2/mass_storage
.1/
configfs-gadget gadget: unbind function 'gser'/be822b80
configfs-gadget gadget: unbind function 'Mass Storage Function'/be822d80
When you remove a symbolic link pointing at a function when the gadget is bound
(active), then the gadget is unbound by design.
There is no perfect solution to this problem. When the gadget is bound
the host has already enumerated it and selected the gadget's configuration.
What would it mean if gadget's identity/composition changed? As far as
I know the USB standard does not allow changig device's identity and/or
structure (that is: what configurations and functions there are) on the fly.
So a sensible solution here is to force gadget's unbind so it can be
bound again with new identity/composition.
And it is not device's (gadget's) role at all to decide which configuration
to activate. USB is a host-centric bus and nothing happens on the bus
without host's initiative. It is totally up to the host which configuration
to select. The host must know somehow which one to choose. Please be aware
that some proprietary operating systems never ask for configurations
other than the one at index 0.
You can have more than one function (interface from the host's point of view)
in one configuration and the host should handle it properly. The host must
know how to do it, though, so you need appropriate host-side drivers and/or their
parameters set properly.
Thanks Andrzej & Peter. (Mailbox problem, this email should be out
yesterday)

1. I have setup successfully for running mass storage and CDC ACM at the
same time with below steps:

- Using CDC ACM config (CONFIG_USB_CONFIGFS_ACM), I thought the gser at
configfs is the same with g_serial, but in fact, it is not. The gser at
configfs seems to work not well at my linux pc, it can't create serial
port, but the acm and g_serial can let the pc create /dev/ttyACM0.

- Create two interfaces at one configurations mkdir
functions/mass_storage.1 echo "/dev/mmcblk0p1" >
functions/mass_storage.1/lun.0/file
ln -s functions/mass_storage.1 configs/c.1 mkdir functions/acm.1 ln -s
functions/acm.1 configs/c.1

- Let udc run
echo ci_hdrc.0 > UDC

At host, I can see both interfaces at one configuration.

2. But when I try to remove one function, it removes two functions
together, does it be expected? Andrzej has answered, it is expected.

***@freescale /sys/kernel/config/usb_gadget/g1$ rm -rf
configs/c.1/mass_storage .1/ configfs-gadget gadget: unbind function
'acm'/be443e40 configfs-gadget gadget: unbind function 'Mass Storage
Function'/be595280 ***@freescale /sys/kernel/config/usb_gadget/g1$ ls
-l configs/c.1/
-rw-r--r-- 1 root root 4096 Apr 30 00:37 MaxPower
lrwxrwxrwx 1 root root 0 Apr 30 00:39 acm.1 ->
../../../../usb_gadget/g1/functions/acm.1
-rw-r--r-- 1 root root 4096 Apr 30 01:02 bmAttributes
drwxr-xr-x 2 root root 0 Apr 30 00:37 strings

3. Besides, I have tried two configurations, and each configuration with
one function, I find the host PC always set configuration 1 (The first
configuration), any ways to switch configuration at host
side? libusb?

When I tried to delete one un-selected configuration (configuration 2),
the configfs also delete both functions two. Andrzej has answered,
it is expected.

***@freescale /sys/kernel/config/usb_gadget/g1$ rm -rf
configs/c.2/mass_storage .1/ configfs-gadget gadget: unbind
function 'acm'/beb85180 configfs-gadget gadget: unbind function
'Mass Storage Function'/be524f80
--
Best Regards,
Peter Chen
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-***@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Alan Stern
2014-05-06 14:03:53 UTC
Permalink
Post by Peter Chen
3. Besides, I have tried two configurations, and each configuration with
one function, I find the host PC always set configuration 1 (The first
configuration), any ways to switch configuration at host
side? libusb?
You can switch configurations on a Linux host by writing to a sysfs
file:

echo N >/sys/bus/usb/devices/.../bConfigurationValue

where N is the bConfigurationValue of the config you want to use and
"..." is the pathname for the device.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-***@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Peter Chen
2014-05-20 09:12:57 UTC
Permalink
Post by Alan Stern
Post by Peter Chen
3. Besides, I have tried two configurations, and each configuration
with one function, I find the host PC always set configuration 1 (The
first
Post by Peter Chen
configuration), any ways to switch configuration at host side?
libusb?
You can switch configurations on a Linux host by writing to a sysfs
echo N >/sys/bus/usb/devices/.../bConfigurationValue
where N is the bConfigurationValue of the config you want to use and
"..." is the pathname for the device.
Yes, it may work from host side, but it seems there are some problems
at gadget side when switch configurations.

***@freescale /sys/kernel/config/usb_gadget/g1$ ln -s functions/mass_storage.1/
configs/c.1/
***@freescale /sys/kernel/config/usb_gadget/g1$ mkdir functions/gser.1
***@freescale /sys/kernel/config/usb_gadget/g1$ ln -s functions/gser.1 configs/
c.2/
***@freescale /sys/kernel/config/usb_gadget/g1$
***@freescale /sys/kernel/config/usb_gadget/g1$ echo udc-0 > UDC
sh: write error: No such device
***@freescale /sys/kernel/config/usb_gadget/g1$ echo ci_hdrc.0 > UDC
***@freescale /sys/kernel/config/usb_gadget/g1$ configfs-gadget gadget: high-speed config #1: c

=============>>>>>At host side run: echo 2 > /sys/bus/usb/devices/1-6/bConfigurationValue

***@freescale /sys/kernel/config/usb_gadget/g1$
***@freescale /sys/kernel/config/usb_gadget/g1$ configfs-gadget gadget: high-speed config #2: c
ci_hdrc ci_hdrc.0: enabling a non-empty endpoint!
------------[ cut here ]------------
WARNING: CPU: 0 PID: 764 at /home/b29397/work/projects/upstream/usb/usb/kernel/locking/lockdep.c:3159 __lock_acquire+0x68c/0x90c()
DEBUG_LOCKS_WARN_ON(id >= MAX_LOCKDEP_KEYS)
Modules linked in: usb_f_serial u_serial usb_f_mass_storage libcomposite ci_hdrc_imx usbmisc_imx ci_hdrc
CPU: 0 PID: 764 Comm: file-storage Not tainted 3.15.0-rc3+ #222
Backtrace:
[<80011d88>] (dump_backtrace) from [<80012128>] (show_stack+0x18/0x1c)
r6:807f3b94 r5:00000000 r4:00000000 r3:00000000
[<80012110>] (show_stack) from [<80672900>] (dump_stack+0x80/0x9c)
[<80672880>] (dump_stack) from [<80028b40>] (warn_slowpath_common+0x6c/0x8c)
r5:00000c57 r4:be64fd40
[<80028ad4>] (warn_slowpath_common) from [<80028c04>] (warn_slowpath_fmt+0x38/0x40)
r8:00000448 r7:00000000 r6:be713484 r5:00000000 r4:00000000
[<80028bd0>] (warn_slowpath_fmt) from [<8006698c>] (__lock_acquire+0x68c/0x90c)
r3:807f4abc r2:807f115c
[<80066300>] (__lock_acquire) from [<8006719c>] (lock_acquire+0x68/0x7c)
r10:00000000 r9:00000000 r8:00000002 r7:00000080 r6:60000093 r5:be64e000
r4:00000000
[<80067134>] (lock_acquire) from [<8067dd24>] (_raw_spin_lock+0x34/0x44)
r7:be55f220 r6:be713474 r5:00000001 r4:be713474
[<8067dcf0>] (_raw_spin_lock) from [<7f026cdc>] (bulk_out_complete+0x34/0x7c [usb_f_mass_storage])
r5:00000000 r4:be713400
[<7f026ca8>] (bulk_out_complete [usb_f_mass_storage]) from [<7f0020a0>] (ep_dequeue+0xcc/0xf8 [ci_hdrc])
r7:80000013 r6:be76aeb4 r5:be76ae80 r4:bebc04e4
[<7f001fd4>] (ep_dequeue [ci_hdrc]) from [<7f028484>] (handle_exception+0x11c/0x3f0 [usb_f_mass_storage])
r7:be64e000 r6:60000013 r5:be5a3400 r4:00000002
[<7f028368>] (handle_exception [usb_f_mass_storage]) from [<7f02a9fc>] (fsg_main_thread+0x154/0x1f4 [usb_f_mass_storage])
r8:fffffff8 r7:fffffff7 r6:be5a3474 r5:be64e000 r4:be5a3400
[<7f02a8a8>] (fsg_main_thread [usb_f_mass_storage]) from [<80046c24>] (kthread+0xd0/0xec)
r10:00000000 r8:00000000 r7:7f02a8a8 r6:be5a3400 r5:be70d940 r4:00000000
[<80046b54>] (kthread) from [<8000ea48>] (ret_from_fork+0x14/0x2c)
r7:00000000 r6:00000000 r5:80046b54 r4:be70d940
---[ end trace f883df719f2cfac6 ]---

***@nchen-desktop:~$ lsusb -d 15a2:0054 -v

Bus 001 Device 006: ID 15a2:0054 Freescale Semiconductor, Inc.
Device Descriptor:
bLength 18
bDescriptorType 1
bcdUSB 0.00
bDeviceClass 0 (Defined at Interface level)
bDeviceSubClass 0
bDeviceProtocol 0
bMaxPacketSize0 64
idVendor 0x15a2 Freescale Semiconductor, Inc.
idProduct 0x0054
bcdDevice 3.15
iManufacturer 1 Freescale
iProduct 2 FSL i.mx6q sabreSD Board
iSerial 3 123456ABCDEF
bNumConfigurations 2
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 32
bNumInterfaces 1
bConfigurationValue 1
iConfiguration 0
bmAttributes 0x80
(Bus Powered)
MaxPower 6mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 8 Mass Storage
bInterfaceSubClass 6 SCSI
bInterfaceProtocol 80 Bulk (Zip)
iInterface 4 Mass Storage
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x01 EP 1 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 1
Configuration Descriptor:
bLength 9
bDescriptorType 2
wTotalLength 32
bNumInterfaces 1
bConfigurationValue 2
iConfiguration 0
bmAttributes 0x80
(Bus Powered)
MaxPower 2mA
Interface Descriptor:
bLength 9
bDescriptorType 4
bInterfaceNumber 0
bAlternateSetting 0
bNumEndpoints 2
bInterfaceClass 255 Vendor Specific Class
bInterfaceSubClass 0
bInterfaceProtocol 0
iInterface 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x81 EP 1 IN
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Endpoint Descriptor:
bLength 7
bDescriptorType 5
bEndpointAddress 0x01 EP 1 OUT
bmAttributes 2
Transfer Type Bulk
Synch Type None
Usage Type Data
wMaxPacketSize 0x0200 1x 512 bytes
bInterval 0
Device Status: 0x0000
(Bus Powered)
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-***@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Andrzej Pietrasiewicz
2014-05-06 06:40:40 UTC
Permalink
Hi Peter,
Post by Peter Chen
Post by Peter Chen
Hi Sebastian & Andrzej,
<snip>
Post by Peter Chen
1. I have setup successfully for running mass storage and CDC ACM at the
- Using CDC ACM config (CONFIG_USB_CONFIGFS_ACM), I thought the gser at
configfs is the same with g_serial, but in fact, it is not. The gser at
configfs seems to work not well at my linux pc, it can't create serial
port, but the acm and g_serial can let the pc create /dev/ttyACM0.
It is the same function.
g_serial in fact offers _three_ different functions:

- acm proper
- gser
- obex

Which is chosen depends on g_serial's module parameters.
Please do modinfo g_serial.
If use_acm is true, ACM is used [use_acm is true by default].
Else if use_obex is true, obex is used [use_obex is false by default].
Else gser is used.
So if you load g_serial without using any parameters, in fact you
get acm, not gser.

Please add "use_acm=0" to modprobe/insmod g_serial and try again,
and see if the host creates a new node in /dev.
Please note, that if you use generic serial (gser), then the host
creates /dev/ttyUSB<n>, not /dev/ttyACM<n>.

Only if you successfully see /dev/ttyUSB<n> at host using g_serial,
you can start suspecting gser set up through configfs interface
of not working correctly.

Please note that g_serial by default uses 0x0525 as vendor id
and as product id it uses 0xa4a7 for ACM, 0xa4a9 for obex and
0xa4a6 for generic serial. If your PC host can only talk to gadgets
with these ids you need to use the same with configfs,
or configure your host to accept different ids.


<snip>
Post by Peter Chen
3. Besides, I have tried two configurations, and each configuration with
one function, I find the host PC always set configuration 1 (The first
configuration), any ways to switch configuration at host
side? libusb?
You either have a driver/class driver at the host side, or use libusb.

AP

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-***@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Andrzej Pietrasiewicz
2014-05-05 09:09:30 UTC
Permalink
Post by Peter Chen
Hi Sebastian & Andrzej,
<snip>
<snip>
Post by Peter Chen
- How to choose gserial? I tried to remove the configuration
of mass storage, but both of configurations have been removed
configs/c.2/mass_storage
.1/
configfs-gadget gadget: unbind function 'gser'/be822b80
configfs-gadget gadget: unbind function 'Mass Storage Function'/be822d80
When you remove a symbolic link pointing at a function when the gadget is bound
(active), then the gadget is unbound by design.
There is no perfect solution to this problem. When the gadget is bound
the host has already enumerated it and selected the gadget's configuration.
What would it mean if gadget's identity/composition changed? As far as
I know the USB standard does not allow changig device's identity and/or
structure (that is: what configurations and functions there are) on the fly.
So a sensible solution here is to force gadget's unbind so it can be
bound again with new identity/composition.

And it is not device's (gadget's) role at all to decide which configuration
to activate. USB is a host-centric bus and nothing happens on the bus
without host's initiative. It is totally up to the host which configuration
to select. The host must know somehow which one to choose. Please be aware
that some proprietary operating systems never ask for configurations
other than the one at index 0.

You can have more than one function (interface from the host's point of view)
in one configuration and the host should handle it properly. The host must
know how to do it, though, so you need appropriate host-side drivers and/or their
parameters set properly.

AP

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-***@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Loading...