RE: About gadget configfs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



 
> 
> On Tue, 6 May 2014, Peter Chen wrote:
> 
> > 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.
> 

Yes, it may work from host side, but it seems there are some problems
at gadget side when switch configurations.

root@freescale /sys/kernel/config/usb_gadget/g1$ ln -s functions/mass_storage.1/
 configs/c.1/
root@freescale /sys/kernel/config/usb_gadget/g1$ mkdir functions/gser.1
root@freescale /sys/kernel/config/usb_gadget/g1$ ln -s functions/gser.1 configs/
c.2/
root@freescale /sys/kernel/config/usb_gadget/g1$ 
root@freescale /sys/kernel/config/usb_gadget/g1$ echo udc-0 > UDC
sh: write error: No such device
root@freescale /sys/kernel/config/usb_gadget/g1$ echo ci_hdrc.0 > UDC
root@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

root@freescale /sys/kernel/config/usb_gadget/g1$ 
root@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 ]---

b29397@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@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux