Automatic Activation, Hotplug and UDEV, Configuration
isak.sr
Posts: 20
Joined: 24 Jan 2010, 19:39

Post by isak.sr » 20 Feb 2010, 07:08

lsusb -v with modem "usable"

Code: Select all

Bus 001 Device 009: ID 12d1:101e Huawei Technologies Co., Ltd. 
Device Descriptor:                                             
  bLength                18                                    
  bDescriptorType         1                                    
  bcdUSB               2.00                                    
  bDeviceClass            0 (Defined at Interface level)       
  bDeviceSubClass         0                                    
  bDeviceProtocol         0                                    
  bMaxPacketSize0        64                                    
  idVendor           0x12d1 Huawei Technologies Co., Ltd.      
  idProduct          0x101e                                    
  bcdDevice            0.00                                    
  iManufacturer           2 Huawei Technologies                
  iProduct                1 Mobile Configuration               
  iSerial                 0                                    
  bNumConfigurations      1                                    
  Configuration Descriptor:                                    
    bLength                 9                                  
    bDescriptorType         2                                  
    wTotalLength          173                                  
    bNumInterfaces          3                                  
    bConfigurationValue     1                                  
    iConfiguration          1 Mobile Configuration             
    bmAttributes         0xe0                                  
      Self Powered                                             
      Remote Wakeup                                            
    MaxPower              500mA                                
    Interface Descriptor:                                      
      bLength                 9                                
      bDescriptorType         4                                
      bInterfaceNumber        0                                
      bAlternateSetting       0                                
      bNumEndpoints           3                                
      bInterfaceClass       255 Vendor Specific Class          
      bInterfaceSubClass    255 Vendor Specific Subclass       
      bInterfaceProtocol    255 Vendor Specific Protocol       
      iInterface              0                                
      ** UNRECOGNIZED:  05 24 00 10 01                         
      ** UNRECOGNIZED:  04 24 02 02                            
      ** UNRECOGNIZED:  05 24 01 03 00                         
      ** UNRECOGNIZED:  05 24 06 00 00                         
      ** UNRECOGNIZED:  15 24 12 20 01 98 b0 6a 49 b0 9e 48 96 94 46 d9 9a 28 ca 4e 5d                                                                          
      ** UNRECOGNIZED:  06 24 13 00 01 10                                       
      Endpoint Descriptor:                                                      
        bLength                 7                                               
        bDescriptorType         5                                               
        bEndpointAddress     0x81  EP 1 IN                                      
        bmAttributes            3                                               
          Transfer Type            Interrupt                                    
          Synch Type               None                                         
          Usage Type               Data                                         
        wMaxPacketSize     0x0040  1x 64 bytes                                  
        bInterval               5                                               
      Endpoint Descriptor:                                                      
        bLength                 7                                               
        bDescriptorType         5                                               
        bEndpointAddress     0x82  EP 2 IN                                      
        bmAttributes            2                                               
          Transfer Type            Bulk                                         
          Synch Type               None                                         
          Usage Type               Data                                         
        wMaxPacketSize     0x0200  1x 512 bytes                                 
        bInterval              32                                               
      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              32                                               
    Interface Descriptor:                                                       
      bLength                 9                                                 
      bDescriptorType         4                                                 
      bInterfaceNumber        1                                                 
      bAlternateSetting       0                                                 
      bNumEndpoints           2                                                 
      bInterfaceClass       255 Vendor Specific Class                           
      bInterfaceSubClass    255 Vendor Specific Subclass                        
      bInterfaceProtocol    255 Vendor Specific Protocol                        
      iInterface              0                                                 
      ** UNRECOGNIZED:  05 24 00 10 01                                          
      ** UNRECOGNIZED:  05 24 15 00 01                                          
      ** UNRECOGNIZED:  05 24 06 01 01                                          
      ** UNRECOGNIZED:  15 24 12 20 01 98 b0 6a 49 b0 9e 48 96 94 46 d9 9a 28 ca 4e 5d                                                                          
      ** UNRECOGNIZED:  06 24 13 00 01 10                                       
      Endpoint Descriptor:                                                      
        bLength                 7                                               
        bDescriptorType         5                                               
        bEndpointAddress     0x83  EP 3 IN                                      
        bmAttributes            2                                               
          Transfer Type            Bulk                                         
          Synch Type               None                                         
          Usage Type               Data                                         
        wMaxPacketSize     0x0200  1x 512 bytes                                 
        bInterval              32                                               
      Endpoint Descriptor:                                                      
        bLength                 7                                               
        bDescriptorType         5                                               
        bEndpointAddress     0x02  EP 2 OUT                                     
        bmAttributes            2                                               
          Transfer Type            Bulk                                         
          Synch Type               None                                         
          Usage Type               Data                                         
        wMaxPacketSize     0x0200  1x 512 bytes                                 
        bInterval              32                                               
    Interface Descriptor:                                                       
      bLength                 9                                                 
      bDescriptorType         4                                                 
      bInterfaceNumber        2                                                 
      bAlternateSetting       0                                                 
      bNumEndpoints           2                                                 
      bInterfaceClass         8 Mass Storage                                    
      bInterfaceSubClass      6 SCSI                                            
      bInterfaceProtocol     80 Bulk (Zip)                                      
      iInterface              0                                                 
      Endpoint Descriptor:                                                      
        bLength                 7                                               
        bDescriptorType         5                                               
        bEndpointAddress     0x03  EP 3 OUT                                     
        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     0x84  EP 4 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
Device Qualifier (for other device speed):
  bLength                10
  bDescriptorType         6
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0        64
  bNumConfigurations      1
Device Status:     0x0001
  Self Powered

lsusb -v with modem "not usable"

Code: Select all


Bus 001 Device 010: ID 12d1:101e Huawei Technologies Co., Ltd. 
Device Descriptor:                                             
  bLength                18                                    
  bDescriptorType         1                                    
  bcdUSB               2.00                                    
  bDeviceClass            0 (Defined at Interface level)       
  bDeviceSubClass         0                                    
  bDeviceProtocol         0                                    
  bMaxPacketSize0        64                                    
  idVendor           0x12d1 Huawei Technologies Co., Ltd.      
  idProduct          0x101e                                    
  bcdDevice            0.00                                    
  iManufacturer           2 Huawei Technologies                
  iProduct                1 Mobile Configuration               
  iSerial                 0                                    
  bNumConfigurations      1                                    
  Configuration Descriptor:                                    
    bLength                 9                                  
    bDescriptorType         2                                  
    wTotalLength           32                                  
    bNumInterfaces          1                                  
    bConfigurationValue     1                                  
    iConfiguration          1 Mobile Configuration             
    bmAttributes         0xe0                                  
      Self Powered                                             
      Remote Wakeup                                            
    MaxPower              500mA                                
    Interface Descriptor:                                      
      bLength                 9                                
      bDescriptorType         4                                
      bInterfaceNumber        0                                
      bAlternateSetting       0                                
      bNumEndpoints           2                                
      bInterfaceClass         8 Mass Storage                   
      bInterfaceSubClass      6 SCSI                           
      bInterfaceProtocol     80 Bulk (Zip)                     
      iInterface              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
      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
Device Qualifier (for other device speed):
  bLength                10
  bDescriptorType         6
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0
  bDeviceProtocol         0
  bMaxPacketSize0        64
  bNumConfigurations      1
Device Status:     0x0001
  Self Powered

isak.sr
Posts: 20
Joined: 24 Jan 2010, 19:39

Post by isak.sr » 20 Feb 2010, 08:14

ok............

i managed to reproduce this 3 times... and i think i found when (but not how) the switch or modem activation happens

i restore xp to a month ago... to plug the phone as it was the first time... so what happens here is that windows only detect a usb storage cd rom...

so i follow and clicked on "3G connect via the phone"... it installs dial up and some drivers and it automatically unplugs phone...

in that moment i check in linux dmesg and i get modem...

so i reconnect phone in windows and i get the 4 devices i posted before... but i found this... the usb mass storage it mounts the first time is not the usb mass storage it mounts the second time...

i imagine that i was sniffing the wrong usb mass storage...
as i found this reproduce it 3 times with same results... so i sniffed on the FIRST usb mass storage that appears...

its quite big cause it has the install of the dial up program but i didnt wanted to erase anything... it is like reading chinesse for me :? (you are aware that im not a developer right?)

http://www.gigasize.com/get.php?d=so0yvr9zslf

hope this helps... (still frustrated and going back to windows tho)

Josh
Site Admin
Posts: 6570
Joined: 03 Nov 2007, 00:30

Post by Josh » 20 Feb 2010, 09:29

Now you're talking :)

The "lsusb" shows that the phone does indeed switch ... but it keeps the USB ID. You can see (in fact you did) that the interfaces are changing internally.

And your log has an interesting ending. The end is the only relevant part because that's where the old "CD ROM" is gone. The switch must happen immediately before that.

There is a suspicious command that you should try:

Code: Select all

usb_modeswitch -v 0x12d1 -p 0x101e -C 0xff -M "55534243123456780600000080000601000000000000000000000000000000" 
(in one line, as usual)

The "-C" option allows usb_modeswitch to decide if the device was switched or not. If you look at your both "lsusb" outputs, you can see that in "modem unusable" state, the first "bInterfaceClass" says "8". In "modem usable" state it says "255"(or 0xff in hexadecimal). That is the "TargetClass", and that is the way to distinguish which state the device is in.

The easiest way to test if the switch was successful is to run the same usb_modeswitch command again and see if it says "found device in target mode or class". Of course, "dmesg" should also have something to say.


isak.sr
Posts: 20
Joined: 24 Jan 2010, 19:39

Post by isak.sr » 21 Feb 2010, 03:55

[ 260.838334] option 1-6:1.0: GSM modem (1-port) converter detected
[ 260.838476] usb 1-6: GSM modem (1-port) converter now attached to ttyUSB0
[ 260.838511] option 1-6:1.1: GSM modem (1-port) converter detected
[ 260.838583] usb 1-6: GSM modem (1-port) converter now attached to ttyUSB1


YOU ARE THE MAN!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

THANK YOU SO MUCH!!!!!!!!!!!!!!!!!!!

just one more thing... can you help me to add this as an udev rule... so it does automatically... and to add this to some script to modprobe option when booting???

again... thank you soooooooooo much!!!!!!!!!!

ill post this everywhere!!!!!!!!!!!!!! :D :D :D

Josh
Site Admin
Posts: 6570
Joined: 03 Nov 2007, 00:30

Post by Josh » 21 Feb 2010, 10:13

If you want your name in the usb_modeswitch.conf file (as contributor), mail or PM it to me.

I will do a new data release around noon (local, GMT+1) where your device is added to rules and configuration. You need the newest usb_modeswitch version (1.1.0) though; Debian provides it in "sid" if you don't have it already. With this, everything - including driver loading - will work automatically.


pilchat
Posts: 10
Joined: 20 Jan 2011, 20:10

Post by pilchat » 20 Jan 2011, 20:25

Dear Josh,

I have almost the same problem with my Huawei V725 (aka Vodafone 725, it's a mobile phone).

I used to switch it in my Ubuntu 9.04 using the following script:

--------------------------------------------------------------
#!/bin/bash
usb_modeswitch -v 12d1 -p 1009 -d 1

sleep 20

usb_modeswitch -v 12d1 -p 1009 -H 1

sleep 20

modprobe usbserial

lsstring=$(ls /dev/ttyUSB*)

if [ "$lsstring" != '' ]
then
wvdial -C /etc/wvdial.conf.3.cell
fi

exit 0
--------------------------------------------------------------

It was usb-modeswitch 1.0.2-1, and everything worked fairly well.

Now I'm running Ubuntu Lucyd and usb-modeswitch 1.1.0-2. If I try just the first usb_modeswitch call, my phone seems to be detached, but soon after it is re-attached exactly the same way as the first time:

--------------------------------------------------------------
Jan 20 19:23:51 hon kernel: [ 9665.968182] usb 2-1: USB disconnect, address 22
Jan 20 19:24:04 hon kernel: [ 9678.360151] usb 2-1: new full speed USB device using uhci_hcd and address 23
Jan 20 19:24:04 hon kernel: [ 9678.518189] usb 2-1: configuration #1 chosen from 1 choice
Jan 20 19:24:04 hon kernel: [ 9678.520693] scsi26 : SCSI emulation for USB Mass Storage devices
Jan 20 19:24:09 hon kernel: [ 9683.524903] scsi 26:0:0:0: CD-ROM VODAFONE Mass Storage 2.31 PQ: 0 ANSI: 2
Jan 20 19:24:09 hon kernel: [ 9683.557875] sr0: scsi-1 drive
Jan 20 19:24:09 hon kernel: [ 9683.562542] sr 26:0:0:0: Attached scsi generic sg2 type 5
Jan 20 19:24:12 hon kernel: [ 9686.303957] sr: Sense Key : Hardware Error [current]
Jan 20 19:24:12 hon kernel: [ 9686.303973] sr: Add. Sense: No additional sense information
Jan 20 19:24:12 hon kernel: [ 9686.397981] sr: Sense Key : Hardware Error [current]
Jan 20 19:24:12 hon kernel: [ 9686.397998] sr: Add. Sense: No additional sense information
Jan 20 19:24:12 hon kernel: [ 9686.516936] sr: Sense Key : Hardware Error [current]
Jan 20 19:24:12 hon kernel: [ 9686.516953] sr: Add. Sense: No additional sense information
Jan 20 19:24:12 hon kernel: [ 9686.656980] sr: Sense Key : Hardware Error [current]
Jan 20 19:24:12 hon kernel: [ 9686.656996] sr: Add. Sense: No additional sense information
--------------------------------------------------------------

Moreover, "lsusb -v" keeps saying that the device is "Mass storage". I also tried some of the commands I found in the previous posts, without success.

I am not a master of usb-modeswitch, so I beg you to help me. I don't want to switch to windows everytime I need to connect to the internet using my phone as a modem.

Josh
Site Admin
Posts: 6570
Joined: 03 Nov 2007, 00:30

Post by Josh » 20 Jan 2011, 23:05

The CDROM errors you are seeing are caused by changes in the kernel; the usb-storage driver adheres a bit stricter to the specification now, exposing quirks in the device firmware. But usually these errors have no impact on the switching process.

Did you ever try the newer Huawei switching method described in the previous posts of this topic ?

Like this (one line, of course):

Code: Select all

usb_modeswitch -I -v 0x12d1 -p 0x1009 -M "55534243123456780600000080000601000000000000000000000000000000"

pilchat
Posts: 10
Joined: 20 Jan 2011, 20:10

Post by pilchat » 21 Jan 2011, 00:42

Thank you for your quick reply. Let's sort it out.

When I plug my phone I get these messages:

-----------------------------------------------------------------
Jan 20 23:35:58 hon kernel: [ 4901.593114] usb 2-1: new full speed USB device using uhci_hcd and address 3
Jan 20 23:35:58 hon kernel: [ 4901.754684] usb 2-1: configuration #1 chosen from 1 choice
Jan 20 23:35:58 hon kernel: [ 4901.768105] scsi9 : SCSI emulation for USB Mass Storage devices
Jan 20 23:36:03 hon kernel: [ 4906.777981] scsi 9:0:0:0: CD-ROM VODAFONE Mass Storage 2.31 PQ: 0 ANSI: 2
Jan 20 23:36:03 hon kernel: [ 4906.814972] sr0: scsi-1 drive
Jan 20 23:36:03 hon kernel: [ 4906.814983] Uniform CD-ROM driver Revision: 3.20
Jan 20 23:36:03 hon kernel: [ 4906.818644] sr 9:0:0:0: Attached scsi generic sg2 type 5
Jan 20 23:36:05 hon kernel: [ 4908.322758] sr: Sense Key : Hardware Error [current]
Jan 20 23:36:05 hon kernel: [ 4908.322766] sr: Add. Sense: No additional sense information
Jan 20 23:36:06 hon kernel: [ 4909.391283] sr: Sense Key : Hardware Error [current]
Jan 20 23:36:06 hon kernel: [ 4909.391291] sr: Add. Sense: No additional sense information
Jan 20 23:36:06 hon kernel: [ 4909.476331] sr: Sense Key : Hardware Error [current]
Jan 20 23:36:06 hon kernel: [ 4909.476340] sr: Add. Sense: No additional sense information
Jan 20 23:36:06 hon kernel: [ 4909.757484] sr: Sense Key : Hardware Error [current]
Jan 20 23:36:06 hon kernel: [ 4909.757496] sr: Add. Sense: No additional sense information
-----------------------------------------------------------------

Then, I give the command you suggest a try, getting:

-----------------------------------------------------------------
Looking for default devices ...
Found default devices (1)
Accessing device 003 on bus 002 ...

USB description data (for identification)
-------------------------
Manufacturer: VODAFONE Technologies
Product: VODAFONE Mobile
Serial No.: not provided
-------------------------
Looking for active driver ...
OK, driver found ("usb-storage")
OK, driver "usb-storage" detached
Setting up communication with interface 0 ...
Trying to send the message to endpoint 0x04 ...
OK, message successfully sent
-> Run lsusb to note any changes. Bye.
----------------------------------------------------------------------

Soon after, I get these kernel messages:
----------------------------------------------------------------------
Jan 20 23:39:38 hon kernel: [ 5121.865273] usb 2-1: USB disconnect, address 3
Jan 20 23:39:39 hon kernel: [ 5123.132151] usb 2-1: new full speed USB device using uhci_hcd and address 4
Jan 20 23:39:40 hon kernel: [ 5123.290530] usb 2-1: configuration #1 chosen from 1 choice
Jan 20 23:39:40 hon kernel: [ 5123.298428] scsi10 : SCSI emulation for USB Mass Storage devices
Jan 20 23:39:45 hon kernel: [ 5128.301132] scsi 10:0:0:0: CD-ROM VODAFONE Mass Storage 2.31 PQ: 0 ANSI: 2
Jan 20 23:39:45 hon kernel: [ 5128.332728] sr0: scsi-1 drive
Jan 20 23:39:45 hon kernel: [ 5128.333501] sr 10:0:0:0: Attached scsi generic sg2 type 5
Jan 20 23:39:47 hon kernel: [ 5130.335796] sr: Sense Key : Hardware Error [current]
Jan 20 23:39:47 hon kernel: [ 5130.335812] sr: Add. Sense: No additional sense information
Jan 20 23:39:48 hon kernel: [ 5131.365306] sr: Sense Key : Hardware Error [current]
Jan 20 23:39:48 hon kernel: [ 5131.365322] sr: Add. Sense: No additional sense information
Jan 20 23:39:48 hon kernel: [ 5131.457343] sr: Sense Key : Hardware Error [current]
Jan 20 23:39:48 hon kernel: [ 5131.457360] sr: Add. Sense: No additional sense information
Jan 20 23:39:48 hon kernel: [ 5131.618420] sr: Sense Key : Hardware Error [current]
Jan 20 23:39:48 hon kernel: [ 5131.618437] sr: Add. Sense: No additional sense information
---------------------------------------------------------------------------------------------------------

I don't find any difference with respect to the first plug....

Any suggestion?

Josh
Site Admin
Posts: 6570
Joined: 03 Nov 2007, 00:30

Post by Josh » 21 Jan 2011, 11:13

Hmm, maybe the code from the other Huawei phone works ? Try this behind the -M parameter:

Code: Select all

"55534243123456780600000080010a11060000000000000000000000000000"
Or this from the latest Huawei sticks:

Code: Select all

"55534243123456780000000000000011062000000100000000000000000000" 
After each attempt, check if the USB ID has changed with "lsusb".


pilchat
Posts: 10
Joined: 20 Jan 2011, 20:10

Post by pilchat » 21 Jan 2011, 12:14

Nope, it doesn't change. It's stuck at:

"Bus 002 Device 004: ID 12d1:1009 Huawei Technologies Co., Ltd. U120"

Any other idea?

Josh
Site Admin
Posts: 6570
Joined: 03 Nov 2007, 00:30

Post by Josh » 21 Jan 2011, 15:16

No other idea except going through the whole sniffing process to see what the Windows driver is doing.

pilchat
Posts: 10
Joined: 20 Jan 2011, 20:10

Post by pilchat » 21 Jan 2011, 15:31

Sorry, but I am not a windows user. What does it mean?

Josh
Site Admin
Posts: 6570
Joined: 03 Nov 2007, 00:30

Post by Josh » 21 Jan 2011, 18:42

See the main documentation page, paragraph "Contribute".

pilchat
Posts: 10
Joined: 20 Jan 2011, 20:10

Post by pilchat » 21 Jan 2011, 19:21

Thanks! I used Mark's guideline and I sent you an e-mail with the log (it's a long file).

Let me know if you don't receive my email.

Thanks!

Josh
Site Admin
Posts: 6570
Joined: 03 Nov 2007, 00:30

Post by Josh » 21 Jan 2011, 20:29

I got your mail.

Some remarks about that:
It would have been more polite to ask before sending such a big file. But even if sending it without asking for permission, the least you could do is to compress the files with ZIP or GZIP or whatever. That reduces the file size of a large text file to 10% of the original.
Also, BMP is the image format taking the most space of all possible. Consider using PNG or GIF for screenshots. Indexing your picture and saving it as PNG results in a file of 20 kB. Your BMP has 1800 kB.

My bandwith and volume is limited.

Now to the log file:
You managed to capture the moment of switching which is all that counts. Look at [292 ms], that is a control transfer very close to the moment where the device is "removed" at [3448 ms].

The control transfer is the old Huawei mode-switching command issued with the -H parameter, just what you did all the time. We know that for sure now. There must be other reasons why things are not working right.

The next things to check for is the timing and the kernel version. Regarding the latter, there are some kernels around 2.6.31 which make Huawei devices reset because of that "sense error" you are getting. If you have a kernel of that series, try to update, at least above 2.6.31.5, better to a 2.6.32 version.

If that does not help or apply then we will look at the timing more closely.


Post Reply