Page 1 of 1

usb_modeswitch suddenly stopped working with K3772-Z

Posted: 07 May 2014, 11:31
by amrbekhit
Hello all,

I've got a Raspberry Pi Model B that I'm running Arch linux on and using a Vodafone/ZTE K3772-Z USB modem for internet connection. I initially had problems getting usb_modeswitch to work on Arch (only worked when I specified a config file that I downloaded off), but I ended up doing a clean install (reflashing the SD card) and the installing the usb_modeswitch package via pacman and since then it's worked fine, with the device automatically switching once plugged in.

However, after leaving the Pi running for a few days, I've since come back to it and found that the dongle will not automatically switch when plugged in. I've enabled logging in usb_modeswitch, and here's the output of the log when I plug my device in:

Code: Select all

USB_ModeSwitch log from Wed May 07 09:54:51 BST 2014

Use global config file: /etc/usb_modeswitch.conf
Raw args from udev: 1-1.3/1-1.3

Use top device dir /sys/bus/usb/devices/1-1.3

----------------
USB values from sysfs:
  manufacturer	Vodafone
  product	K3772-Z
  serial	0EBA659B814EFABD2AA3976EC30EA0BBB67AF86D
----------------
bNumConfigurations is 1 - don't check for active configuration
SCSI attributes not needed, move on
Check config: /usr/share/usb_modeswitch/19d2:1179
! matched. Read config data
config: TargetVendor set to 19d2
config: TargetProduct set to 1181
config: NoDriverLoading is set to active
Driver will not be handled by usb_modeswitch
Command to be run:
usb_modeswitch -W -D -s 20 -u -1 -b 1 -g 12 -v 19d2 -p 1179 -f $configBuffer
Here's also the output of the system log (via journalctl) when I plug the device in:

Code: Select all

May 07 10:12:02 alarmpi kernel: usb 1-1.3: USB disconnect, device number 14
May 07 10:12:10 alarmpi kernel: usb 1-1.3: new high-speed USB device number 15 using dwc_otg
May 07 10:12:10 alarmpi kernel: usb 1-1.3: New USB device found, idVendor=19d2, idProduct=1179
May 07 10:12:10 alarmpi kernel: usb 1-1.3: New USB device strings: Mfr=2, Product=1, SerialNumber=3
May 07 10:12:10 alarmpi kernel: usb 1-1.3: Product: K3772-Z
May 07 10:12:10 alarmpi kernel: usb 1-1.3: Manufacturer: Vodafone
May 07 10:12:10 alarmpi kernel: usb 1-1.3: SerialNumber: 0EBA659B814EFABD2AA3976EC30EA0BBB67AF86D
May 07 10:12:10 alarmpi kernel: usb-storage 1-1.3:1.0: USB Mass Storage device detected
May 07 10:12:10 alarmpi kernel: scsi6 : usb-storage 1-1.3:1.0
May 07 10:12:11 alarmpi kernel: scsi 6:0:0:0: CD-ROM            Vodafone USB SCSI CD-ROM  0001 PQ: 0 ANSI: 0
May 07 10:12:12 alarmpi usb_modeswitch[871]: switch device 19d2:1179 on 001/015
The output of usb_modeswitch -W is shown below:

Code: Select all

 * usb_modeswitch: handle USB devices with multiple modes
 * Version 2.1.1 (C) Josua Dietze 2014
 * Based on libusb1/libusbx

 ! PLEASE REPORT NEW CONFIGURATIONS !

NeedResponse=0

No default vendor/product ID given. Abort
Although Arch linux on the Raspberry Pi doesn't have a separate usb_modeswitch_data package, I'm fairly certain it's already there since /usr/share/usb_modeswitch is populated with files for every combination of VID/PID.

I initially thought the modem might be at fault, but plugging into a Windows machine shows that it still seems to work fine.

I tried to run usb_modeswitch manually using a config file I'd found online that worked before (from http://www.linuxquestions.org/questions ... ost4756940) using usb_modeswitch -c dongle.txt, but that didn't work either. Here's the output:

Code: Select all

Look for target devices ...
 No devices in target mode or class found
Look for default devices ...
   product ID matched
 Found devices in default mode (1)
Access device 016 on bus 001
Current configuration number is 1
Use interface number 0
Use endpoints 0x01 (out) and 0x81 (in)

USB description data (for identification)
-------------------------
Manufacturer: Vodafone
     Product: K3772-Z
  Serial No.: 0EBA659B814EFABD2AA3976EC30EA0BBB67AF86D
-------------------------
Looking for active driver ...
 No active driver found. Detached before or never attached
Set up interface 0
Use endpoint 0x01 for message sending ...
Trying to send message 1 to endpoint 0x01 ...
 OK, message successfully sent
Reset response endpoint 0x81
Reset message endpoint 0x01
-> Run lsusb to note any changes. Bye!
Any thoughts?

Thanks

Amr

Re: usb_modeswitch suddenly stopped working with K3772-Z

Posted: 13 May 2014, 05:41
by LOM
The last line of your system log shows that usb_modeswitch gets invoked, where is the remaining part of the log showing the switch result and the detection of the new device id?

Re: usb_modeswitch suddenly stopped working with K3772-Z

Posted: 13 May 2014, 11:33
by amrbekhit
Hi LOM,

That is the end of the system log - I don't get any other log messages after this one:

Code: Select all

May 07 10:12:12 alarmpi usb_modeswitch[871]: switch device 19d2:1179 on 001/015
I've just tried it again now and it's the same. Even after I leave the modem plugged in for a few minutes, there is nothing new.

Amr

Re: usb_modeswitch suddenly stopped working with K3772-Z

Posted: 14 May 2014, 08:49
by LOM
I'd guess this is the common problem with RaspBerry Pi's usb controller, your dongle has received the switch message and has changed its usb id but the controller has not detected it.

Which linux kernel version are you using and which usb hub driver? dmesg should show the driver and it can be either dwc_otg or dwc2.
dwc2 is a reworked driver which should fix the usb controller "hanging", dwc_otg is an old buggy driver which was replaced by dwc2 a few month ago.

Re: usb_modeswitch suddenly stopped working with K3772-Z

Posted: 15 May 2014, 15:29
by amrbekhit
Thanks for your response. uname -r shows the following:

Code: Select all

3.12.19-2-ARCH
I've had a look at dmesg and it appears that the usb driver is indeed dwc_otg, based on the following line that appears when I plug the dongle in:

Code: Select all

[   40.688653] usb 1-1.3: new high-speed USB device number 10 using dwc_otg
Since you're saying that this is possibly the cause of the issue, I'll do some research to find out how I can swap dwc_otg for dwc2 (I'm using the Arch distro).

Re: usb_modeswitch suddenly stopped working with K3772-Z

Posted: 15 May 2014, 16:31
by LOM
The maintainers of Raspbian started to patch the dwc_otg driver over a year ago and got rid of the worst bugs so switching distro may help you.
dwc2 was introduced in linux 3.14 but you can probably lift over the source and compile it to run on 3.12.19 if you need to stay on Arch.


https://forum.openwrt.org/viewtopic.php?id=43420 describes the problem quite well, not enough host channels and too long time to free them. Devices with only 1 interfaces like ethernet adapters, keyboard, and mouse works but composite devices with multiple interfaces causes problem.