Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bug#805512: usb-modeswitch-data: Huawei 12d1:1446 does not switch due to bad udev rule

230 views
Skip to first unread message

Blake Miner

unread,
Nov 18, 2015, 7:10:02 PM11/18/15
to
Package: usb-modeswitch-data
Version: 20150115-1
Severity: normal

Dear Maintainer,

This bug is very similar to archived bug # 751271. After upgrading from Debian 7 to Debian 8, my Huawei modem will no longer switch from "usb storage" to "modem mode" when the device is plugged in.

I am experiencing this problem in latest Debian 8.2, udev 215, usb_modeswitch 2.2.0+repack0-2, and usb-modeswitch-data 20150115-1. I am using the Huawei 12d1:1446 device -- the same mentioned in archived bug # 751271.

The catch-all udev rule does not work:

​# Generic entry for all Huawei devices
ATTRS{idVendor}=="12d1", ATTR{bInterfaceNumber}=="00", ATTR{bInterfaceClass}=="08", RUN+="usb_modeswitch '%b/%k'"​


The switching does not occur by udev automatically. Switching by manually calling usb_modeswitch works fine:

usb_modeswitch -v 12d1 -p 1446 -J

And... a few moments later by new device 12d1:1506 appears and all is well.

If I simply modify the udev rule, everything works automatically. For example, this rule works:

ATTR{idVendor}=="12d1", ATTR{idProduct}=="1446", RUN+="/lib/udev/usb_modeswitch '%b/%k'"

This does not work, however:

ATTR{idVendor}=="12d1", ATTR{idProduct}=="1446", ATTR{bInterfaceNumber}=="00", RUN+="/lib/udev/usb_modeswitch '%b/%k'"

Here's an except from `udevadm info` **before switching**:

looking at device '/devices/pci0000:00/0000:00:1d.7/usb2/2-1/2-1:1.0':
KERNEL=="2-1:1.0"
SUBSYSTEM=="usb"
DRIVER=="usb-storage"
ATTR{bInterfaceClass}=="08"
ATTR{bInterfaceSubClass}=="06"
ATTR{bInterfaceProtocol}=="50"
ATTR{bNumEndpoints}=="02"
ATTR{supports_autosuspend}=="1"
ATTR{bAlternateSetting}==" 0"
ATTR{bInterfaceNumber}=="00"

looking at parent device '/devices/pci0000:00/0000:00:1d.7/usb2/2-1':
KERNELS=="2-1"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRS{bDeviceSubClass}=="00"
ATTRS{bDeviceProtocol}=="00"
ATTRS{devpath}=="1"
ATTRS{idVendor}=="12d1"
ATTRS{speed}=="480"
ATTRS{bNumInterfaces}==" 2"
ATTRS{bConfigurationValue}=="1"
ATTRS{bMaxPacketSize0}=="64"
ATTRS{busnum}=="2"
ATTRS{devnum}=="18"
ATTRS{configuration}=="Huawei Configuration"
ATTRS{bMaxPower}=="500mA"
ATTRS{authorized}=="1"
ATTRS{bmAttributes}=="c0"
ATTRS{bNumConfigurations}=="1"
ATTRS{maxchild}=="0"
ATTRS{bcdDevice}=="0000"
ATTRS{avoid_reset_quirk}=="0"
ATTRS{quirks}=="0x0"
ATTRS{version}==" 2.00"
ATTRS{urbnum}=="313"
ATTRS{ltm_capable}=="no"
ATTRS{manufacturer}=="Huawei Technologies"
ATTRS{removable}=="unknown"
ATTRS{idProduct}=="1446"
ATTRS{bDeviceClass}=="00"
ATTRS{product}=="HUAWEI Mobile"

And, here is the output from `udevadm test -a add /devices/pci0000:00/0000:00:1d.7/usb2/2-1/2-1:1.0` **before switching**:

calling: test
version 215
This program is for debugging only, it does not run any program
specified by a RUN key. It may show incorrect results, because
some values may be different, or not available at a simulation run.

load module index
Network interface NamePolicy= disabled on kernel commandline, ignoring.
timestamp of '/etc/systemd/network' changed
timestamp of '/lib/systemd/network' changed
Parsed configuration file /lib/systemd/network/99-default.link
Created link configuration context.
timestamp of '/etc/udev/rules.d' changed
read rules file: /lib/udev/rules.d/40-usb_modeswitch.rules
read rules file: /lib/udev/rules.d/42-usb-hid-pm.rules
read rules file: /lib/udev/rules.d/50-firmware.rules
read rules file: /lib/udev/rules.d/50-udev-default.rules
read rules file: /lib/udev/rules.d/55-dm.rules
read rules file: /lib/udev/rules.d/60-cdrom_id.rules
read rules file: /lib/udev/rules.d/60-drm.rules
read rules file: /lib/udev/rules.d/60-gnupg.rules
read rules file: /lib/udev/rules.d/60-keyboard.rules
read rules file: /lib/udev/rules.d/60-persistent-alsa.rules
read rules file: /lib/udev/rules.d/60-persistent-input.rules
read rules file: /lib/udev/rules.d/60-persistent-serial.rules
read rules file: /lib/udev/rules.d/60-persistent-storage-dm.rules
read rules file: /lib/udev/rules.d/60-persistent-storage-tape.rules
read rules file: /lib/udev/rules.d/60-persistent-storage.rules
read rules file: /lib/udev/rules.d/60-persistent-v4l.rules
read rules file: /lib/udev/rules.d/61-accelerometer.rules
read rules file: /lib/udev/rules.d/64-btrfs.rules
read rules file: /lib/udev/rules.d/64-xorg-xkb.rules
read rules file: /lib/udev/rules.d/69-xorg-vmmouse.rules
read rules file: /etc/udev/rules.d/70-persistent-net.rules
read rules file: /lib/udev/rules.d/70-power-switch.rules
read rules file: /lib/udev/rules.d/70-uaccess.rules
read rules file: /lib/udev/rules.d/71-seat.rules
read rules file: /lib/udev/rules.d/73-idrac.rules
read rules file: /lib/udev/rules.d/73-seat-late.rules
read rules file: /lib/udev/rules.d/75-net-description.rules
read rules file: /lib/udev/rules.d/75-persistent-net-generator.rules
read rules file: /lib/udev/rules.d/75-probe_mtd.rules
read rules file: /lib/udev/rules.d/75-tty-description.rules
read rules file: /lib/udev/rules.d/78-sound-card.rules
read rules file: /lib/udev/rules.d/80-drivers.rules
read rules file: /lib/udev/rules.d/80-net-setup-link.rules
read rules file: /lib/udev/rules.d/80-networking.rules
read rules file: /lib/udev/rules.d/85-hwclock.rules
read rules file: /lib/udev/rules.d/90-alsa-restore.rules
read rules file: /lib/udev/rules.d/95-udev-late.rules
read rules file: /etc/udev/rules.d/99-custom.rules
read rules file: /lib/udev/rules.d/99-systemd.rules
rules contain 49152 bytes tokens (4096 * 12 bytes), 14073 bytes strings
3585 strings (38731 bytes), 2565 de-duplicated (25679 bytes), 1021 trie nodes used
RUN 'usb_modeswitch '%b/%k'' /lib/udev/rules.d/40-usb_modeswitch.rules:24
IMPORT builtin 'hwdb' /lib/udev/rules.d/50-udev-default.rules:11
RUN 'kmod load $env{MODALIAS}' /lib/udev/rules.d/80-drivers.rules:5
ACTION=add
DEVPATH=/devices/pci0000:00/0000:00:1d.7/usb2/2-1/2-1:1.0
DEVTYPE=usb_interface
DRIVER=usb-storage
ID_MODEL_FROM_DATABASE=E1552/E1800/E173 (HSPA modem)
ID_VENDOR_FROM_DATABASE=Huawei Technologies Co., Ltd.
INTERFACE=8/6/80
MODALIAS=usb:v12D1p1446d0000dc00dsc00dp00ic08isc06ip50in00
PRODUCT=12d1/1446/0
SUBSYSTEM=usb
TYPE=0/0/0
USEC_INITIALIZED=23090527
run: 'usb_modeswitch '2-1/2-1:1.0''
run: 'kmod load usb:v12D1p1446d0000dc00dsc00dp00ic08isc06ip50in00'
unload module index
Unloaded link configuration context.


I should also note that running /lib/udev/usb_modeswitch '2-1/2-1:1.0' manually does not cause the USB device to switch.
Interestingly, running /lib/udev/usb_modeswitch '2-1' does cause the USB device to switch.

This could be why setting the rule on the USB device works but setting the rule on the USB device **interface** does not.

I'd be happy to provide more information as needed.

Thanks!

-- System Information:
Debian Release: 8.2
APT prefers stable-updates
APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 3.16.0-4-amd64 (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

usb-modeswitch-data depends on no packages.

Versions of packages usb-modeswitch-data recommends:
ii udev 215-17+deb8u2
ii usb-modeswitch 2.2.0+repack0-2

usb-modeswitch-data suggests no packages.

-- no debconf information

Josua Dietze

unread,
Nov 19, 2015, 5:10:02 AM11/19/15
to
Am 19.11.2015 um 01:00 schrieb Blake Miner:

> The catch-all udev rule does not work:
>
> ​# Generic entry for all Huawei devices
> ATTRS{idVendor}=="12d1", ATTR{bInterfaceNumber}=="00", ATTR{bInterfaceClass}=="08", RUN+="usb_modeswitch '%b/%k'"​

Thanks for the report. Upstream dev here.

This has been a puzzle for some time now. Most people don't have any problems with this rule, but there are occasional hiccups like your's.

There is an educated guess that it's not the rule itself that is to blame. It's very likely that the installed systemd version affects the respective outcome.
The problem is related to the creation of "instance units" for systemd. USB_ModeSwitch requires this as there are possibly several instances started in parallel (if there is more than one device connected which needs a mode switch).
These instances are defined by the *filename*, meaning that the template unit file "usb_modeswitch@.service" will be instantiated as "usb_modeswitch@<bus/kernel_name>.service".

Originally, the unchanged parameter from the RUN directive was used to name the instance. At the time of testing, systemd translated the "/" character transparently. However, there seems to have been a change so that re-translation did not work as before, and subsequently the dispatcher script failed to recognize the parameter when the instance name was passed on by the unit.

In usb-modeswitch 2.2.2, the parameter format was altered: "/" is replaced by "_" *before* the systemd service unit is started. The dispatcher was modified accordingly.

I'm not sure if a version update is possible for Debian. Anyway, here is a little patch that you can try (after restoring the 'catch-all' rule to its original form). The patch is against 2.2.1 in the upstream version but should be easy to apply to the Debian source manually.

Best regards,
Josh


systemd_unit_instance.patch

Blake Miner

unread,
Nov 20, 2015, 1:40:03 PM11/20/15
to
​Josh,

Thanks for your response.

Here's the thing... the udev rule is triggering, and systemd is running the /lib/udev/usb_modeswitch program, which ends up running usb_modeswitch_dispatcher.  All is good there, but the problem (I think) is as follows:

The working udev rule:
* Triggered when the USB device is attached
* Ends up executing /lib/udev/usb_modeswitch '/2-1'

The non-working catch-all udev rule:
* Triggered when the USB device **interface** is attached
* Ends up executing /lib/udev/usb_modeswitch '2-1/2-1:1.0'

I don't understand the inner-workings of the usb_modeswitch_dispatcher, but why does one rule work and not the other?

Blake Miner

unread,
Jan 8, 2016, 3:30:04 PM1/8/16
to
Bump.  Any another thoughts on this bug?  It's hard to tell if this is a usb-modeswitch bug (i.e. a problem with usb_modeswitch_dispatcher) or if this is a problem with the udev rule itself (a usb-modeswitch-data bug).

Again, to summarize, I think that the non-working rule triggers when the USB interface is attached and executes the command: /lib/udev/usb_modeswitch '2-1/2-1:1.0'.  The working rule triggers when the device itself is attached and executes the command: /lib/udev/usb_modeswitch '/2-1'.

/lib/udev/usb_modeswitch '2-1/2-1:1.0' does not work.
/lib/udev/usb_modeswitch '/2-1' works just fine.

Thanks.

Josua Dietze

unread,
Jan 8, 2016, 6:00:03 PM1/8/16
to
Am 08.01.2016 um 21:25 schrieb Blake Miner:
> Bump. Any another thoughts on this bug? It's hard to tell if this is a
> usb-modeswitch bug (i.e. a problem with usb_modeswitch_dispatcher) or if this
> is a problem with the udev rule itself (a usb-modeswitch-data bug).

Have you tried to enable usb_modeswitch's logging?
If the rules are at least triggering and starting the dispatcher, there should
be a log being created.

> /lib/udev/usb_modeswitch '2-1/2-1:1.0' does not work.
> /lib/udev/usb_modeswitch '/2-1' works just fine.

The log should give more hints.


Regards,
Josh

Blake Miner

unread,
Jan 8, 2016, 6:20:03 PM1/8/16
to
Honestly, I did try the whole usbmodeswitch logging thing to no avail - no logfile is generated in /var/log/. Can you give me some pointers on how to enable logging in Debian? If it's any consolation, I'm using a read-only root partition with a writable /var tmpfs.

Josua Dietze

unread,
Jan 11, 2016, 6:30:02 AM1/11/16
to
Am 09.01.2016 um 00:14 schrieb Blake Miner:
> Honestly, I did try the whole usbmodeswitch logging thing to no avail

There is only the one global switch in /etc/usb_modeswitch.conf - if that did not work, then it's very likely that the dispatcher is never run.

I'll have a closer look at /lib/udev/usb_modeswitch. There may also be systemd involved, as I have stated before.


Best regards,
Josh

Josua Dietze

unread,
Jan 11, 2016, 8:20:03 AM1/11/16
to
Am 09.01.2016 um 00:14 schrieb Blake Miner:
> Honestly, I did try the whole usbmodeswitch logging thing to no avail

I have found a stupid bug in the dispatcher which prevented early
logging ...

Edit the dispatcher script "/sbin/usb_modeswitch_dispatcher" (or
"usb_modeswitch.tcl" in the source).

Change line #731 from

set $flags(logwrite) 1

to

set flags(logwrite) 1

Now you should get a (short) log, showing at least the input parameter the
dispatcher receives.



Best regards,
Josh

Josua Dietze

unread,
Jan 13, 2016, 9:00:03 AM1/13/16
to
I have just released upstream version 2.3.0 of usb_modeswitch and version 20160112 of the data package.

The bug with the missing log is fixed, as well as a potentially disruptive other bug in the wrapper (see http://draisberghof.de/usb_modeswitch/bb/viewtopic.php?p=16240 ).

However, I have not been able to replicate bug #805512 that Blake Miner describes.

Unfortunately, there is no way to move forward with this bug until I see the usb_modeswitch log with the raw parameter data transmitted by the systemd instance.


Best regards,
Josh

Paul Slootman

unread,
Jul 4, 2016, 2:30:02 PM7/4/16
to
I had problems with the mode switch not happening with a Huawei E3272.
This was with usb-modswitch 2.2.0+repack0-2 and usb-modeswitch-data
20150115-1. After upgrading to 2.4.0+repack0-1 and 20160612-1 I had no
problems, so updating to this version works for me. I'm using systemd
with basically jessie. I also needed to upgrade libjim0.76 to 0.76-2
due to dependencies but nothing else.

With the old version I needed this line in de rules.d file:

ATTR{idVendor}=="12d1", ATTR{idProduct}=="1f01", RUN +="usb_modeswitch '%b/%k'"

I first thought that the problem was that the catchall rule has ATTRS
while my lins has ATTR... but I admit I know next to nothing about udev
:)


Paul

Christian Pointner

unread,
Jul 6, 2016, 11:10:02 AM7/6/16
to
Hi,

Am 2016-07-04 um 20:21 schrieb Paul Slootman:
> I had problems with the mode switch not happening with a Huawei E3272.
> This was with usb-modswitch 2.2.0+repack0-2 and usb-modeswitch-data
> 20150115-1. After upgrading to 2.4.0+repack0-1 and 20160612-1 I had no
> problems, so updating to this version works for me. I'm using systemd
> with basically jessie. I also needed to upgrade libjim0.76 to 0.76-2
> due to dependencies but nothing else.

I as well had problems with automatic switching (Huawei E173) and just
backported the usb-modeswitch and usb-modeswitch-data package from
stretch to jessie. This was very easy as the package just builds on
jessie without modifications.

After the upgrade the mode switch worked as expected.

regards
christian
0 new messages