Automatic Activation, Hotplug and UDEV, Configuration
pilchat
Posts: 10
Joined: 20 Jan 2011, 20:10

Post by pilchat » 21 Jan 2011, 21:46

Oops, I am very sorry. :oops: I didn't even notice that they were that large!

By the way, I have the kernel 2.6.32-27-generic, nonetheless I get the error messages.

What do you mean by "look at the time more closely"?

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

Post by Josh » 23 Jan 2011, 01:49

What I mean is that it would probably help to activate the switching right upon plug-in, before the storage subsystem has a chance to kick in.

For this, it would be advised to prepare everything for an automatic switching. That means creating a config file and and adding an udev rule to "/lib/udev/rules.d/40-usb_modeswitch.rules".

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

Post by pilchat » 23 Jan 2011, 10:58

Ok, it makes a lot of sense. What should I do?

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

Post by Josh » 23 Jan 2011, 11:24

You can easily work with an existing config file in "/etc/usb_modeswitch.d".
Copy the file "12d1:1001" to "12d1:1009", then edit the new file and change the "DefaultProduct" value accordingly.

Next, edit the file "/lib/udev/rules.d/40-usb_modeswitch.rules" and add a line for your device. Have a look at all the other lines, it's very straightforward to do.


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

Post by pilchat » 20 Feb 2011, 12:12

Dear Josh,

I've just tried to edit those files, I restarted my system and then I plugged my mobile phone. Still I get the same errors:

Feb 20 11:09:41 hon kernel: [ 643.084188] usb 2-2: new full speed USB device using uhci_hcd and address 4
Feb 20 11:09:42 hon kernel: [ 643.246633] usb 2-2: configuration #1 chosen from 1 choice
Feb 20 11:09:42 hon kernel: [ 643.258314] scsi7 : SCSI emulation for USB Mass Storage devices
Feb 20 11:09:42 hon usb-modeswitch: switching 12d1:1009 (VODAFONE Technologies: VODAFONE Mobile)
Feb 20 11:09:42 hon kernel: [ 643.976210] usb 2-2: USB disconnect, address 4
Feb 20 11:09:44 hon kernel: [ 645.456175] usb 2-2: new full speed USB device using uhci_hcd and address 5
Feb 20 11:09:44 hon kernel: [ 645.617388] usb 2-2: configuration #1 chosen from 1 choice
Feb 20 11:09:44 hon kernel: [ 645.625322] scsi8 : SCSI emulation for USB Mass Storage devices
Feb 20 11:09:49 hon kernel: [ 650.628642] scsi 8:0:0:0: CD-ROM VODAFONE Mass Storage 2.31 PQ: 0 ANSI: 2
Feb 20 11:09:49 hon kernel: [ 650.662595] sr0: scsi-1 drive
Feb 20 11:09:49 hon kernel: [ 650.668036] sr 8:0:0:0: Attached scsi generic sg2 type 5
Feb 20 11:09:52 hon kernel: [ 653.307323] sr: Sense Key : Hardware Error [current]
Feb 20 11:09:52 hon kernel: [ 653.307339] sr: Add. Sense: No additional sense information
Feb 20 11:09:52 hon kernel: [ 653.415290] sr: Sense Key : Hardware Error [current]
Feb 20 11:09:52 hon kernel: [ 653.415306] sr: Add. Sense: No additional sense information
Feb 20 11:09:52 hon kernel: [ 653.494200] sr: Sense Key : Hardware Error [current]
Feb 20 11:09:52 hon kernel: [ 653.494216] sr: Add. Sense: No additional sense information
Feb 20 11:09:52 hon kernel: [ 653.672118] sr: Sense Key : Hardware Error [current]
Feb 20 11:09:52 hon kernel: [ 653.672140] sr: Add. Sense: No additional sense information

I assumed that it should have been now mounted as a USB modem without any additional commands, therefore I haven't tried to switch it manually.

Is it right?

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

Post by Josh » 20 Feb 2011, 22:01

Apart from the errors, what does "lsusb" say ? Any changes in the ID ?

And what about "lsusb -v" - did the interfaces change in any way ?

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

Post by pilchat » 24 Feb 2011, 11:53

Actually, something changes!

Before editing the files discussed two posts ago, lsusb -v gives:

Code: Select all

Bus 002 Device 003: ID 12d1:1009 Huawei Technologies Co., Ltd. U120
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x12d1 Huawei Technologies Co., Ltd.
  idProduct          0x1009 U120
  bcdDevice            0.00
  iManufacturer           1 
  iProduct                2 
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           32
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xa0
      (Bus 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     0x83  EP 3 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x04  EP 4 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval 
After, I obtain:

Code: Select all

Bus 002 Device 005: ID 12d1:1009 Huawei Technologies Co., Ltd. U120
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               1.10
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x12d1 Huawei Technologies Co., Ltd.
  idProduct          0x1009 U120
  bcdDevice            0.00
  iManufacturer           1 
  iProduct                2 
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           85
    bNumInterfaces          3
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0xa0
      (Bus 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              3 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            3
          Transfer Type            Interrupt
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0010  1x 16 bytes
        bInterval             128
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x02  EP 2 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
    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              3 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x85  EP 5 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x05  EP 5 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
    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     0x83  EP 3 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x04  EP 4 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0040  1x 64 bytes
        bInterval               0
This is what I added in 40-usb_modeswitch.rules (before ' LABEL="modeswitch_rules_end" '):

ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="1009", RUN+="usb_modeswitch '%b/%k'"

Any ideas?

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

Post by Josh » 24 Feb 2011, 21:16

Ahaaa - same ID but different interfaces after switching. Unusual for a Huawei device, but not unusual overall.

So your "12d1:1009" config file should look like this [edited, correction]:

Code: Select all

DefaultVendor= 0x12d1
DefaultProduct=0x1009

TargetClass=0xff

HuaweiMode=1

CheckSuccess=20
Or as a command line:

Code: Select all

usb_modeswitch -v 0x12d1 -p 0x1009 -C 0xff -H

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

Post by Josh » 24 Feb 2011, 21:40

Switching works, now the driver has to be loaded.

You will reliably get serial ports automatically if you use program version 1.1.6

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

Post by pilchat » 07 Mar 2011, 18:21

Holy crap!!! It works!!!

This is what I did. I purged the previous installation of usb-modeswitch and the data package, so to refresh the configuration files I edited some time ago. Then, I manually compiled the 1.1.7 version of usb-modeswitch. I noticed that there is a rule for my Huawei V725.

When I plug in my mobile I get:

Mar 7 17:17:10 hon kernel: [ 4138.537223] usb 2-1: new full speed USB device using uhci_hcd and address 5
Mar 7 17:17:10 hon kernel: [ 4138.699900] usb 2-1: configuration #1 chosen from 1 choice
Mar 7 17:17:10 hon kernel: [ 4138.702394] scsi7 : SCSI emulation for USB Mass Storage devices
Mar 7 17:17:11 hon usb_modeswitch: switching 12d1:1009 (VODAFONE Technologies: VODAFONE Mobile)
Mar 7 17:17:11 hon kernel: [ 4139.539709] usb 2-1: USB disconnect, address 5
Mar 7 17:17:13 hon kernel: [ 4141.020130] usb 2-1: new full speed USB device using uhci_hcd and address 6
Mar 7 17:17:13 hon kernel: [ 4141.175942] usb 2-1: configuration #1 chosen from 1 choice
Mar 7 17:17:13 hon kernel: [ 4141.182824] option 2-1:1.0: GSM modem (1-port) converter detected
Mar 7 17:17:13 hon kernel: [ 4141.183276] usb 2-1: GSM modem (1-port) converter now attached to ttyUSB0
Mar 7 17:17:13 hon kernel: [ 4141.187330] option 2-1:1.1: GSM modem (1-port) converter detected
Mar 7 17:17:13 hon kernel: [ 4141.188135] usb 2-1: GSM modem (1-port) converter now attached to ttyUSB1
Mar 7 17:17:13 hon kernel: [ 4141.188804] scsi8 : SCSI emulation for USB Mass Storage devices
Mar 7 17:17:13 hon usb_modeswitch: switched to 12d1:1009 (VODAFONE Technologies: VODAFONE Mobile)
Mar 7 17:17:18 hon kernel: [ 4146.192822] scsi 8:0:0:0: CD-ROM VODAFONE Mass Storage 2.31 PQ: 0 ANSI: 2
Mar 7 17:17:18 hon kernel: [ 4146.229605] sr0: scsi-1 drive
Mar 7 17:17:18 hon kernel: [ 4146.230619] sr 8:0:0:0: Attached scsi generic sg2 type 5
Mar 7 17:17:20 hon kernel: [ 4148.065653] sr: Sense Key : Hardware Error [current]
Mar 7 17:17:20 hon kernel: [ 4148.065668] sr: Add. Sense: No additional sense information
Mar 7 17:17:21 hon kernel: [ 4149.104686] sr: Sense Key : Hardware Error [current]
Mar 7 17:17:21 hon kernel: [ 4149.104702] sr: Add. Sense: No additional sense information
Mar 7 17:17:21 hon kernel: [ 4149.193684] sr: Sense Key : Hardware Error [current]
Mar 7 17:17:21 hon kernel: [ 4149.193706] sr: Add. Sense: No additional sense information
Mar 7 17:17:21 hon kernel: [ 4149.368738] sr: Sense Key : Hardware Error [current]
Mar 7 17:17:21 hon kernel: [ 4149.368760] sr: Add. Sense: No additional sense information

D'you see? There is something about a GPRS modem. Also, I find the devices /dev/ttyUSB0 and /dev/ttyUSB1.

Finally, without any call to usb_modeswitch, I run wvdial and I am connected! Thank you so much!!!!

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

Post by Josh » 22 Mar 2011, 23:07

That's how it is supposed to work - fully automatic ...

Post Reply