Automatic Activation, Hotplug and UDEV, Configuration
Post Reply
holck
Posts: 7
Joined: 29 Apr 2010, 10:32

usb_modeswitch running, but not working automatically

Post by holck » 01 May 2010, 12:13

I have tried to follow all the instructions I have found here, and I'm very please that usb_modeswitch has made it possible for me to use my Huawei modem on my small eee 901. But I have not been able to make it work automagically - I have to run usb_modeswitch "by hand".

When I plug-in the modem, usb_modeswitch seems to run - here is a snippet from /var/log/messages

Code: Select all

May  1 11:48:34 jespers-eee kernel: [ 2151.240216] usb 1-2: new high speed USB device using ehci_hcd and address 5
May  1 11:48:34 jespers-eee kernel: [ 2151.375141] usb 1-2: configuration #1 chosen from 1 choice
May  1 11:48:34 jespers-eee kernel: [ 2151.386671] scsi3 : SCSI emulation for USB Mass Storage devices
May  1 11:48:34 jespers-eee kernel: [ 2151.388252] scsi4 : SCSI emulation for USB Mass Storage devices
May  1 11:48:36 jespers-eee usb_modeswitch: switching 12d1:1446 (HUAWEI Technology: HUAWEI Mobile)
May  1 11:48:39 jespers-eee kernel: [ 2156.389784] scsi 4:0:0:0: Direct-Access     HUAWEI   SD Storage       2.31 PQ: 0 ANSI: 2
May  1 11:48:39 jespers-eee kernel: [ 2156.392140] sd 4:0:0:0: Attached scsi generic sg3 type 0
May  1 11:48:39 jespers-eee kernel: [ 2156.403324] sd 4:0:0:0: [sdd] Attached SCSI removable disk
But unfortunately, the modem never shows up in the NetworkManager Applet.

If I then unplug and replug the modem, and runs

Code: Select all

sudo mode_switch
it works, here again a copy from /var/log/messages

Code: Select all

May  1 11:54:54 jespers-eee kernel: [ 2531.444235] usb 1-2: new high speed USB device using ehci_hcd and address 7
May  1 11:54:54 jespers-eee kernel: [ 2531.579198] usb 1-2: configuration #1 chosen from 1 choice
May  1 11:54:54 jespers-eee kernel: [ 2531.589314] scsi10 : SCSI emulation for USB Mass Storage devices
May  1 11:54:54 jespers-eee kernel: [ 2531.590908] scsi11 : SCSI emulation for USB Mass Storage devices
May  1 11:54:56 jespers-eee usb_modeswitch: switching 12d1:1446 (HUAWEI Technology: HUAWEI Mobile)
May  1 11:54:59 jespers-eee kernel: [ 2536.589910] scsi 11:0:0:0: Direct-Access     HUAWEI   SD Storage       2.31 PQ: 0 ANSI: 2
May  1 11:54:59 jespers-eee kernel: [ 2536.591650] sd 11:0:0:0: Attached scsi generic sg3 type 0
May  1 11:54:59 jespers-eee kernel: [ 2536.602649] sd 11:0:0:0: [sdd] Attached SCSI removable disk
May  1 11:54:59 jespers-eee kernel: [ 2536.603051] usb 1-2: usbfs: process 2281 (usb_modeswitch) did not claim interface 0 before use
May  1 11:54:59 jespers-eee kernel: [ 2536.609550] usb 1-2: USB disconnect, address 7
May  1 11:55:04 jespers-eee kernel: [ 2541.460212] usb 1-2: new high speed USB device using ehci_hcd and address 8
May  1 11:55:04 jespers-eee kernel: [ 2541.595069] usb 1-2: configuration #1 chosen from 1 choice
May  1 11:55:04 jespers-eee kernel: [ 2541.642072] usbcore: registered new interface driver usbserial
May  1 11:55:04 jespers-eee kernel: [ 2541.642163] USB Serial support registered for generic
May  1 11:55:04 jespers-eee kernel: [ 2541.644020] scsi15 : SCSI emulation for USB Mass Storage devices
May  1 11:55:05 jespers-eee kernel: [ 2541.651613] scsi16 : SCSI emulation for USB Mass Storage devices
May  1 11:55:05 jespers-eee kernel: [ 2541.654392] usbcore: registered new interface driver usbserial_generic
May  1 11:55:05 jespers-eee kernel: [ 2541.654398] usbserial: USB Serial Driver core
May  1 11:55:05 jespers-eee kernel: [ 2541.658927] USB Serial support registered for GSM modem (1-port)
May  1 11:55:05 jespers-eee kernel: [ 2541.659121] option 1-2:1.0: GSM modem (1-port) converter detected
May  1 11:55:05 jespers-eee kernel: [ 2541.659383] usb 1-2: GSM modem (1-port) converter now attached to ttyUSB0
May  1 11:55:05 jespers-eee kernel: [ 2541.659419] option 1-2:1.1: GSM modem (1-port) converter detected
May  1 11:55:05 jespers-eee kernel: [ 2541.659592] usb 1-2: GSM modem (1-port) converter now attached to ttyUSB1
May  1 11:55:05 jespers-eee kernel: [ 2541.659627] option 1-2:1.2: GSM modem (1-port) converter detected
May  1 11:55:05 jespers-eee kernel: [ 2541.659820] usb 1-2: GSM modem (1-port) converter now attached to ttyUSB2
May  1 11:55:05 jespers-eee kernel: [ 2541.659902] usbcore: registered new interface driver option
May  1 11:55:05 jespers-eee kernel: [ 2541.659909] option: v0.7.2:USB Driver for GSM modems
May  1 11:55:06 jespers-eee usb_modeswitch: switched to 12d1:1001 (HUAWEI Technology: HUAWEI Mobile)
May  1 11:55:09 jespers-eee kernel: [ 2546.650449] scsi 15:0:0:0: CD-ROM            HUAWEI   Mass Storage     2.31 PQ: 0 ANSI: 2
May  1 11:55:10 jespers-eee kernel: [ 2546.660056] scsi 16:0:0:0: Direct-Access     HUAWEI   SD Storage       2.31 PQ: 0 ANSI: 2
May  1 11:55:10 jespers-eee kernel: [ 2546.674308] sr0: scsi-1 drive
May  1 11:55:10 jespers-eee kernel: [ 2546.674793] sr 15:0:0:0: Attached scsi generic sg3 type 5
May  1 11:55:10 jespers-eee kernel: [ 2546.675168] sd 16:0:0:0: Attached scsi generic sg4 type 0
May  1 11:55:10 jespers-eee kernel: [ 2546.697153] sd 16:0:0:0: [sdd] Attached SCSI removable disk
Any help appreciated - and I will of course be happy to supply more information.

Thanks,
Jesper, Denmark[/code]

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

Post by Josh » 01 May 2010, 15:15

Please enable logging as described on the main doc page ("Troubleshooting"). Then try plugging again - but be sure to give it some time. These Huaweis need a while to appear as a valid storage device to begin with and then at least five seconds until they are back as a modem device.

"sudo usb_modeswitch" should not do anything except complaining if there is no "/etc/usb_modeswitch.setup" ...

Are you running 1.1.2 ?


holck
Posts: 7
Joined: 29 Apr 2010, 10:32

Post by holck » 01 May 2010, 18:45

I have now upgraded to version 1.1.2, but unfortunately the problem seems to remain the same.

As suggested, enabling logging produces a lengthy log file that I hesitate to post here in total - I will bring what I guess are the some of the most interesting parts:

Code: Select all

USB_ModeSwitch log from Sat May 01 18:25:54 CEST 2010

Using global config file: /etc/usb_modeswitch.conf
raw args from udev: 1-2/1-2:1.0
USB dir exists: /sys/bus/usb/devices/1-2
Warning: USB attribute "serial" not found.
----------------
USB values from sysfs:
  manufacturer  HUAWEI Technology
  product       HUAWEI Mobile
  serial        
----------------
SCSI attributes not needed, moving on
checking config: /etc/usb_modeswitch.d/12d1:1446
! matched, now switching
 (running command: /usr/sbin/usb_modeswitch -I -W -c /etc/usb_modeswitch.d/12d1:1446)
..................
USB error: could not get bound driver: No data available
Reading config file: /etc/usb_modeswitch.d/12d1:1446

 * usb-modeswitch: handle USB devices with multiple modes
 * Version 1.1.2alpha (C) Josua Dietze 2010
 * Based on libusb0 (0.1.12 and above)
..................
Accessing device 005 on bus 001 ...

USB description data (for identification)
-------------------------
Manufacturer: HUAWEI Technology
     Product: HUAWEI Mobile
  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 ...
Check that you have permissions to write to 001/005 and, if you don't, that you set up hotplug (http://linux-hotplug.sourceforge.net/) correctly.
USB error: could not claim interface 0: Device or resource busy
..........................
 No new devices in target mode or class found

Mode switch has failed. Bye.

fail:
--------------------------------
(end of usb_modeswitch output)


All done, exiting

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

Post by Josh » 02 May 2010, 01:44

Hmm, would be better to see the whole thing. You could post it at "pastebin.com" if you like.

holck
Posts: 7
Joined: 29 Apr 2010, 10:32

Post by holck » 02 May 2010, 09:31

Fine, you can get the log-file here:
http://di-vers.dyndns.org/usb_modeswitch_1-2:1.0

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

Post by Josh » 02 May 2010, 12:16

O.K., there seems to be a problem with the USB subsystem. Would you mind to provide one more puzzle piece?

I'd like to see the output of "lsusb -v -d 12d1:1446", with automatic switching globally disabled (edit /etc/usb_modeswitch.conf again) and a freshly plugged stick.


holck
Posts: 7
Joined: 29 Apr 2010, 10:32

Post by holck » 02 May 2010, 18:25

Fine - it is here:

Code: Select all

$ lsusb -v -d 12d1:1446

Bus 001 Device 005: ID 12d1:1446 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          0x1446 
  bcdDevice            0.00
  iManufacturer           3 
  iProduct                2 
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           55
    bNumInterfaces          2
    bConfigurationValue     1
    iConfiguration          1 
    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     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
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        1
      bAlternateSetting       0
      bNumEndpoints           2
      bInterfaceClass         8 Mass Storage
      bInterfaceSubClass      6 SCSI
      bInterfaceProtocol     80 Bulk (Zip)
      iInterface              0 
      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               0
      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               0
can't get device qualifier: Operation not permitted
can't get debug descriptor: Operation not permitted
cannot read device status, Operation not permitted (1)

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

Post by Josh » 02 May 2010, 19:46

Note that you have to run lsusb as well as usb_modeswitch with root/superuser rights. The log points to permission problems too.

Unfortunately, I don't know the system on the EEE. But you can run annother test.

Change to root mode ("sudo bash") and run the following, with a freshly plugged stick, automatic switch still disabled and logging enabled:

Code: Select all

# /lib/udev/usb_modeswitch 1-2/1-2:1.0
The question is if the suspicious line in the log will go away:
"Check that you have permissions to write to 001/005".


holck
Posts: 7
Joined: 29 Apr 2010, 10:32

Post by holck » 02 May 2010, 20:23

The line indeed disappeared:

Code: Select all

USB_ModeSwitch log from Sun May 02 20:18:14 CEST 2010

Using global config file: /etc/usb_modeswitch.conf
raw args from udev: 1-2/1-2:1.0
USB dir exists: /sys/bus/usb/devices/1-2
Warning: USB attribute "serial" not found.
----------------
USB values from sysfs:
  manufacturer  HUAWEI Technology
  product       HUAWEI Mobile
  serial        
----------------

Switching globally disabled. Exiting

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

Post by Josh » 03 May 2010, 00:21

Oops, my fault. Keep switching disabled when plugging in, but then enable before running the posted command ...

holck
Posts: 7
Joined: 29 Apr 2010, 10:32

Post by holck » 03 May 2010, 09:09

Fine, here is the new log:
http://di-vers.dyndns.org/usblog2

And now the connection does appear in the NetworkManager Applet

As far as I know, I'm running a pretty ordinary Ubuntu Karmic Koala

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

Post by Josh » 03 May 2010, 20:13

That supports my theory about insufficient rights for usb_modeswitch in the automatic mode.

Unfortunately, I can't give you many hints for fixing this; I don't have or know that system, I'm testing mostly on the current distribution releases.

The udev daemon should run everything with root rights (including itself). You could experiment with "sudo" in a script, or changing the group that "udevd" runs under. Maybe someone from the Ubuntu community can help you in any way.

Or you delete the "40-usb_modeswitch.rules" file in /lib/udev/rules.d and switch manually with the command that worked.


holck
Posts: 7
Joined: 29 Apr 2010, 10:32

Post by holck » 03 May 2010, 22:31

I found a way to make it work - I think!

In the file /lib/udev/rules.d/61-option-modem-modeswitch.rules, installed by the udev package, there is also a rule for my Huawei modem:

Code: Select all

ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="1446", RUN+="modem-modeswitch -v 0x%s{idVendor} -p 0x%s{idProduct} -t option-zerocd"
.
If I comment out this rule, everything seems to work :-)

Jesper,
Denmark

Post Reply