usb_modeswitch problem with Huawei E3372 [EDIT: FOUND BUG, SEE PATCH]
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Raspbian |
New
|
Undecided
|
Unassigned |
Bug Description
Hi,
I'm using raspbian on a raspberry pi 3 and I found a problem with usb_modeswitch udev rules
and the Huawei E3372 LTE usb modem. With default usb_modeswitch udev rules installed the modem
is not recognised and it stay in CD mode:
Bus 001 Device 038: ID 12d1:1f01 Huawei Technologies Co., Ltd.
If I install ModemManager and reinsert the usb modem it get switched into an ethernet device:
Bus 001 Device 039: ID 12d1:14dc Huawei Technologies Co., Ltd.
The problem is that there is nothing in ModemManager that "should" influence the switch of the modem.
I started debugging and found that the udev rules added by ModemManager have some "timing" influence
on the udev flow that make the switch happen. I came up with a simple test case...
ModemManager add some udev rules like:
77-mm-cinterion
77-mm-ericsson-
77-mm-huawei-
77-mm-longcheer
77-mm-mtk-
to make the switch happen I just need 77-mm-ericsson-
What happen is that the rules in /lib/udev/
behavior. The rule:
ATTRS{idVendor}
is the one responsible of the switch but without ModemManager installed it get fired with %b/%k
having the following value: 1-1.4/1-1.4:1.0
If I install ModemManager (or just put in flace one of the 2 rules files mentioned) this same rules
get fired with %b/%k having the value: /1-1.4:1.0
%b does not hold any value anymore! and the only change is some udev rules that have not effect
on the device just plugged...
the binary usb_modeswitch invoked by udev is /lib/udev/
udev fire rule from 40-usb_
/lib/udev/
/bin/systemctl --no-block start usb_modeswitch@
/usr/sbin/
if usb_modeswitch_
usb_modeswitch@
than usb_modeswitch_
is correclty switched.
there is a bug in usb_modeswitch rules but maybe even in other place because I can't explain why
the id of the device get changed with some rules that have no clue with this modem....
thanks in advance
Luigi
I found the bug in usb_modeswitch! usb_modeswitch call systemctl without escaping and I suspect that it dispatcher. I tried to correcly invoke
the script /lib/udev/
rely on the unescaping done by systemd and use_modeswitch_
the dispatcher with the --switch-systemd option but it does not work or I don't know what kind
of escaping it want and support....
So my patch rely on using use_modeswitch_ dispatcher with --switch-mode options.
The patch is on 2 distinct files:
--- usb_modeswitch 2016-06-17 13:26:07.449674124 +0200 usb_modeswitch 2016-06-17 13:25:35.730749887 +0200 upstart UMS_PARAM=$1 system/ " ]; then # Test if systemd is running $1.service usb_modeswitch@ .service $1) usb_modeswitch_ dispatcher --switch-mode $1 &
+++ /lib/udev/
@@ -80,7 +80,7 @@
if [ -x /sbin/initctl ] && /sbin/initctl version 2>/dev/null | /bin/grep -q upstart; then # Test if upstart is running
exec /sbin/initctl emit --no-wait usb-modeswitch-
elif [ -d "/run/systemd/
- exec /bin/systemctl --no-block start usb_modeswitch@
+ exec /bin/systemctl --no-block start $(systemd-escape --template=
else
export TMPDIR=/run
exec /usr/sbin/
--- usb_modeswitch@ .service 2016-06-17 13:30:51.080058537 +0200 system/ usb_modeswitch@ .service 2016-06-17 13:21:47.668214935 +0200
+++ /lib/systemd/
@@ -3,5 +3,5 @@
[Service] /usr/sbin/ usb_modeswitch_ dispatcher --switch-systemd %I /usr/sbin/ usb_modeswitch_ dispatcher --switch-mode %I "TMPDIR= /run"
Type=oneshot
-ExecStart=
+ExecStart=
Environment=
With my patch the usb modem switch correctly when use_modeswitch get invoke as: usb_modeswitch 1-1.4/1-1.4:1.0
/lib/udev/
Now I don't need to install ModemManager to have the switch to work. Still I don't know why
the rules contained in ModemManager makes the id change to blank... but at this point I don't care :D
I hope this can help
Luigi