Automatic Activation, Hotplug and UDEV, Configuration
Post Reply
kristrev_1
Posts: 5
Joined: 30 Nov 2012, 19:05

Mode is not switched when modem is connected through hub

Post by kristrev_1 » 30 Nov 2012, 19:13

Hello,

I am running usb_modeswitch 1.2.5 (compiled from source) on a machine with Ubuntu 12.04. When I connect one of my 3G modems through my hub, usb_modeswitch is not able to switch the mode. The log file says that the Device is not in install mode. The full log file is available here: https://gist.github.com/4177083. The modems I have tried with are Huawei E173, E3131 and E353. My hub is a D-Link H7, which is registered as two Gensys Logic 4 port hubs (05e3:0610). I also see the same behavior with other hubs (for example my Dell screen). Also, there are multiple devices (four) with same IDs attached, and some are switched correctly.

When I connect the modem directly to one of the USB ports on my motherboard, everything works as intended. Has anyone experienced this and have any tips for solving it?

Thanks in advance for any help,
Kristian
Last edited by kristrev_1 on 30 Nov 2012, 23:44, edited 1 time in total.

kristrev_1
Posts: 5
Joined: 30 Nov 2012, 19:05

Re: Mode is not switched when modem is connected through hub

Post by kristrev_1 » 30 Nov 2012, 23:28

I spent some more time looking into this. One interesting observation is that switching the modem manually work. In order to get it working, I ran the following two commands:

echo "12d1 1506" > /sys/bus/usb-serial/drivers/option1/new_id
usb_modeswitch -v 12d1 -p 14fe -V 12d1 -P 1506 -c /usr/share/usb_modeswitch/12d1\:14fe

There are four devices connected to the machine with the same vendor and product ID, if that matters.

-Kristian

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

Re: Mode is not switched when modem is connected through hub

Post by Josh » 01 Dec 2012, 10:41

Yes, it may well be that cascaded hubs are not evaluated correctly by usb_modeswitch.

I will look into it and release a bug fix.

kristrev_1
Posts: 5
Joined: 30 Nov 2012, 19:05

Re: Mode is not switched when modem is connected through hub

Post by kristrev_1 » 01 Dec 2012, 12:14

Thank you! Let me know if there is anything I can do to help out.

The machine is running the 3.5-kernel (3.5.0-19 according to Ubuntu's versioning system), and, as a last attempt yesterday, I uninstalled usb_modeswitch and usb_modeswitch_data (both packages and from source). When rebooting the machine now, the modems are always immediately seen with their correct IDs and serial devices. I.e., it seems like no switch is required. However, the modems seem to be much more unstable than when usb_modeswitch was used.

I have installed Ubuntu minimal, so there is no automatic tool like modem-manager causing a conflict.

-Kristian

kristrev_1
Posts: 5
Joined: 30 Nov 2012, 19:05

Re: Mode is not switched when modem is connected through hub

Post by kristrev_1 » 01 Dec 2012, 16:14

After spending some more time thinking and trying, I suspect my second observation (that removing modeswitch "solved" the problem) was related to the fact that the modems have had power all the time. After physically disconnecting and connecting the modems, they are not recognized and modeswitch produces the same error logs.

-Kristian

kristrev_1
Posts: 5
Joined: 30 Nov 2012, 19:05

Re: Mode is not switched when modem is connected through hub

Post by kristrev_1 » 03 Dec 2012, 10:55

You were right when you mentioned that usb_modeswitch might not handle cascaded usb hubs correctly. The regex in line 101 of dispatcher (version 1.2.5) is too narrow in scope and removes required parts of the sysfs-path.

I am not familiar enough with sysfs and the behavior of USB devices to suggest a generic fix. However, as a temporary fix, I use the raw path from udev (argList[1]) as dev_top. For me, this works with devices connected directly to the motherboard, as well as with different numbers of cascaded hubs (tested with up to four). I have attached a patch, if anyone is interested in trying.
Attachments
usb_cascade_tmp_fix.patch
(1.17 KiB) Downloaded 611 times

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

Re: Mode is not switched when modem is connected through hub

Post by Josh » 03 Dec 2012, 23:55

Thank you for the patch which saves me some bug-hunting!

The part that you skipped is intended as a compatibility switch to handle both old and new data packages. The way the udev rules file works has changed with the latest release; the check for a storage class device on interface 0 is now done inside the script.

Anyway, I will just extend the regular expression to allow an infinite number of hub cascades ... 8)

ncarrier
Posts: 36
Joined: 02 Nov 2011, 18:05

Re: Mode is not switched when modem is connected through hub

Post by ncarrier » 04 Dec 2012, 09:43

For information, I posted the same patch for a similar issue here two weeks ago...

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

Re: Mode is not switched when modem is connected through hub

Post by Josh » 04 Dec 2012, 15:01

Nicolas, unfortunately I could not look closely at all your patches and notifications yet.
I was gone dancing with Android for a while ...

Anyway, thanks for all these and I will consider them for inclusion in the next release.

About the changes to the "rules" file:

These were necessary to be prepared for the coming generation of MBIM devices:
http://www.usb.org/press/USB-IF_Press_R ... _Final.pdf

Here is the corresponding topic:
http://www.draisberghof.de/usb_modeswit ... f=1&t=1025

int_19h
Posts: 2
Joined: 16 Aug 2013, 12:01

Re: Mode is not switched when modem is connected through hub

Post by int_19h » 16 Aug 2013, 13:02

Hello, Josh!
Firstly, I want to thank you for your great tool, which I use very long time on different devices.
Unfortunately, in my current configuration, I can confirm, "cascaded hubs bug" fix is not working for me since v1.2.6.

I've got:
Raspberry Pi Model B (256 MB)
Powered D-Link DUB-H4 USB 2.0 Hub (2A!)
Two Huawei E367 modems (12d1:1446 unswiched, 1506 - switched). These are thru D-Link Hub ports 3 and 4.
root ~ # uname -a
Linux rpi-router 3.6.11-15-ARCH+ #1 PREEMPT Wed Aug 14 17:15:38 CDT 2013 armv6l GNU/Linux
root ~ # usb_modeswitch --version
* usb_modeswitch: handle USB devices with multiple modes
* Version 1.2.7 (C) Josua Dietze 2012
* Based on libusb0 (0.1.12 and above)
root ~ # pacman -Qs usb
local/libusb-compat 0.1.5-1
Library to enable user space application programs to communicate with USB devices
local/libusbx 1.0.16-2
Library that provides generic access to USB device
local/usb_modeswitch 1.2.7-1
Activating switchable USB devices on Linux.
local/usbutils 007-1 (base)
USB Device Utilities
Here are the logs when auto-switching:
root ~ # cat /var/log/usb_modeswitch_1-1.3.3
USB_ModeSwitch log from Thu Jan 01 03:00:08 MSK 1970

Raw args from udev: 1-1.3/1-1.3.3

Using global config file: /etc/usb_modeswitch.conf
Using top device dir /sys/bus/usb/devices/1-1.3
Warning: USB attribute "manufacturer" not found
Using interface 1.0
----------------
USB values from sysfs:
manufacturer
product USB2.0 Hub
serial
----------------
bNumConfigurations is 1 - don't check for active configuration
Aargh! Config file missing for 05e3:0606! Exiting
root ~ # cat /var/log/usb_modeswitch_1-1.3.4
USB_ModeSwitch log from Thu Jan 01 03:00:08 MSK 1970

Raw args from udev: 1-1.3/1-1.3.4

Using global config file: /etc/usb_modeswitch.conf
Using top device dir /sys/bus/usb/devices/1-1.3
Warning: USB attribute "manufacturer" not found
Using interface 1.0
----------------
USB values from sysfs:
manufacturer
product USB2.0 Hub
serial
----------------
bNumConfigurations is 1 - don't check for active configuration
Aargh! Config file missing for 05e3:0606! Exiting
Manual switching works, but sadly I need to run it two times per device (4 times total). I think it is that way, because of this "unknown" driver:
root ~ # usb_modeswitch -b 1 -g 7 -v 12d1 -p 1446 -M 55534243123456780000000000000011062000000100000000000000000000 -D
Use given bus/device number: 001/007 ...
Looking for default devices ...
bus/device number matched
found matching product ID
adding device
Found device in default mode, class or configuration (1)
Getting the current device configuration ...
OK, got current device configuration (1)
Using interface number 0
Using endpoints 0x01 (out) and 0x81 (in)

USB description data (for identification)
-------------------------
Manufacturer: Huawei Technologies
Product: HUAWEI Mobile
Serial No.: not provided
-------------------------
Looking for active driver ...
OK, driver found; name unknown, limitation of libusb1
OK, driver "unkown" detached

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
Resetting message endpoint 0x01
-> Run lsusb to note any changes. Bye.
At this point, modem on port 3 (device #7 in 'lsusb') stays unswitched, then I run usb_modeswitch second time:
root ~ # usb_modeswitch -b 1 -g 7 -v 12d1 -p 1446 -M 55534243123456780000000000000011062000000100000000000000000000 -D
Use given bus/device number: 001/007 ...
Looking for default devices ...
bus/device number matched
found matching product ID
adding device
Found device in default mode, class or configuration (1)
Getting the current device configuration ...
OK, got current device configuration (1)
Using interface number 0
Using endpoints 0x01 (out) and 0x81 (in)

USB description data (for identification)
-------------------------
Manufacturer: Huawei Technologies
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 ...
OK, message successfully sent
Resetting response endpoint 0x81
Could not reset endpoint (probably harmless): -34
Resetting message endpoint 0x01
Could not reset endpoint (probably harmless): -34
-> Run lsusb to note any changes. Bye.
And only then modem on port 3 switches. Then I repeat this "double procedure" on modem on port 4 (device #8 in 'lsusb').

'lsusb' output before manual switching:
root ~ # lsusb
Bus 001 Device 008: ID 12d1:1446 Huawei Technologies Co., Ltd. E1552/E1800/E173 (HSPA modem)
Bus 001 Device 007: ID 12d1:1446 Huawei Technologies Co., Ltd. E1552/E1800/E173 (HSPA modem)
Bus 001 Device 006: ID 1058:1042 Western Digital Technologies, Inc.
Bus 001 Device 005: ID 04c5:11bc Fujitsu, Ltd
Bus 001 Device 004: ID 05e3:0606 Genesys Logic, Inc. USB 2.0 Hub / D-Link DUB-H4 USB 2.0 Hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp. LAN9500 Ethernet 10/100 Adapter / SMSC9512/9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
'lsusb' output after manual switching:
root ~ # lsusb
Bus 001 Device 010: ID 12d1:1506 Huawei Technologies Co., Ltd. E398 LTE/UMTS/GSM Modem/Networkcard
Bus 001 Device 009: ID 12d1:1506 Huawei Technologies Co., Ltd. E398 LTE/UMTS/GSM Modem/Networkcard
Bus 001 Device 006: ID 1058:1042 Western Digital Technologies, Inc.
Bus 001 Device 005: ID 04c5:11bc Fujitsu, Ltd
Bus 001 Device 004: ID 05e3:0606 Genesys Logic, Inc. USB 2.0 Hub / D-Link DUB-H4 USB 2.0 Hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp. LAN9500 Ethernet 10/100 Adapter / SMSC9512/9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Last, but not least, I should note, that before my yesterday ArchLinux upgrade I was on kernel 3.6.11-7 (If I remember correctly) and there was "cascaded hubs bug" like now, but there wasn't this "unknown" driver issue, so, manual switching worked at first run (2 modems=2 usb_modeswitch commands).

So, can you provide some advice or a little help with this? :?
In case anything you need further (like 'lsusb -v') - I would collaborate immediately!

EDIT:
Speaking of this "cascade hubs", it was quite easy to fool usb_modeswitch by simply changing one letter in /usr/lib/udev/rules.d/40-usb_modeswitch.rules:

Code: Select all

# Huawei, newer modems
ATTR{idVendor}=="12d1", ATTR{idProduct}=="1446", RUN+="usb_modeswitch '%b/%k'"
to
# Huawei, newer modems
ATTR{idVendor}=="12d1", ATTR{idProduct}=="1446", RUN+="usb_modeswitch '%k/%k'"
Udev rules and down-layer scripts started to work as expected, however further experiments revealed that it is something not right with new ArchLinux usb subsystem or serial driver or storage driver.
The problem is of some worst case random nature. For now I speaking switching my two modems on boot.
Modems stayed unswitched at almost all power-ons, until I blacklisted cd-rom driver:

Code: Select all

root ~ # cat /etc/modprobe.d/blacklist-sr_mod.conf
blacklist sr_mod
Then, sometimes it started to perform good, sometimes modems stayed unswitched, sometimes only one (random) modem switched.
It works good in 80% of power-ons with removed HDDs from hub. With one self-powered HDD left in hub - it works in 20%.
And, respectivly, when modem switches, then kernel is saying, that it have found ttyUSBs:

Code: Select all

Jan  1 03:00:11 rpi-router usb_modeswitch: switching device 12d1:1446 on 001/005
Jan  1 03:00:11 rpi-router usb_modeswitch: switching device 12d1:1446 on 001/006
Jan  1 03:00:11 rpi-router usb_modeswitch: switching device 12d1:1446 on 001/006
Jan  1 03:00:11 rpi-router usb_modeswitch: switching device 12d1:1446 on 001/005
Jan  1 03:00:11 rpi-router kernel: [   11.708592] usb 1-1.3.3: USB disconnect, device number 5
Jan  1 03:00:11 rpi-router kernel: [   11.887379] usb 1-1.3.4: USB disconnect, device number 6
Jan  1 03:00:15 rpi-router kernel: [   15.856260] usb 1-1.3.3: new high-speed USB device number 7 using dwc_otg
Jan  1 03:00:15 rpi-router kernel: [   15.959301] usb 1-1.3.3: New USB device found, idVendor=12d1, idProduct=1506
Jan  1 03:00:15 rpi-router kernel: [   15.959339] usb 1-1.3.3: New USB device strings: Mfr=4, Product=3, SerialNumber=0
Jan  1 03:00:15 rpi-router kernel: [   15.959358] usb 1-1.3.3: Product: HUAWEI Mobile
Jan  1 03:00:15 rpi-router kernel: [   15.959373] usb 1-1.3.3: Manufacturer: Huawei Technologies
Jan  1 03:00:16 rpi-router kernel: [   16.047795] scsi4 : usb-storage 1-1.3.3:1.5
Jan  1 03:00:16 rpi-router kernel: [   16.050025] scsi5 : usb-storage 1-1.3.3:1.6
Jan  1 03:00:16 rpi-router kernel: [   16.186293] usbcore: registered new interface driver usbserial
Jan  1 03:00:16 rpi-router kernel: [   16.193706] usbcore: registered new interface driver usbserial_generic
Jan  1 03:00:16 rpi-router kernel: [   16.198379] USB Serial support registered for generic
Jan  1 03:00:16 rpi-router kernel: [   16.198436] usbserial: USB Serial Driver core
Jan  1 03:00:16 rpi-router kernel: [   16.211386] usbcore: registered new interface driver cdc_wdm
Jan  1 03:00:16 rpi-router kernel: [   16.243852] qmi_wwan 1-1.3.3:1.1: cdc-wdm0: USB WDM device
Jan  1 03:00:16 rpi-router kernel: [   16.250015] qmi_wwan 1-1.3.3:1.1: wwan0: register 'qmi_wwan' at usb-bcm2708_usb-1.3.3, WWAN/QMI device, 02:50:f3:00:00:00
Jan  1 03:00:16 rpi-router kernel: [   16.258968] usbcore: registered new interface driver qmi_wwan
Jan  1 03:00:16 rpi-router kernel: [   16.283020] usbcore: registered new interface driver option
Jan  1 03:00:16 rpi-router kernel: [   16.287436] USB Serial support registered for GSM modem (1-port)
Jan  1 03:00:16 rpi-router kernel: [   16.287869] option 1-1.3.3:1.0: GSM modem (1-port) converter detected
Jan  1 03:00:16 rpi-router kernel: [   16.296383] usb 1-1.3.4: new high-speed USB device number 8 using dwc_otg
Jan  1 03:00:16 rpi-router kernel: [   16.302428] usb 1-1.3.3: GSM modem (1-port) converter now attached to ttyUSB0
Jan  1 03:00:16 rpi-router kernel: [   16.302873] option 1-1.3.3:1.3: GSM modem (1-port) converter detected
Jan  1 03:00:16 rpi-router kernel: [   16.313063] usb 1-1.3.3: GSM modem (1-port) converter now attached to ttyUSB1
Jan  1 03:00:16 rpi-router kernel: [   16.313753] option 1-1.3.3:1.4: GSM modem (1-port) converter detected
Jan  1 03:00:16 rpi-router kernel: [   16.315395] usb 1-1.3.3: GSM modem (1-port) converter now attached to ttyUSB2
Jan  1 03:00:16 rpi-router kernel: [   16.399640] usb 1-1.3.4: New USB device found, idVendor=12d1, idProduct=1506
Jan  1 03:00:16 rpi-router kernel: [   16.399675] usb 1-1.3.4: New USB device strings: Mfr=4, Product=3, SerialNumber=0
Jan  1 03:00:16 rpi-router kernel: [   16.399694] usb 1-1.3.4: Product: HUAWEI Mobile
Jan  1 03:00:16 rpi-router kernel: [   16.399710] usb 1-1.3.4: Manufacturer: Huawei Technologies
Jan  1 03:00:16 rpi-router kernel: [   16.483927] option 1-1.3.4:1.0: GSM modem (1-port) converter detected
Jan  1 03:00:16 rpi-router kernel: [   16.484700] usb 1-1.3.4: GSM modem (1-port) converter now attached to ttyUSB3
Jan  1 03:00:16 rpi-router kernel: [   16.485427] option 1-1.3.4:1.1: GSM modem (1-port) converter detected
Jan  1 03:00:16 rpi-router kernel: [   16.486092] usb 1-1.3.4: GSM modem (1-port) converter now attached to ttyUSB4
Jan  1 03:00:16 rpi-router kernel: [   16.486853] option 1-1.3.4:1.2: GSM modem (1-port) converter detected
Jan  1 03:00:16 rpi-router kernel: [   16.490879] usb 1-1.3.4: GSM modem (1-port) converter now attached to ttyUSB5
Jan  1 03:00:16 rpi-router kernel: [   16.494087] qmi_wwan 1-1.3.4:1.3: cdc-wdm1: USB WDM device
Jan  1 03:00:16 rpi-router kernel: [   16.495340] qmi_wwan 1-1.3.4:1.3: wwan1: register 'qmi_wwan' at usb-bcm2708_usb-1.3.4, WWAN/QMI device, 02:50:f3:00:00:00
Jan  1 03:00:16 rpi-router kernel: [   16.504977] scsi6 : usb-storage 1-1.3.4:1.5
Jan  1 03:00:16 rpi-router kernel: [   16.506531] scsi7 : usb-storage 1-1.3.4:1.6
Jan  1 03:00:17 rpi-router kernel: [   17.048274] scsi 4:0:0:0: CD-ROM            HUAWEI   Mass Storage     2.31 PQ: 0 ANSI: 2
Jan  1 03:00:17 rpi-router kernel: [   17.049401] scsi 5:0:0:0: Direct-Access     HUAWEI   TF CARD Storage       PQ: 0 ANSI: 2
Jan  1 03:00:17 rpi-router kernel: [   17.053797] sd 5:0:0:0: [sda] Attached SCSI removable disk
Jan  1 03:00:17 rpi-router kernel: [   17.497666] scsi 6:0:0:0: CD-ROM            HUAWEI   Mass Storage     2.31 PQ: 0 ANSI: 2
Jan  1 03:00:17 rpi-router kernel: [   17.507849] scsi 7:0:0:0: Direct-Access     HUAWEI   TF CARD Storage       PQ: 0 ANSI: 2
Jan  1 03:00:17 rpi-router kernel: [   17.512661] sd 7:0:0:0: [sdb] Attached SCSI removable disk
But in bad cases these messages are not printing at all. Simply:

Code: Select all

Jan  1 03:00:11 rpi-router usb_modeswitch: switching device 12d1:1446 on 001/005
Jan  1 03:00:11 rpi-router usb_modeswitch: switching device 12d1:1446 on 001/006
And thats all, it all goes to space :(

I've tried to turn on logging for usb_modeswitch, but I think it is related to some storage unavialability or resetting, because files are being created, but they are empty for most times, sometimes they saing sane debug info, sometimes they half-written (cutted in the middle of log phrases). But nothing bad in them.

I should note, that before system update, all was working in 99,9% scenarios with physically same devices and same hub, power-consumptions and without any modprobe dancing.

Dear Josh and other forum fellas, can you pleae give me some suggestions, what else should I try?

int_19h
Posts: 2
Joined: 16 Aug 2013, 12:01

Re: Mode is not switched when modem is connected through hub

Post by int_19h » 22 Aug 2013, 12:17

So, my temporary problem salvation was to:
1) disable udev rules, because they are triggerring, but diying unexpectivly (half-written logs) and not switching mode
2) make double-identical autorun command on boot for each modem:
/usr/bin/usb_modeswitch -b 1 -g 7 -I -v 12d1 -p 1446 -M 55534243123456780000000000000011062000000100000000000000000000
/usr/bin/usb_modeswitch -b 1 -g 7 -I -v 12d1 -p 1446 -M 55534243123456780000000000000011062000000100000000000000000000
modems are switched only after second command.

I confirm that in my setup:
1) udev rules are not working as expected
2) cascaded hubs bug is present (however, manual rule edit as stated in my previous post helps)
3) each modem needs two identical usb_modeswitch commands to successfully switch its mode.

Post Reply