On Mon, May 05, 2014 at 11:09:30AM +0200, Andrzej Pietrasiewicz wrote: > W dniu 04.05.2014 09:48, Peter Chen pisze: > >Hi Sebastian & Andrzej, > > <snip> > > > > >My questions: > > > > <snip> > > >- How to choose gserial? I tried to remove the configuration > >of mass storage, but both of configurations have been removed > > > >root@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 > > > > 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. root@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 root@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. root@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@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html