title: usb_modeswitch with USB dongle 3G on qemu
body: <p>I am trying to use a dongle 3G within qemu with openwrt environment. Dongle ref : HUAWEi - K4605.</p>
  
  <p>First I have patch kernel sources in option.c :</p>
  
  <pre><code>--- option.c    2010-12-09 22:29:45.000000000 +0100
  +++ option.c    2012-11-12 17:39:17.000000000 +0100
  @@ -165,6 +165,7 @@
   #define HUAWEI_PRODUCT_E143D           0x143D
   #define HUAWEI_PRODUCT_E143E           0x143E
   #define HUAWEI_PRODUCT_E143F           0x143F
  +#define HUAWEI_PRODUCT_E14C6           0x14C6
   #define HUAWEI_PRODUCT_K4505           0x1464
   #define HUAWEI_PRODUCT_K3765           0x1465
   #define HUAWEI_PRODUCT_E14AC           0x14AC
  @@ -477,6 +478,7 @@
      { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E143E, 0xff, 0xff, 0xff) },
      { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E143F, 0xff, 0xff, 0xff) },
      { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_K4505, 0xff, 0xff, 0xff) },
  +   { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E14C6, 0xff, 0xff, 0xff) },
      { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_K3765, 0xff, 0xff, 0xff) },
      { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_ETS1220, 0xff, 0xff, 0xff) },
      { USB_DEVICE_AND_INTERFACE_INFO(HUAWEI_VENDOR_ID, HUAWEI_PRODUCT_E14AC, 0xff, 0xff, 0xff) },
  </code></pre>
  
  <p>I have also install kernel module as kmod-usb-serial-option or kmod-usb-uhci.
  Next, I have disable auto usb_modeswitch on host machine in /etc/usb_modeswitch.conf. </p>
  
  <p>My dongle have two product/vendor id, 12d1:14c1 when we are using it in storage mod, and 12d1:14c6 in dongle 3G mod. I run my qemu with usb option :         </p>
  
  <pre><code>-usb -usbdevice host:12d1:14c6 -usbdevice host:12d1:14c1 
  </code></pre>
  
  <p>I detect my device on my qemu machine with lsusb in storage mod. Now I have to switch it with : <code>/usr/bin/usb_modeswitch -v 12d1 -p 14c1 -W -M "55534243123456780000000000000011062000000100000000000000000000"</code></p>
  
  <p>This step is not working. After putting some debugging code in usb_modeswitch.c, I can see that usb_bulk_write is working but the usb_bulk_read never respond. I modified sources of usb_modeswitch to remove limitless waiting of usb_bulk_read. Thanks to this modification, I can see with lsusb that my dongle success to switch but dev entry ttyUSB0 is not create in /dev... </p>
  
  <p>trace of usb_modeswitch is :</p>
  
  <blockquote>
  <pre><code>root@OpenWrt:~# /usr/bin/usb_modeswitch -v 12d1 -p 14c1 -W -M "55534243123456780000000000000011062000000100000000000000000000"
  scsi 2:0:0:0: CD-ROM            Vodafone CD ROM (Huawei)  2.31 PQ: 0 ANSI: 2
  scsi 3:0:0:0: Direct-Access     Vodafone Storage (Huawei)      PQ: 0 ANSI: 2
  sd 3:0:0:0: [sdb] Attached SCSI removable disk
  
  Taking all parameters from the command line
  
  
   usb_modeswitch: handle USB devices with multiple modes
   Version 1.2.3 (C) Josua Dietze 2012
   Based on libusb0 (0.1.12 and above)
  
   PLEASE REPORT NEW CONFIGURATIONS !
  
  DefaultVendor=  0x12d1
  DefaultProduct= 0x14c1
  TargetVendor=   not set
  TargetProduct=  not set
  TargetClass=    not set
  TargetProductList=""
  
  DetachStorageOnly=0
  HuaweiMode=0
  SierraMode=0
  SonyMode=0
  QisdaMode=0
  GCTMode=0
  KobilMode=0
  SequansMode=0
  MobileActionMode=0
  CiscoMode=0
  MessageEndpoint=  not set
  MessageContent="55534243123456780000000000000011062000000100000000000000000000"
  NeedResponse=0
  ResponseEndpoint= not set
  
  InquireDevice enabled (default)
  Success check disabled
  System integration mode disabled
  
  
  Looking for default devices ...
    searching devices, found USB ID 1d6b:0001
    searching devices, found USB ID 0409:55aa
    searching devices, found USB ID 12d1:14c1
     found matching vendor ID
     found matching product ID
     adding device
   Found device in default mode, class or configuration (1)
  Accessing device 003 on bus 001 ...
  Getting the current device configuration ...
   OK, got current device configuration (1)
  Using first interface: 0x00
  Using endpoints 0x01 (out) and 0x81 (in)
  Inquiring device details; driver will be detached ...
  Looking for active driver ...
   OK, driver found; name unknown, limitation of libusb1
   OK, driver "unkown" detached
   Could not get INQUIRY response (error -110)
  
  USB description data (for identification)
  -------------------------
  Manufacturer: Vodafone Group (Huawei) 
       Product: Vodafone Mobile Broadband (Huawei) 
    Serial No.: not provided
  -------------------------
  Looking for active driver ...
   No driver found. Either detached before or never attached
  Setting up communication with interface 0
  Using endpoint 0x01 for message sending ...
  Trying to send message 1 to endpoint 0x01 ...
   OK, message successfully sent
  Resetting response endpoint 0x81
  libusb:error [op_clear_halt] clear_halt failed error -1 errno 32
   Could not reset endpoint (probably harmless): -34
  Resetting message endpoint 0x01
  libusb:error [op_clear_halt] clear_halt failed error -1 errno 32
   Could not reset endpoint (probably harmless): -34
  usb 1-2.1: USB disconnect, address 3
   Device is gone, skipping any further commands
  -&gt; Run lsusb to note any changes. Bye.
  </code></pre>
  </blockquote>
  
  <p>Someone have a solution ? Do I have to configure qemu in a certain way to send msg to my dongle through bulk endpoint ?</p>
  
  <p>Thanks,</p>