Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Automatic usb_modeswitch
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware
View previous topic :: View next topic  
Author Message
Unb0rn
n00b
n00b


Joined: 12 Jun 2012
Posts: 63

PostPosted: Tue Nov 22, 2016 12:13 pm    Post subject: Automatic usb_modeswitch Reply with quote

I have a Huawei E3372h stick LTE modem and it has zerocd image by default.
I've installed usb_modeswitch, downloaded usb_modeswitch-data from draisberghof.de (as it's recommended by wiki) and installed its' config files.
I even added config for my modem to /etc/usb_modeswitch.conf and now I can switch to CDC manually by issuing usb_modeswitch -c /etc/usb_modeswitch.conf or usb_modeswitch -v 12d1 -p 1f01 -M"<convert message here> but the system won't autoswitch modem for me. I have 40-usb_modeswitch.rule in /lib/udev/rules.d (tried to copy it in /etc/udev/rules.d/) this config has Huawei devices by default but I added my specifically. It still won't work in automatic mode.
I am running systemd, so udev should be no problem.
Any ideas? Or is this a bug?
Upd. It works after reboot-if I had my device plugged in while booting, it would autoswitch, but if I re-plug it while system is running, it still won't autoswitch.
If it helps, here are logs of usb_modeswitch on boot and dmesg on stick replug:pastebin.com/YaFXFjEH (modeswitch), pastebin.com/ytfpdLQJ(dmesg)
Back to top
View user's profile Send private message
Unb0rn
n00b
n00b


Joined: 12 Jun 2012
Posts: 63

PostPosted: Fri Nov 25, 2016 11:42 am    Post subject: Reply with quote

Up.d First, tried to update usb_modeswitch to latest testing version, then, updated systemd to 231(232 has a regression and is masked) Nothing helps. Autoswitching works only on boot. Any ideas at all?
Back to top
View user's profile Send private message
Logicien
Veteran
Veteran


Joined: 16 Sep 2005
Posts: 1369
Location: Montréal

PostPosted: Fri Nov 25, 2016 1:31 pm    Post subject: Reply with quote

It may depend on how you have compiled the support for your Huawei stick. If you have put it in the kernel image you cannot unload/reload the support unless you reboot. I ever had a Huawei stick. Only one string passing to the Usb stick with usb_modeswitch was working. The string can be put in /etc/usb_modeswitch.conf instead of being pass at command line.

If I remember well, sometimes I had to unplug the stick, unload and reload the option module and after had replug the stick, executing usb_modeswitch was switching the stick to modem mode. The modem was working but with tricky manipulations in some cases.

I am not sure if a Udev rule is the best way to switch the stick to modem mode. Is there a usb_modeswitch service you can enable at boot time who can do it?
_________________
Paul
Back to top
View user's profile Send private message
borbor
n00b
n00b


Joined: 26 Nov 2016
Posts: 5

PostPosted: Sat Nov 26, 2016 7:55 am    Post subject: Reply with quote

You could try:

1. comment out the line
#exec 1<&- 2<&- 5<&- 7<&-
in /lib/udev/usb_modeswitch for /usb_modeswitch-2.4.0

2. downgrade to usb_modeswitch-2.3.0

or (not tested yet)

3. change the end of /lib/udev/usb_modeswitch file to:
systemctl --no-block start usb_modeswitch@$p1'_'$p2.service
(without if's; for gentoo with systemd only)

http://www.draisberghof.de/usb_modeswitch/bb/viewtopic.php?f=2&t=2329
Back to top
View user's profile Send private message
Unb0rn
n00b
n00b


Joined: 12 Jun 2012
Posts: 63

PostPosted: Sat Nov 26, 2016 10:41 am    Post subject: Reply with quote

Logicien wrote:
It may depend on how you have compiled the support for your Huawei stick. If you have put it in the kernel image you cannot unload/reload the support unless you reboot. I ever had a Huawei stick. Only one string passing to the Usb stick with usb_modeswitch was working. The string can be put in /etc/usb_modeswitch.conf instead of being pass at command line.

If I remember well, sometimes I had to unplug the stick, unload and reload the option module and after had replug the stick, executing usb_modeswitch was switching the stick to modem mode. The modem was working but with tricky manipulations in some cases.

I am not sure if a Udev rule is the best way to switch the stick to modem mode. Is there a usb_modeswitch service you can enable at boot time who can do it?

Support for usb_xhci is built-in kernel, support for cdc is built as module. Re-plugging does not help. It autoswitches only if stick is plugged in while system is booting...
usb_modeswitch.conf is already edited to include default and target vendors and products, also it has a string with MessaeContent. I can manually issue usb_modeswitch -c /etc/usb_modeswitch.conf and stick will switch to CDC...
Back to top
View user's profile Send private message
Unb0rn
n00b
n00b


Joined: 12 Jun 2012
Posts: 63

PostPosted: Sat Nov 26, 2016 10:49 am    Post subject: Reply with quote

borbor wrote:
You could try:

1. comment out the line
#exec 1<&- 2<&- 5<&- 7<&-
in /lib/udev/usb_modeswitch for /usb_modeswitch-2.4.0

2. downgrade to usb_modeswitch-2.3.0

or (not tested yet)

3. change the end of /lib/udev/usb_modeswitch file to:
systemctl --no-block start usb_modeswitch@$p1'_'$p2.service
(without if's; for gentoo with systemd only)

http://www.draisberghof.de/usb_modeswitch/bb/viewtopic.php?f=2&t=2329


Tried first method-nothing.
Tried to install testing 2.3.0(now i've tried every version on portage tree-2.2.6, 2.3.0 and 2.4.0)-still nothing...
And about third-is it okay that manually issuing systemctl start usb_modeswitch returns an error "no such file.."?
Back to top
View user's profile Send private message
borbor
n00b
n00b


Joined: 26 Nov 2016
Posts: 5

PostPosted: Sat Nov 26, 2016 11:33 am    Post subject: Reply with quote

udevadm control --log-priority=debug
systemctl start ModemManager
systemctl start NetworkManager
Using 2.4.0 and "method 1" I have in journalctl -f :
...
kernel: usb-storage 3-1:1.0: USB Mass Storage device detected
.....
kernel: usb 3-1: new high-speed USB device number 13 using xhci_hcd
.....
kernel: option 3-1:1.3: GSM modem (1-port) converter detected
......
usb_modeswitch: switched to 12d1:1506 on 003/013
......
ModemManager[836]: <warn> (ttyUSB2): port attributes not fully set
.....

and I have network connection.
Back to top
View user's profile Send private message
borbor
n00b
n00b


Joined: 26 Nov 2016
Posts: 5

PostPosted: Sat Nov 26, 2016 12:04 pm    Post subject: Reply with quote

Using "method 3" for 2.4.0 with very last lines
of /lib/udev/usb_modeswitch:

IFS='/' read -r p1 p2 <<EOF
$1
EOF

PATH=/bin:/sbin:/usr/bin:/usr/sbin
systemctl --no-block start usb_modeswitch@$p1'_'$p2.service
exit 0

also all looks ok.
=====
Logicien: "Is there a usb_modeswitch service you can enable at boot ...?"
I do not have enabled or started usb_modeswitch.service .
Back to top
View user's profile Send private message
Unb0rn
n00b
n00b


Joined: 12 Jun 2012
Posts: 63

PostPosted: Sat Nov 26, 2016 3:05 pm    Post subject: Reply with quote

borbor wrote:
udevadm control --log-priority=debug
systemctl start ModemManager
systemctl start NetworkManager
Using 2.4.0 and "method 1" I have in journalctl -f :
...
kernel: usb-storage 3-1:1.0: USB Mass Storage device detected
.....
kernel: usb 3-1: new high-speed USB device number 13 using xhci_hcd
.....
kernel: option 3-1:1.3: GSM modem (1-port) converter detected
......
usb_modeswitch: switched to 12d1:1506 on 003/013
......
ModemManager[836]: <warn> (ttyUSB2): port attributes not fully set
.....

and I have network connection.


And now this is really weird. It really works after I issue udevam control command to set debug loglevel. If I don't-it still does not autoswitch. What it may be? User rights conflict?
Back to top
View user's profile Send private message
borbor
n00b
n00b


Joined: 26 Nov 2016
Posts: 5

PostPosted: Sat Nov 26, 2016 4:02 pm    Post subject: Reply with quote

That the log-priority=debug was the cause looks extremely unlikely.
It would be pure mysticism ( any timeouts in the systemd ...).
ModemManager and NetworkManager could be causing the problems.

I'am very glad it works :D
Back to top
View user's profile Send private message
Unb0rn
n00b
n00b


Joined: 12 Jun 2012
Posts: 63

PostPosted: Sat Nov 26, 2016 4:39 pm    Post subject: Reply with quote

borbor wrote:
That the log-priority=debug was the cause looks extremely unlikely.
It would be pure mysticism ( any timeouts in the systemd ...).
ModemManager and NetworkManager could be causing the problems.

I'am very glad it works :D

Now I have to call it every boot... Anyway, thank you!=)
Back to top
View user's profile Send private message
borbor
n00b
n00b


Joined: 26 Nov 2016
Posts: 5

PostPosted: Sat Nov 26, 2016 5:09 pm    Post subject: Reply with quote

maybe kernel command line: udev.log-priority
(maybe /etc/udev/udev.conf)

I have installed (no changes in configuration files no kernel parameters connected to udev):
virtual/udev-217
udev-init-scripts-32
systemd-232

and no need to set debug level
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Kernel & Hardware All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum