Automatic Activation, Hotplug and UDEV, Configuration
Post Reply
mkkot
Posts: 8
Joined: 14 Jul 2015, 18:34

Huawei E3272 aka Megafon M100-4 works but not on boot

Post by mkkot » 14 Jul 2015, 19:22

Hello,

I own Huawei E3272 which was working properly before 01.07.2015. After some update it suddenly stopped. While I was searching for the reason I found in the log this:

lip 14 15:48:24 linux usb_modeswitch[4958]: switch device 12d1:1f01 on 001/005
lip 14 15:48:25 linux root[4989]: usb_modeswitch: switched to 12d1:14db on 001/006

It's the output of usb_modeswitch while modem is being disconnected and plugged in again. Basicaly I was unable to find anything else. The modem works when it's plugged in after system boot. It doesn't work when it's already plugged in before PC is being powered on.

I'm also unable to find manual command for the switch. It will be something like:
usb_modeswitch -v 12d1 -p 14db

but it produces:

Code: Select all

[root@linux mk]# usb_modeswitch -v 12d1 -p 14db -J
Look for default devices ...
   product ID matched
 Found devices in default mode (1)
Access device 008 on bus 002
Current configuration number is 1
Use interface number 0
Error: message endpoint not given or found. Abort

I'm confused with all this udev/wrapper/systemd complex. I have no idea how to run it manually.

In my system there is a file /usr/share/usb_modeswitch/12d1:1f01 with content:

Code: Select all

# Huawei E353 (3.se) and others
TargetVendor=0x12d1
TargetProductList="14db,14dc"
HuaweiNewMode=1
NoDriverLoading=1
There is also
/lib/udev/rules.d/40-usb_modeswitch.rules

with rule

Code: Select all

# Generic entry for all Huawei devices, excluding Android phones
ATTRS{idVendor}=="12d1", ATTRS{manufacturer}!="Android*", ATTR{bInterfaceNumber}=="00", ATTR{bInterfaceClass}=="08", RUN+="usb_modeswitch '%b/%k'"
If I only knew what %b/%k stands for...

I also found /var/log/usb_modeswitch_2-1:1.0 file with content:

Code: Select all


USB_ModeSwitch log from Tue Jul 14 18:08:41 CEST 2015

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

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

----------------
USB values from sysfs:
  manufacturer	HUAWEI Technology
  product	HUAWEI Mobile
  serial	FFFFFFFFFFFFFFFF
----------------
bNumConfigurations is 1 - don't check for active configuration
ConfigList: /usr/share/usb_modeswitch/12d1:1f01 /usr/share/usb_modeswitch/12d1:#linux
SCSI attributes not needed, move on
Check config: /usr/share/usb_modeswitch/12d1:1f01
! matched. Read config data
config: NoDriverLoading is set to active
Driver will not be handled by usb_modeswitch
Command to be run:
usb_modeswitch -W -D -u -1 -b 2 -g 7 -v 12d1 -p 1f01 -f $flags(config)

Verbose debug output of usb_modeswitch and libusb follows
(Note that some USB errors are to be expected in the process)
--------------------------------

Read long config from command line

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

 ! PLEASE REPORT NEW CONFIGURATIONS !

DefaultVendor=  0x12d1
DefaultProduct= 0x1f01
TargetVendor=   0x12d1
TargetProductList="14db,14dc"
HuaweiNewMode=1
NeedResponse=0
System integration mode enabled

Use given bus/device number: 002/007 ...
Look for default devices ...
 bus/device number matched
  found USB ID 12d1:1f01
   vendor ID matched
   product ID matched
 Found devices in default mode (1)
Use interface number 0
Use endpoints 0x01 (out) and 0x81 (in)

USB description data (for identification)
-------------------------
Manufacturer: HUAWEI Technology
     Product: HUAWEI Mobile
  Serial No.: FFFFFFFFFFFFFFFF
-------------------------
Using standard Huawei switching message
Looking for active driver ...
 OK, driver detached
Set up interface 0
Use endpoint 0x01 for message sending ...
Trying to send message 1 to endpoint 0x01 ...
libusb: error [op_clear_halt] clear_halt failed error -1 errno 71
 OK, message successfully sent
Reset response endpoint 0x81
 Could not reset endpoint (probably harmless): -99
Reset message endpoint 0x01
 Could not reset endpoint (probably harmless): -4
 Device is gone, skip any further commands
ok:busdev
--------------------------------
(end of usb_modeswitch output)

Check success of mode switch for max. 20 seconds ...
 Read attributes ...
 All attributes matched
Mode switching was successful, found 12d1:14db (HUAWEI Technology: HUAWEI Mobile)
Logger is /usr/bin/logger
Check for AVOID_RESET_QUIRK kernel attribute
 AVOID_RESET_QUIRK activated

All done, exit


I restarted the system and used command found in above log, thinking that it could shitch the mode manually:

Code: Select all

[root@linux mk]# usb_modeswitch -W -D -u -1 -b 2 -g 7 -v 12d1 -p 1f01 -f "$flags(config)"

Read long config from command line

Read long config from command line

Read long config from command line

Read long config from command line

Read long config from command line

Read long config from command line

Read long config from command line

Read long config from command line

Read long config from command line

Read long config from command line

Read long config from command line

Read long config from command line

Read long config from command line

Read long config from command line

Read long config from command line

Read long config from command line

Read long config from command line

Read long config from command line

Read long config from command line

Read long config from command line

Read long config from command line

Read long config from command line

Read long config from command line

Read long config from command line

Read long config from command line

Read long config from command line

Read long config from command line

Read long config from command line

Read long config from command line

Read long config from command line

Read long config from command line

Read long config from command line

Read long config from command line

Read long config from command line

Read long config from command line

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

 ! PLEASE REPORT NEW CONFIGURATIONS !

DefaultVendor=  0x12d1
DefaultProduct= 0x1f01
NeedResponse=0
System integration mode enabled

Use given bus/device number: 002/007 ...
Look for default devices ...
 No devices in default mode found. Nothing to do. Bye!
Would someone please help me to investigate? What could I do to get it working on boot?

BTW I admit that this modem is not genuine. I re-flashed it from Megafon software from modem to hi-link version. While doing that I damaged a bit storage memory (this one for windows drivers):

Code: Select all

[   12.541510] blk_update_request: critical medium error, dev sr2, sector 262136
[   12.545294] sr 6:0:0:0: [sr2] UNKNOWN(0x2003) Result: hostbyte=0x00 driverbyte=0x08
My system:
linux 4.0.7-2-ARCH #1 SMP PREEMPT Tue Jun 30 07:50:21 UTC 2015 x86_64 GNU/Linux
systemd 221
libgudev 230

I can also see in the log that:

[2015-06-30 21:42] [ALPM] upgraded usb_modeswitch (2.2.1-1 -> 2.2.3-1)

I will try to downgrade it and check if that solves the problem.

Any help appreciated!

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

Re: Huawei E3272 aka Megafon M100-4 works but not on boot

Post by Josh » 14 Jul 2015, 19:43

mkkot wrote:lip 14 15:48:24 linux usb_modeswitch[4958]: switch device 12d1:1f01 on 001/005
lip 14 15:48:25 linux root[4989]: usb_modeswitch: switched to 12d1:14db on 001/006

It's the output of usb_modeswitch while modem is being disconnected and plugged in again.
No. It is exactly what is expected.

I suggest you have a look at the usb_modeswitch documentation page. Everything is explained in the introduction there.

mkkot
Posts: 8
Joined: 14 Jul 2015, 18:34

Re: Huawei E3272 aka Megafon M100-4 works but not on boot

Post by mkkot » 14 Jul 2015, 20:45

Okay, so the bug isn't a bug, but a feature! :)

I assumed it's a bug because it was working for me with previous version of usb_modeswitch, kernel and systemd. Could you please point me how I can restore desired behaviour? (I'm using it with stand-alone PC). Meaning - Internet working after boot up without plugging off and on the modem?

/edit:

I created a file /etc/usb_modeswitch.d/12d1:1f01

Code: Select all

# Huawei E353 (3.se) and others
TargetVendor=0x12d1
TargetProductList="14db,14dc"
HuaweiNewMode=1
NoDriverLoading=1
WaitBefore=5
It doesn't work obviously because it isn't processed. I removed all /var/log/usb_modeswitch* files, rebooted the system and these logs weren't recreated. I re-plugged the modem and there appeared one:

Code: Select all

USB_ModeSwitch log from Tue Jul 14 21:02:20 CEST 2015

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

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

----------------
USB values from sysfs:
  manufacturer	HUAWEI Technology
  product	HUAWEI Mobile
  serial	FFFFFFFFFFFFFFFF
----------------
bNumConfigurations is 1 - don't check for active configuration
ConfigList: /etc/usb_modeswitch.d/12d1:1f01 /usr/share/usb_modeswitch/12d1:1f01 /usr/share/usb_modeswitch/12d1:#linux
SCSI attributes not needed, move on
Check config: /etc/usb_modeswitch.d/12d1:1f01
! matched. Read config data
Use config file from override folder /etc/usb_modeswitch.d
Logger is /usr/bin/logger
config: NoDriverLoading is set to active
Driver will not be handled by usb_modeswitch
Delay time of 5 seconds
 wait is over, start mode switch
Command to be run:
usb_modeswitch -W -D -u -1 -b 1 -g 5 -v 12d1 -p 1f01 -f $flags(config)

Verbose debug output of usb_modeswitch and libusb follows
(Note that some USB errors are to be expected in the process)
--------------------------------

Read long config from command line

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

 ! PLEASE REPORT NEW CONFIGURATIONS !

DefaultVendor=  0x12d1
DefaultProduct= 0x1f01
TargetVendor=   0x12d1
TargetProductList="14db,14dc"
HuaweiNewMode=1
NeedResponse=0
System integration mode enabled

Use given bus/device number: 001/005 ...
Look for default devices ...
 bus/device number matched
  found USB ID 12d1:1f01
   vendor ID matched
   product ID matched
 Found devices in default mode (1)
Use interface number 0
Use endpoints 0x01 (out) and 0x81 (in)

USB description data (for identification)
-------------------------
Manufacturer: HUAWEI Technology
     Product: HUAWEI Mobile
  Serial No.: FFFFFFFFFFFFFFFF
-------------------------
Using standard Huawei switching message
Looking for active driver ...
 OK, driver detached
Set up interface 0
Use endpoint 0x01 for message sending ...
Trying to send message 1 to endpoint 0x01 ...
libusb: error [op_clear_halt] clear_halt failed error -1 errno 71
 OK, message successfully sent
Reset response endpoint 0x81
 Could not reset endpoint (probably harmless): -99
Reset message endpoint 0x01
 Could not reset endpoint (probably harmless): -4
 Device is gone, skip any further commands
ok:busdev
--------------------------------
(end of usb_modeswitch output)

Check success of mode switch for max. 20 seconds ...
 Read attributes ...
 All attributes matched
Mode switching was successful, found 12d1:14db (HUAWEI Technology: HUAWEI Mobile)
Check for AVOID_RESET_QUIRK kernel attribute
 AVOID_RESET_QUIRK activated

All done, exit



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

Re: Huawei E3272 aka Megafon M100-4 works but not on boot

Post by Josh » 14 Jul 2015, 21:26

mkkot wrote:I assumed it's a bug because it was working for me with previous version of usb_modeswitch, kernel and systemd. Could you please point me how I can restore desired behaviour?
I don't know what components have changed on your system. What version of usb_modeswitch was installed previously?
What's the current version of systemd?

mkkot
Posts: 8
Joined: 14 Jul 2015, 18:34

Re: Huawei E3272 aka Megafon M100-4 works but not on boot

Post by mkkot » 14 Jul 2015, 21:38

I think it was after that update:

Code: Select all

[2015-06-30 21:32] [PACMAN] Running 'pacman -Syu'
[2015-06-30 21:32] [PACMAN] synchronizing package lists
[2015-06-30 21:32] [PACMAN] starting full system upgrade
[2015-06-30 21:40] [ALPM] transaction started
[2015-06-30 21:41] [ALPM] removed dnsutils (9.9.2.P2-2)
[2015-06-30 21:41] [ALPM] upgraded gnutls (3.4.1-1 -> 3.4.2-1)
[2015-06-30 21:41] [ALPM] upgraded kmod (20-1 -> 21-1)
[2015-06-30 21:41] [ALPM] upgraded libsystemd (219-6 -> 221-2)
[2015-06-30 21:41] [ALPM] upgraded systemd (219-6 -> 221-2)
[2015-06-30 21:41] [ALPM] upgraded polkit (0.112-2 -> 0.112-3)
[2015-06-30 21:41] [ALPM] installed libgudev (230-1)
[2015-06-30 21:41] [ALPM] upgraded udisks2 (2.1.5-1 -> 2.1.5-2)
[2015-06-30 21:41] [ALPM] upgraded upower (0.99.2-2 -> 0.99.3-1)
[2015-06-30 21:41] [ALPM] upgraded glib-networking (2.44.0-2 -> 2.44.0-3)
[2015-06-30 21:42] [ALPM] upgraded lib32-systemd (219-1 -> 221-1)
[2015-06-30 21:42] [ALPM] upgraded linux (4.0.5-1 -> 4.0.6-1)
[2015-06-30 21:42] [ALPM] upgraded usb_modeswitch (2.2.1-1 -> 2.2.3-1)
Now I have:
systemd 221-2
usb_modeswitch 2.2.3-1
linux 4.0.7-2

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

Re: Huawei E3272 aka Megafon M100-4 works but not on boot

Post by Josh » 14 Jul 2015, 22:50

You can check if usb_modeswitch is causing the problem by downgrading it to 2.2.1.

mkkot
Posts: 8
Joined: 14 Jul 2015, 18:34

Re: Huawei E3272 aka Megafon M100-4 works but not on boot

Post by mkkot » 15 Jul 2015, 00:46

I have already trying that. It doesn't work at all, I guess (from change log) that I will have to downgrade systemd and remove libgudev. I'll do that tomorrow and come back then :)

mkkot
Posts: 8
Joined: 14 Jul 2015, 18:34

Re: Huawei E3272 aka Megafon M100-4 works but not on boot

Post by mkkot » 15 Jul 2015, 21:47

Okay, so I downgraded systemd:

[2015-07-15 21:32] [PACMAN] Running 'pacman -Rdd libgudev'
[2015-07-15 21:32] [ALPM] transaction started
[2015-07-15 21:32] [ALPM] removed libgudev (230-1)
[2015-07-15 21:32] [ALPM] transaction completed

[2015-07-15 21:32] [ALPM] downgraded libsystemd (221-2 -> 219-6)
[2015-07-15 21:32] [ALPM] warning: /etc/systemd/coredump.conf installed as /etc/systemd/coredump.conf.pacnew
[2015-07-15 21:32] [ALPM] downgraded systemd (221-2 -> 219-6)
[2015-07-15 21:32] [ALPM] transaction completed

Didn't help. So I downgraded usb-modemswitch:

[2015-07-15 21:36] [PACMAN] Running 'pacman -U /var/cache/pacman/pkg/usb_modeswitch-2.2.1-1-x86_64.pkg.tar.xz'
[2015-07-15 21:36] [ALPM] transaction started
[2015-07-15 21:36] [ALPM] downgraded usb_modeswitch (2.2.3-1 -> 2.2.1-1)
[2015-07-15 21:36] [ALPM] transaction completed

And voila, it works as before. My modem starts at system boot. I don't have access to 2.2.4 version yet, but I guess I will be in a few days. I was reading the changelog to see what could possibly happen between 2.2.3 and 2.2.1 but I can't find the reason. Any ideas?

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

Re: Huawei E3272 aka Megafon M100-4 works but not on boot

Post by Josh » 16 Jul 2015, 08:30

Look in the shell script "usb_modeswitch.sh". When installed it is named "/lib/udev/usb_modeswitch".

For the context, see this thread:
http://www.draisberghof.de/usb_modeswit ... f=2&t=2329

mkkot
Posts: 8
Joined: 14 Jul 2015, 18:34

Re: Huawei E3272 aka Megafon M100-4 works but not on boot

Post by mkkot » 16 Jul 2015, 20:54

This is not as simple. I noticed today that there is 2.2.4 verion in repository so I upgraded whole system with systemd to 221. Does not work even when I reconnect physically USB plug. It doesn't work at all.

I tested then all the variants with version 2.2.4:

Code: Select all


2.2.1

esac
exec 1<&- 2<&- 5<&- 7<&-
(
count=20
while [ $count != 0 ]; do
	if [ ! -e "/usr/bin/usb_modeswitch_dispatcher" ]; then
		sleep 1
		count=$(($count - 1))
	else
		if [ -e "/etc/init/usb-modeswitch-upstart.conf" ]; then
			exec /sbin/initctl emit --no-wait usb-modeswitch-upstart UMS_PARAM=$1
		elif [ -e "/etc/systemd/system/usb_modeswitch@.service" ]; then
			exec /usr/bin/systemctl --no-block start usb_modeswitch@$1.service
		else
			exec /usr/bin/usb_modeswitch_dispatcher --switch-mode $1 &
		fi
		exit 0
	fi
done
) &
exit 0




2.2.3


esac
(
IFS='/' read -r p1 p2 <<EOF
$1
EOF
#sleep 10
PATH=/bin:/sbin:/usr/bin:/usr/sbin
count=20
while [ $count != 0 ]; do
	if [ ! -e "/usr/bin/usb_modeswitch_dispatcher" ]; then
		sleep 1
		count=$(($count - 1))
	else
		if [ -e "/etc/systemd/system/usb_modeswitch@.service" ]; then
			exec systemctl --no-block start usb_modeswitch@$p1'_'$p2.service
		elif [ -e "/etc/init/usb-modeswitch-upstart.conf" ]; then
			exec initctl emit --no-wait usb-modeswitch-upstart UMS_PARAM=$1
		else
			exec usb_modeswitch_dispatcher --switch-mode $1 &
		fi
		exit 0
	fi
done
) &
# >/dev/null 2>/dev/null
exit 0


2.2.4

esac
(
IFS='/' read -r p1 p2 <<EOF
$1
EOF
PATH=/bin:/sbin:/usr/bin:/usr/sbin
count=20
while [ $count != 0 ]; do
	if [ ! -e "/usr/bin/usb_modeswitch_dispatcher" ]; then
		sleep 1
		count=$(($count - 1))
	else
		if [ -e "/etc/systemd/system/usb_modeswitch@.service" ]; then
			exec systemctl --no-block start usb_modeswitch@$p1'_'$p2.service
		elif [ -e "/etc/init/usb-modeswitch-upstart.conf" ]; then
			exec initctl emit --no-wait usb-modeswitch-upstart UMS_PARAM=$1
		else
			exec usb_modeswitch_dispatcher --switch-mode $1 &
		fi
		exit 0
	fi
done
) &
exit 0
Neither of them works on boot with version 2.2.4...

mkkot
Posts: 8
Joined: 14 Jul 2015, 18:34

Re: Huawei E3272 aka Megafon M100-4 works but not on boot

Post by mkkot » 16 Jul 2015, 21:28

I thought you might be interested in why 2.2.4 doesn't work at all. I upgraded system to 2.2.4 now, removed /var/log/usb_modeswitch* logs, and restarted PC. New log didn't appear. I reconnected the modem and that time neither new log appeared. So there must be some udev rule problem.

Then I just downgraded to 2.2.3 and replugged the modem, log appeared and it started to work.

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

Re: Huawei E3272 aka Megafon M100-4 works but not on boot

Post by Josh » 16 Jul 2015, 23:51

There was a bad bug in 2.2.4. I've just released 2.2.5.

The official page is not yet updated, but here it is:
http://www.draisberghof.de/usb_modeswit ... .5.tar.bz2

mkkot
Posts: 8
Joined: 14 Jul 2015, 18:34

Re: Huawei E3272 aka Megafon M100-4 works but not on boot

Post by mkkot » 17 Jul 2015, 18:41

2.2.5 solves the problem for me :)
Thank you :)

BTW what is the right command to trigger switch manually?

I can see in log:
Command to be run:
usb_modeswitch -W -D -u -1 -b 1 -g 5 -v 12d1 -p 1f01 -f $flags(config)

but this doesn't work. What is the $flags variable, how to get it?

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

Re: Huawei E3272 aka Megafon M100-4 works but not on boot

Post by Josh » 17 Jul 2015, 20:58

This command is to be used within the script; it's not very useful on the command line. The "flags" variable just contains the whole text from the config file.

Drop the bus and device number - just give default vendor and product ID. Then you have the choice of using a ready-made config file with any name you give it (-c parameter), or you give the respective flags on the command line directly.

For your modem that would be
# usb_modeswitch -v 12d1 -p 1f01 -J

Run usb_modeswitch without any parameter for a very short reference. See the file REFERENCE in the data package for a more elaborate explanation.

Post Reply