Activation Codes and Methods, Hardware Details, Sniffing
Post Reply
Stofferl
Posts: 6
Joined: 06 Dec 2016, 01:40

Huawei E3531 manual switch works, but not automatic

Post by Stofferl » 06 Dec 2016, 02:12

Hello!


I am working with a rapsberry pi and the latest raspbian version.

The first try i made on a raspberry, that i don't have now, but it worked then.
The new try with the same E3531 on a different raspi does not work automatically.
My problem is, that the manual switch works perfect, but when i create a rule, it disconnects the ttyUSB0 at reboot.

I am quite a linux noob, but its getting better. :-)

My knowledge is from there https://wiki.ubuntuusers.de/USB_ModeSwitch/

This are the steps, that worked on the other raspi, but not on this one i have:

Manual Switch

Code: Select all

sudo usb_modeswitch -v 12d1 -p 15ca -M '55534243123456780000000000000011062000000100000000000000000000'

Rules in /etc/udev/rules.d/70-usb-modeswitch.rules

Code: Select all

ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="15ca", RUN+="/usr/sbin/usb_modeswitch -v 12d1 -p 15ca -M '55534243123456780000000000000011062000000100000000000000000000'"
ACTION=="add", SUBSYSTEM=="usb", ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="1506", RUN+="/bin/bash -c 'modprobe option && echo 12d1 1506 > /sys/bus/usb-serial/drivers/option1/new_id'"
After a reboot it worked on the old one.



So here is a compare between the manual and the auto mode:

Before manual:

Code: Select all

$ lsusb
Bus 001 Device 004: ID 12d1:15ca Huawei Technologies Co., Ltd.
After manual

Code: Select all

$ lsusb
Bus 001 Device 005: ID 12d1:1506 Huawei Technologies Co., Ltd. E398 LTE/UMTS/GSM Modem/Networkcard

Code: Select all

$ ifconfig
Gives back a wwan0 interface.

Code: Select all

$ ls -la /dev/ttyUSB*
crw-rw---- 1 root dialout 188, 0 Dez  6 00:26 /dev/ttyUSB0
crw-rw---- 1 root dialout 188, 1 Dez  6 00:28 /dev/ttyUSB1
crw-rw---- 1 root dialout 188, 2 Dez  6 00:26 /dev/ttyUSB2

Code: Select all

$ dmesg | grep USB
[    2.517289] dwc_otg 20980000.usb: new USB bus registered, assigned bus number 1
[    2.548256] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
[    2.557786] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    2.591823] hub 1-0:1.0: USB hub found
[    2.779382] usbhid: USB HID core driver
[    3.053906] usb 1-1: new high-speed USB device number 2 using dwc_otg
[    3.294434] usb 1-1: New USB device found, idVendor=0424, idProduct=9514
[    3.304234] usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[    3.318992] hub 1-1:1.0: USB hub found
[    3.613932] usb 1-1.1: new high-speed USB device number 3 using dwc_otg
[    3.714442] usb 1-1.1: New USB device found, idVendor=0424, idProduct=ec00
[    3.724842] usb 1-1.1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[    3.843337] smsc95xx 1-1.1:1.0 eth0: register 'smsc95xx' at usb-20980000.usb-1.1, smsc95xx USB 2.0 Ethernet, b8:27:eb:be:25:ce
[    8.633910] usb 1-1.5: new high-speed USB device number 4 using dwc_otg
[    8.735792] usb 1-1.5: New USB device found, idVendor=12d1, idProduct=15ca
[    8.735834] usb 1-1.5: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[    8.815769] usb-storage 1-1.5:1.0: USB Mass Storage device detected
[  206.315621] usb 1-1.5: USB disconnect, device number 4
[  206.556509] usb 1-1.5: new high-speed USB device number 5 using dwc_otg
[  206.658589] usb 1-1.5: New USB device found, idVendor=12d1, idProduct=1506
[  206.658628] usb 1-1.5: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[  206.767159] usb-storage 1-1.5:1.4: USB Mass Storage device detected
[  206.769263] usb-storage 1-1.5:1.5: USB Mass Storage device detected
[  206.902181] usbserial: USB Serial support registered for generic
[  206.970298] usbserial: USB Serial support registered for GSM modem (1-port)
[  206.990893] huawei_cdc_ncm 1-1.5:1.1: cdc-wdm0: USB WDM device
[  207.015586] usb 1-1.5: GSM modem (1-port) converter now attached to ttyUSB0
[  207.029740] usb 1-1.5: GSM modem (1-port) converter now attached to ttyUSB1
[  207.049727] usb 1-1.5: GSM modem (1-port) converter now attached to ttyUSB2



With the rules i wrote previously, i get this now:

Code: Select all

$ lsusb
Bus 001 Device 005: ID 12d1:1506 Huawei Technologies Co., Ltd. E398 LTE/UMTS/GSM Modem/Networkcard

Code: Select all

$ dmesg | grep USB
[    2.514613] dwc_otg 20980000.usb: new USB bus registered, assigned bus number 1
[    2.545595] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
[    2.555067] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    2.589083] hub 1-0:1.0: USB hub found
[    2.779528] usbhid: USB HID core driver
[    3.053998] usb 1-1: new high-speed USB device number 2 using dwc_otg
[    3.264657] usb 1-1: New USB device found, idVendor=0424, idProduct=9514
[    3.274572] usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[    3.288599] hub 1-1:1.0: USB hub found
[    3.584028] usb 1-1.1: new high-speed USB device number 3 using dwc_otg
[    3.714482] usb 1-1.1: New USB device found, idVendor=0424, idProduct=ec00
[    3.724918] usb 1-1.1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[    3.822405] smsc95xx 1-1.1:1.0 eth0: register 'smsc95xx' at usb-20980000.usb-1.1, smsc95xx USB 2.0 Ethernet, b8:27:eb:be:25:ce
[    8.604049] usb 1-1.5: new high-speed USB device number 4 using dwc_otg
[    8.705808] usb 1-1.5: New USB device found, idVendor=12d1, idProduct=15ca
[    8.705851] usb 1-1.5: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[    8.795778] usb-storage 1-1.5:1.0: USB Mass Storage device detected
[   11.443224] usb 1-1.5: USB disconnect, device number 4
[   11.684047] usb 1-1.5: new high-speed USB device number 5 using dwc_otg
[   11.785693] usb 1-1.5: New USB device found, idVendor=12d1, idProduct=1506
[   11.785735] usb 1-1.5: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[   11.851307] usb-storage 1-1.5:1.4: USB Mass Storage device detected
[   11.858539] usb-storage 1-1.5:1.5: USB Mass Storage device detected
[   11.985489] usbserial: USB Serial support registered for generic
[   12.015383] usbserial: USB Serial support registered for GSM modem (1-port)
[   12.019978] usb 1-1.5: GSM modem (1-port) converter now attached to ttyUSB0
[   12.022822] usb 1-1.5: GSM modem (1-port) converter now attached to ttyUSB1
[   12.034826] usb 1-1.5: GSM modem (1-port) converter now attached to ttyUSB2
[   15.948696] option1 ttyUSB0: GSM modem (1-port) converter now disconnected from ttyUSB0

Code: Select all

$ ls -la /dev/ttyUSB*
crw-rw---- 1 root dialout 188, 1 Dez  6 00:28 /dev/ttyUSB1
crw-rw---- 1 root dialout 188, 2 Dez  6 00:26 /dev/ttyUSB2

And no wwan0 inteface.
I don't need the wwan0, i only want to send SMS, but this also doesn't works.

Why does the ttyUSB0 disconnect?
What could be the problem here, i would be very happy for any hints!

Greetings, Stofferl.

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

Re: Huawei E3531 manual switch works, but not automatic

Post by Josh » 06 Dec 2016, 09:22

Need to clarify some things:

The file "/etc/udev/rules.d/70-usb-modeswitch.rules" - did you install that manually or did it come installed with the distribution?

In this very file, is there a 'generic' Huawei rule somewhere above all the device rules?

That generic rule has been in the original usb-modeswitch-data package for quite a while now. It would likely trigger before your rule.

Anyway, to use a custom switching method, you don't have to touch the 'rules' file at all.

Just put a custom config file into /etc/usb_modeswitch.d. In your case, the name of the file should be "12d1:15ca". You can put in there any 'MessageContent' that you like, and there will be no conflict regarding udev rules.
The "usb_modeswitch_dispatcher" will prefer the custom configuration file over the 'stock' file that comes with the usb-modeswitch-data package.

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

Re: Huawei E3531 manual switch works, but not automatic

Post by Josh » 06 Dec 2016, 09:40

Addendum:

Some bits in the Ubuntu-Wiki are outdated or plainly incorrect, especially the advice to run the binary program directly from the "rules" file.

Again: new or customized configurations is what "/etc/usb_modeswitch.d" is for.

LOM
Posts: 1404
Joined: 11 Jul 2012, 15:14
Location: Koh Samui, TH

Re: Huawei E3531 manual switch works, but not automatic

Post by LOM » 06 Dec 2016, 12:25

Stofferl wrote:
Why does the ttyUSB0 disconnect?
What could be the problem here, i would be very happy for any hints!
Most likely because you have added an udev rule for using the option drivers new_id function while the dongle already is supported within the driver.

Stofferl
Posts: 6
Joined: 06 Dec 2016, 01:40

Re: Huawei E3531 manual switch works, but not automatic

Post by Stofferl » 06 Dec 2016, 13:49

Hello!

The file "/etc/udev/rules.d/70-usb-modeswitch.rules" was empty, the two rules i wrote are the only entrys.

After posting my problem, i had found out, that the Raspbian version of usb_modeswitch is 2.2.0, so it is over 2,5 years old!!

I don't know if such old software repositorys are usual in the linux world, but i am wondering much.
Like i said before, i am almost a Linux noob and i thought there is everything better in this universe. ;-)

So i think, before we investigate my problem, i should upgrade to the newest version.
But can i be sure, that the "apt-get update" will not make any problems, when there is a much higher version installed as in the raspbian online repository exists?
Can i update the repository list to an actual link for this one software, or does it make no troubles for apt-get, when newer software is installed?

Greetings, Stofferl.

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

Re: Huawei E3531 manual switch works, but not automatic

Post by Josh » 06 Dec 2016, 14:36

Stofferl wrote:The file "/etc/udev/rules.d/70-usb-modeswitch.rules" was empty, the two rules i wrote are the only entrys.
That's weird. There should be a 'populated' rules file from the usb-modeswitch-data package. Are you sure that there is no 40-usb-modeswitch.rules file in the rules folder?

Can you also check if you have the "usb_modeswitch_dispatcher" file installed?

Let's make sure that you have a complete installation first, however old.

Stofferl
Posts: 6
Joined: 06 Dec 2016, 01:40

Re: Huawei E3531 manual switch works, but not automatic

Post by Stofferl » 06 Dec 2016, 22:11

Hi!

The file "40-usb_modeswitch.rules" is under "/lib/udev/rules.d" and not under "/etc/udev/rules.d" where i put the "70-usb-modeswitch.rules" file.
The "40-usb_modeswitch.rules" does not contain de ID of my device.

/usr/sbin/usb_modeswitch_dispatcher is installed.

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

Re: Huawei E3531 manual switch works, but not automatic

Post by Josh » 07 Dec 2016, 09:39

Stofferl wrote:The "40-usb_modeswitch.rules" does not contain de ID of my device.
Not explicitely, but it contains the generic Huawei rule that will trigger with your modem:

Code: Select all

ATTRS{idVendor}=="12d1", ATTR{bInterfaceNumber}=="00", ATTR{bInterfaceClass}=="08" ...
This rule will match on all USB devices with the Huawei vendor ID which also have interface class 8 on interface 0. That's basically all Huawei devices in storage (driver install) mode.

Remove your custom rules file and put a custom config file in the folder "/etc/usb_modeswitch.d".
The custom file has the name "12d1:15ca". This is the content:

Code: Select all

TargetVendor=0x12d1
TargetProduct=0x1506
HuaweiNewMode=1

Stofferl
Posts: 6
Joined: 06 Dec 2016, 01:40

Re: Huawei E3531 manual switch works, but not automatic

Post by Stofferl » 07 Dec 2016, 13:00

Hello!

It seems that this also don't work.
I removed the old rule, created the new one "/etc/usb_modeswitch.d/12d1:15ca" with the content you wrote.
But after reboot the system only has this device:

Code: Select all

$ lsusb
Bus 001 Device 004: ID 12d1:15ca Huawei Technologies Co., Ltd.

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

Re: Huawei E3531 manual switch works, but not automatic

Post by Josh » 07 Dec 2016, 13:27

To see what exactly usb_modeswitch is doing, enable logging in "/etc/usb_modeswitch.conf".

Then re-plug the modem, and after a while have a look into the folder "/var/log".

Stofferl
Posts: 6
Joined: 06 Dec 2016, 01:40

Re: Huawei E3531 manual switch works, but not automatic

Post by Stofferl » 07 Dec 2016, 15:45

OK, i have enabled logging, but i can't replug the device, because i am accessing remotely.

Rebooting the raspi doesn't create a log file.

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

Re: Huawei E3531 manual switch works, but not automatic

Post by Josh » 07 Dec 2016, 18:15

Stofferl wrote:OK, i have enabled logging, but i can't replug the device, because i am accessing remotely.
Ah, that's not the best situation for testing ... It would be better to actually initialize the stick. It may arrive in an undefined state after all those experiments.

Maybe there is a way to toggle the USB power? That would help by initializing the stick. A reboot does not help as long as it doesn't cut power to the modem.

Stofferl
Posts: 6
Joined: 06 Dec 2016, 01:40

Re: Huawei E3531 manual switch works, but not automatic

Post by Stofferl » 09 Dec 2016, 01:30

Hi!

The Raspberry Pi does cut the USB power for a few seconds on a reboot, so that was not the solution.

I have changed the Raspi to a newer one now.
The first testing pi was a pi3, the not working a pi1 B+ and now i used another pi3.
The OS was on every pi the latest Raspbian Distro.

I treid first your way with the "/etc/usb_modeswitch.d/12d1:15ca" file, but this doesn't work.
Also enabling the Logging had no effect, the logfile was never created.

So i decided to try it with my first solution, to create the file "/etc/udev/rules.d/70-usb-modeswitch.rules" and the content.

And it works.

It don't make the wwan0 device, but i don't need it.


Maybe the problem was only the old version, that the Raspbian repositories use.

I think i will not update to the new version, because it's running and i don't know what will happen, if the version is higher than in the repository.
Do you know how linux acts in such a case?


But thank you very much for your help and effort!

Nice greetings, Stofferl.

Post Reply