Automatic Activation, Hotplug and UDEV, Configuration
Post Reply
styxxx
Posts: 1
Joined: 28 Jul 2017, 05:49

Automatic usb_modeswitch sometimes works - sometimes doesn't

Post by styxxx » 28 Jul 2017, 06:43

Hi,

as the topic states I've the strange problem that usb_modeswitch behaves unpredictable.

I've an Alcatel X602D usb modem (Vendor=1bbb ProdID=022c) and an raspberry pi (with the latest Raspbian Jessie updates and Linux 4.9.35-v7+). According to Debian's usb-modeswitch-data changelog the modem is supported since version 20150115-1 (which I have installed).

Installed packages:

Code: Select all

$ dpkg -l | grep usb-modeswitch
ii  usb-modeswitch                 2.2.0+repack0-2                  armhf        mode switching tool for controlling "flip flop" USB devices
ii  usb-modeswitch-data            20150115-1                       all          mode switching data for usb-modeswitch
Now according to dmesg and /var/log/messages usb_modeswitch sometimes kicks in and sometimes doesn't on reboots. It mostly doesn't.

As a secondary problem no log files are created, although I set it in the config file /etc/usb_modeswitch.conf. It's only content is
DisableSwitching=0
EnableLogging=1
Most of the time I get the following output for "dmesg -T":
[Fr Jul 28 06:04:51 2017] usb 1-1.2: new high-speed USB device number 4 using dwc_otg
[Fr Jul 28 06:04:51 2017] usb 1-1.2: New USB device found, idVendor=1bbb, idProduct=022c
[Fr Jul 28 06:04:51 2017] usb 1-1.2: New USB device strings: Mfr=2, Product=1, SerialNumber=0
[Fr Jul 28 06:04:51 2017] usb 1-1.2: Product: HSPA+ USB Modem
[Fr Jul 28 06:04:51 2017] usb 1-1.2: Manufacturer: Spreadtrum
[Fr Jul 28 06:04:51 2017] usb-storage 1-1.2:1.0: USB Mass Storage device detected
[Fr Jul 28 06:04:51 2017] scsi host0: usb-storage 1-1.2:1.0
"usb-devices" then says as expected:
T: Bus=01 Lev=02 Prnt=02 Port=01 Cnt=02 Dev#= 4 Spd=480 MxCh= 0
D: Ver= 2.00 Cls=ef(misc ) Sub=02 Prot=01 MxPS=64 #Cfgs= 2
P: Vendor=1bbb ProdID=022c Rev=00.00
S: Manufacturer=Spreadtrum
S: Product=HSPA+ USB Modem
C: #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=250mA
I: If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage
Only sometimes the following happens:
dmesg:
[Fr Jul 28 04:38:24 2017] usb 1-1.2: new high-speed USB device number 4 using dwc_otg
[Fr Jul 28 04:38:24 2017] usb 1-1.2: New USB device found, idVendor=1bbb, idProduct=022c
[Fr Jul 28 04:38:24 2017] usb 1-1.2: New USB device strings: Mfr=2, Product=1, SerialNumber=0
[Fr Jul 28 04:38:24 2017] usb 1-1.2: Product: HSPA+ USB Modem
[Fr Jul 28 04:38:24 2017] usb 1-1.2: Manufacturer: Spreadtrum
[Fr Jul 28 04:38:24 2017] usb-storage 1-1.2:1.0: USB Mass Storage device detected
[Fr Jul 28 04:38:24 2017] scsi host0: usb-storage 1-1.2:1.0
[Fr Jul 28 04:38:24 2017] usb 1-1.2: usbfs: interface 0 claimed by usb-storage while 'usb_modeswitch' sets config #2
usb-devices:
T: Bus=01 Lev=02 Prnt=02 Port=01 Cnt=02 Dev#= 4 Spd=480 MxCh= 0
D: Ver= 2.00 Cls=ef(misc ) Sub=02 Prot=01 MxPS=64 #Cfgs= 2
P: Vendor=1bbb ProdID=022c Rev=00.00
S: Manufacturer=Spreadtrum
S: Product=HSPA+ USB Modem
C: #Ifs= 4 Cfg#= 2 Atr=80 MxPwr=200mA
I: If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=(none)
I: If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=(none)
I: If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=(none)
I: If#= 3 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=(none)
Should look that way all the time. As the dmesg-output shows the hardware is always recognized with the correct vendor and product IDs. So it doesn't make sense that sometimes usb_modeswitch get triggered and sometimes doesn't. And even if my modeswitch-data package was too old it still should work with the configs I made.

To make sure I already tried writing my own rules in in /lib/udev/rules.d/40-usb_modeswitch.rules like
ATTRS{idVendor}=="1bbb", ATTRS{idProduct}=="022c", RUN+="usb_modeswitch '%b/%k'"

and other variations with no effect.

I also created /etc/usb_modeswitch.d/1bbb:022c with
#Alcatel X602D
Configuration=2
But it still doesn't work every time.
Then I tried to make init-scripts to execute usb_modeswitch this way, but I might have been to stupid for that. :roll:

I'm aware that even if usb_modeswitch works I still have to load the correct drivers via modprobe. But I'm mostly not even getting this far (also I'd like to make this an automatic task - maybe via 40-usb_modeswitch.rules? But one step at a time).

Manually executing usb_modeswitch seems to work btw. But still no logfiles and I don't know why.

Might this be a bug in this version? Seems to be a bit old. I could try later versions but the jessie repository only has this one.

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

Re: Automatic usb_modeswitch sometimes works - sometimes doe

Post by Josh » 28 Jul 2017, 14:16

This is indeed an open issue:

Code: Select all

[Fr Jul 28 04:38:24 2017] usb 1-1.2: usbfs: interface 0 claimed by usb-storage while 'usb_modeswitch' sets config #2
I will provide a test version this weekend to work around it.

Do you get a usb_modeswitch log when you connect the modem after boot-up? (You won't get any when using usb_modeswitch on the command line, but you can enable verbose output with -W)

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

Re: Automatic usb_modeswitch sometimes works - sometimes doe

Post by Josh » 30 Jul 2017, 13:59

So here you go - check out the test version:
http://www.draisberghof.de/usb_modeswit ... 195#p18195

If that doesn't solve your problem, we will investigate further.

saferot
Posts: 2
Joined: 31 Aug 2023, 02:16
Contact:

Re: Automatic usb_modeswitch sometimes works - sometimes doesn't

Post by saferot » 31 Aug 2023, 02:21

styxxx wrote: 28 Jul 2017, 06:43 Hi,

as the topic states I've the strange problem that usb_modeswitch behaves unpredictable.

I've an Alcatel X602D usb modem (Vendor=1bbb ProdID=022c) and an raspberry pi (with the latest Raspbian Jessie updates and Linux 4.9.35-v7+). According to Debian's usb-modeswitch-data changelog the modem is supported since version 20150115-1 (which I have installed).

Installed packages:

Code: Select all

$ dpkg -l | grep usb-modeswitch
ii  usb-modeswitch                 2.2.0+repack0-2                  armhf        mode switching tool for controlling "flip flop" USB devices
ii  usb-modeswitch-data            20150115-1                       all          mode switching data for usb-modeswitch
Now according to dmesg and /var/log/messages usb_modeswitch sometimes kicks in and sometimes doesn't on reboots. It mostly doesn't.

As a secondary problem no log files are created, although I set it in the config file /etc/usb_modeswitch.conf. It's only content is
DisableSwitching=0
EnableLogging=1
Most of the time I get the following output for "dmesg -T":
[Fr Jul 28 06:04:51 2017] usb 1-1.2: new high-speed USB device number 4 using dwc_otg
[Fr Jul 28 06:04:51 2017] usb 1-1.2: New USB device found, idVendor=1bbb, idProduct=022c
[Fr Jul 28 06:04:51 2017] usb 1-1.2: New USB device strings: Mfr=2, Product=1, SerialNumber=0
[Fr Jul 28 06:04:51 2017] usb 1-1.2: Product: HSPA+ USB Modem
[Fr Jul 28 06:04:51 2017] usb 1-1.2: Manufacturer: Spreadtrum
[Fr Jul 28 06:04:51 2017] usb-storage 1-1.2:1.0: USB Mass Storage device detected
[Fr Jul 28 06:04:51 2017] scsi host0: usb-storage 1-1.2:1.0
"usb-devices" then says as expected:
T: Bus=01 Lev=02 Prnt=02 Port=01 Cnt=02 Dev#= 4 Spd=480 MxCh= 0
D: Ver= 2.00 Cls=ef(misc ) Sub=02 Prot=01 MxPS=64 #Cfgs= 2
P: Vendor=1bbb ProdID=022c Rev=00.00
S: Manufacturer=Spreadtrum
S: Product=HSPA+ USB Modem
C: #Ifs= 1 Cfg#= 1 Atr=80 MxPwr=250mA
I: If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage
Only sometimes the following happens:
dmesg:
[Fr Jul 28 04:38:24 2017] usb 1-1.2: new high-speed USB device number 4 using dwc_otg
[Fr Jul 28 04:38:24 2017] usb 1-1.2: New USB device found, idVendor=1bbb, idProduct=022c
[Fr Jul 28 04:38:24 2017] usb 1-1.2: New USB device strings: Mfr=2, Product=1, SerialNumber=0
[Fr Jul 28 04:38:24 2017] usb 1-1.2: Product: HSPA+ USB dreadhead parkour Modem
[Fr Jul 28 04:38:24 2017] usb 1-1.2: Manufacturer: Spreadtrum
[Fr Jul 28 04:38:24 2017] usb-storage 1-1.2:1.0: USB Mass Storage device detected
[Fr Jul 28 04:38:24 2017] scsi host0: usb-storage 1-1.2:1.0
[Fr Jul 28 04:38:24 2017] usb 1-1.2: usbfs: interface 0 claimed by usb-storage while 'usb_modeswitch' sets config #2
usb-devices:
T: Bus=01 Lev=02 Prnt=02 Port=01 Cnt=02 Dev#= 4 Spd=480 MxCh= 0
D: Ver= 2.00 Cls=ef(misc ) Sub=02 Prot=01 MxPS=64 #Cfgs= 2
P: Vendor=1bbb ProdID=022c Rev=00.00
S: Manufacturer=Spreadtrum Jumping Shell
S: Product=HSPA+ USB Modem
C: #Ifs= 4 Cfg#= 2 Atr=80 MxPwr=200mA
I: If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=(none)
I: If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=(none)
I: If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=(none)
I: If#= 3 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=00 Prot=00 Driver=(none)
Should look that way all the time. As the dmesg-output shows the hardware is always recognized with the correct vendor and product IDs. So it doesn't make sense that sometimes usb_modeswitch get triggered and sometimes doesn't. And even if my modeswitch-data package was too old it still should work with the configs I made.

To make sure I already tried writing my own rules in in /lib/udev/rules.d/40-usb_modeswitch.rules like
ATTRS{idVendor}=="1bbb", ATTRS{idProduct}=="022c", RUN+="usb_modeswitch '%b/%k'"

and other variations with no effect.

I also created /etc/usb_modeswitch.d/1bbb:022c with
#Alcatel X602D monkey mart
Configuration=2
But it still doesn't work every time.
Then I tried to make init-scripts to execute usb_modeswitch this way, but I might have been to stupid for that. :roll:

I'm aware that even if usb_modeswitch works I still have to load the correct drivers via modprobe. But I'm mostly not even getting this far (also I'd like to make this an automatic task - maybe via 40-usb_modeswitch.rules? But one step at a time).

Manually executing usb_modeswitch seems to work btw. But still no logfiles and I don't know why.

Might this be a bug in this version? Seems to be a bit old. I could try later versions but the jessie repository only has this one.


Seems like quite the technical challenge with usb_modeswitch and the Alcatel modem. Some intermittent behavior there. Have you considered reaching out to the Raspberry Pi or Linux community for insights? Collaborating might shed light on this tricky issue. Good luck getting it sorted!

jeffreestar
Posts: 5
Joined: 16 Nov 2023, 04:52

Re: Automatic usb_modeswitch sometimes works - sometimes doesn't

Post by jeffreestar » 30 Jan 2024, 05:13

Ensure that your custom udev rule is correctly formatted and placed in the right directory. You can use udevadm test /sys/bus/usb/devices/<device> to simulate how udev would handle the device and check if your rule matches.


slice master

Post Reply