Automatic Activation, Hotplug and UDEV, Configuration
Post Reply
Miklos
Posts: 1
Joined: 17 Nov 2011, 05:01

ttyUSB* not created on boot

Post by Miklos » 17 Nov 2011, 05:27

I'm having a wierd issue with ttyUSB* not being created on boots, but if I unplug/replug the device everything works fine.

Code: Select all

# cat /etc/udev/rules.d/40-usb_modeswitch.rules
ATTRS{idVendor}=="12d1", ATTRS{idProduct}=="1446", RUN+="usb_modeswitch '%b/%k'"

Code: Select all

# cat /etc/usb_modeswitch.d/12d1\:1446
########################################################
# Huawei, newer modems

DefaultVendor= 0x12d1
DefaultProduct=0x1446

TargetVendor=  0x12d1
TargetProductList="1001,1406,140b,140c,1412,141b,1433,14ac,1506"

CheckSuccess=20

MessageContent="55534243123456780000000000000011062000000100000000000000000000"
After a clean reboot:

Code: Select all

# lsusb|grep 1506
Bus 001 Device 002: ID 12d1:1506 Huawei Technologies Co., Ltd. E398 LTE/UMTS/GSM Modem/Networkcard

# ls -l /dev/ttyU*
ls: cannot access /dev/ttyU*: No such file or directory

Code: Select all

kernel: [    1.095091] usb 1-1: new high speed USB device using ehci_hcd and address 2
kernel: [    1.218520] usb 1-1: New USB device found, idVendor=12d1, idProduct=1506
kernel: [    1.218527] usb 1-1: New USB device strings: Mfr=4, Product=3, SerialNumber=0
kernel: [    1.218531] usb 1-1: Product: HUAWEI Mobile
kernel: [    1.218534] usb 1-1: Manufacturer: Huawei Technologies
kernel: [    1.218669] usb 1-1: configuration #1 chosen from 1 choice
kernel: [    1.228652] Initializing USB Mass Storage driver...
kernel: [    1.229597] scsi2 : SCSI emulation for USB Mass Storage devices
kernel: [    1.229669] usb-storage: device found at 2
kernel: [    1.229671] usb-storage: waiting for device to settle before scanning
kernel: [    1.229713] scsi3 : SCSI emulation for USB Mass Storage devices
kernel: [    1.229765] usb-storage: device found at 2
kernel: [    1.229766] usb-storage: waiting for device to settle before scanning
kernel: [    1.229782] usbcore: registered new interface driver usb-storage
kernel: [    1.229784] USB Mass Storage support registered.

kernel: [    2.331958] udev[396]: starting version 164

 kernel: [    6.228636] usb-storage: device scan complete
 kernel: [    6.229120] usb-storage: device scan complete
 kernel: [    6.229378] scsi 3:0:0:0: Direct-Access     HUAWEI   TF CARD Storage       PQ: 0 ANSI: 2
 kernel: [    6.229729] scsi 2:0:0:0: CD-ROM            HUAWEI   Mass Storage     2.31 PQ: 0 ANSI: 2
 kernel: [    6.232983] sd 3:0:0:0: [sdb] Attached SCSI removable disk
 kernel: [    6.277548] sr0: scsi-1 drive
 kernel: [    6.277551] Uniform CD-ROM driver Revision: 3.20
 kernel: [    6.277670] sr 2:0:0:0: Attached scsi CD-ROM sr0
 kernel: [    6.376480] sd 0:0:1:0: Attached scsi generic sg0 type 0
 kernel: [    6.376528] sd 3:0:0:0: Attached scsi generic sg1 type 0
 kernel: [    6.376556] sr 2:0:0:0: Attached scsi generic sg2 type 5
And this is the log when replugging (and the device works).

Code: Select all

kernel: [  706.606202] usb 1-1: USB disconnect, address 2
kernel: [  715.416017] usb 1-1: new high speed USB device using ehci_hcd and address 8
kernel: [  715.550582] usb 1-1: New USB device found, idVendor=12d1, idProduct=1446
kernel: [  715.550588] usb 1-1: New USB device strings: Mfr=3, Product=2, SerialNumber=0
kernel: [  715.550591] usb 1-1: Product: HUAWEI Mobile
kernel: [  715.550594] usb 1-1: Manufacturer: Huawei Technologies
kernel: [  715.550742] usb 1-1: configuration #1 chosen from 1 choice
kernel: [  715.570733] scsi6 : SCSI emulation for USB Mass Storage devices
kernel: [  715.570836] usb-storage: device found at 8
kernel: [  715.570838] usb-storage: waiting for device to settle before scanning
kernel: [  715.570909] scsi7 : SCSI emulation for USB Mass Storage devices
kernel: [  715.570961] usb-storage: device found at 8
kernel: [  715.570962] usb-storage: waiting for device to settle before scanning
usb_modeswitch: switching 12d1:1446 (Huawei Technologies: HUAWEI Mobile)
usb_modeswitch: switching 12d1:1446 (Huawei Technologies: HUAWEI Mobile)
usb_modeswitch: switching 12d1:1446 (Huawei Technologies: HUAWEI Mobile)
kernel: [  716.330994] usb 1-1: usbfs: process 3582 (usb_modeswitch) did not claim interface 0 before use
usb_modeswitch: switching 12d1:1446 (Huawei Technologies: HUAWEI Mobile)
usb_modeswitch: switching 12d1:1446 (Huawei Technologies: HUAWEI Mobile)
usb_modeswitch: switching 12d1:1446 (Huawei Technologies: HUAWEI Mobile)
kernel: [  716.333127] usb 1-1: USB disconnect, address 8
kernel: [  720.280026] usb 1-1: new high speed USB device using ehci_hcd and address 9
kernel: [  720.415678] usb 1-1: New USB device found, idVendor=12d1, idProduct=1506
kernel: [  720.415684] usb 1-1: New USB device strings: Mfr=4, Product=3, SerialNumber=0
kernel: [  720.415688] usb 1-1: Product: HUAWEI Mobile
kernel: [  720.415691] usb 1-1: Manufacturer: Huawei Technologies
kernel: [  720.415838] usb 1-1: configuration #1 chosen from 1 choice
kernel: [  720.434673] scsi8 : SCSI emulation for USB Mass Storage devices
kernel: [  720.434735] usb-storage: device found at 9
kernel: [  720.434737] usb-storage: waiting for device to settle before scanning
kernel: [  720.434805] scsi9 : SCSI emulation for USB Mass Storage devices
kernel: [  720.434862] usb-storage: device found at 9
kernel: [  720.434864] usb-storage: waiting for device to settle before scanning
usb_modeswitch: switched to 12d1:1506 (Huawei Technologies: HUAWEI Mobile)
usb_modeswitch: switched to 12d1:1506 (Huawei Technologies: HUAWEI Mobile)
usb_modeswitch: switched to 12d1:1506 (Huawei Technologies: HUAWEI Mobile)
usb_modeswitch: switched to 12d1:1506 (Huawei Technologies: HUAWEI Mobile)
usb_modeswitch: switched to 12d1:1506 (Huawei Technologies: HUAWEI Mobile)
usb_modeswitch: switched to 12d1:1506 (Huawei Technologies: HUAWEI Mobile)
kernel: [  721.952824] usbcore: registered new interface driver usbserial
kernel: [  721.953041] USB Serial support registered for generic
kernel: [  721.953255] usbcore: registered new interface driver usbserial_generic
kernel: [  721.953257] usbserial: USB Serial Driver core
logger: usb_modeswitch: adding device ID 12d1:1506 to driver "option"
logger: usb_modeswitch: adding device ID 12d1:1506 to driver "option"
kernel: [  721.986088] USB Serial support registered for GSM modem (1-port)
kernel: [  721.986359] usbcore: registered new interface driver option
kernel: [  721.986361] option: v0.7.2:USB Driver for GSM modems
kernel: [  721.993551] option 1-1:1.0: GSM modem (1-port) converter detected
kernel: [  721.993687] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB0
kernel: [  721.993721] option 1-1:1.1: GSM modem (1-port) converter detected
kernel: [  721.993772] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB1
kernel: [  721.993801] option 1-1:1.2: GSM modem (1-port) converter detected
kernel: [  721.993845] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB2
kernel: [  721.993876] option 1-1:1.3: GSM modem (1-port) converter detected
kernel: [  721.993920] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB3
kernel: [  721.994092] option 1-1:1.4: GSM modem (1-port) converter detected
kernel: [  721.994251] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB4
logger: usb_modeswitch: adding device ID 12d1:1506 to driver "option"
logger: usb_modeswitch: adding device ID 12d1:1506 to driver "option"
logger: usb_modeswitch: adding device ID 12d1:1506 to driver "option"
logger: usb_modeswitch: adding device ID 12d1:1506 to driver "option"
kernel: [  725.433176] usb-storage: device scan complete
kernel: [  725.434279] usb-storage: device scan complete
kernel: [  725.434535] scsi 8:0:0:0: CD-ROM            HUAWEI   Mass Storage     2.31 PQ: 0 ANSI: 2
kernel: [  725.436043] scsi 9:0:0:0: Direct-Access     HUAWEI   TF CARD Storage       PQ: 0 ANSI: 2
kernel: [  725.441513] sr0: scsi-1 drive
kernel: [  725.441696] sr 8:0:0:0: Attached scsi CD-ROM sr0
kernel: [  725.441801] sr 8:0:0:0: Attached scsi generic sg1 type 5
kernel: [  725.442719] sd 9:0:0:0: Attached scsi generic sg2 type 0
kernel: [  725.449923] sd 9:0:0:0: [sdb] Attached SCSI removable disk

Code: Select all

# ls -l /dev/ttyU*
crw-rw---- 1 root dialout 188, 0 Nov 17 03:21 /dev/ttyUSB0
crw-rw---- 1 root dialout 188, 1 Nov 17 03:21 /dev/ttyUSB1
crw-rw---- 1 root dialout 188, 2 Nov 17 03:21 /dev/ttyUSB2
crw-rw---- 1 root dialout 188, 3 Nov 17 03:21 /dev/ttyUSB3
crw-rw---- 1 root dialout 188, 4 Nov 17 03:21 /dev/ttyUSB4
Problem is I need this to work on boot as well as replugging living in a country where power supply is very shady I need it to come up on itself 8)

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

Post by Josh » 18 Nov 2011, 15:01

What's your usb_modeswitch version?

bo538
Posts: 4
Joined: 18 Jan 2012, 17:56

Same problem

Post by bo538 » 18 Jan 2012, 18:02

Hello,

I have the same problem.
I use Centos 6.2 and usb_modeswitch 1.2.1 with database date 20111023.

When I boot my system first and then plugin the huawei modem, the ttyUSB ports are created. However when I then reboot my system the ports are gone.

After a reboot the lsusb command shows the modem is already switched. It shows 12d1:1506
Last edited by bo538 on 20 Jan 2012, 09:30, edited 1 time in total.

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

Post by Josh » 19 Jan 2012, 23:08

bo538, are you using the source from this site or do you have an RPM package (probably from Fedora)?

This is important because the Fedora package is incomplete and therefore flawed.


bo538
Posts: 4
Joined: 18 Jan 2012, 17:56

Post by bo538 » 20 Jan 2012, 09:28

Hi Josh,

Thanx for your response. No I do not use an RPM package. I downloaded and installed the program and dbase myself from this site.

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

Post by Josh » 20 Jan 2012, 12:52

It's logical that the modem is still switched after a reboot; if you don't unplug it, it stays powered and holds its mode (which is independent of the operating system).

However, the driver should be re-bound by the udev rules of usb_modeswitch after a warm reboot, creating the ttyUSB ports again.

Can you check the folder "/var/lib/usb_modeswitch" and see if the "12d1:1506" ID is listed in the files there?


bo538
Posts: 4
Joined: 18 Jan 2012, 17:56

Post by bo538 » 20 Jan 2012, 13:21

I understand that is logical and as designed by huawei.
Like you say I was expecting a re-bound by udev.

In /var/lib/usb_modeswitch both bind_list and link_list have one line with "12d1:1506".

Thanx for your quick response!

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

Post by Josh » 20 Jan 2012, 20:23

Hmm, then we have to look at /lib/udev/usb_modeswitch which is a small shell script responsible for some wrapping plus the reloading and rebinding of the 3G modem driver.

It is called after rebooting by this udev rule (for USB and any "add/change" event):

ATTR{bInterfaceClass}=="ff", ATTR{bInterfaceNumber}=="00", ATTRS{bNumConfigurations}=="*", RUN+="usb_modeswitch --driver-bind %p %s{idVendor} %s{idProduct} %E{PRODUCT}"

The rule itself may trigger for all kinds of unrelated devices. The point of the "check list" in
"/var/lib/usb_modeswitch" is to make sure only a device that was handled by usb_modeswitch before is touched.

Since your device is indeed in the list, it should be treated. And it obviously is, at least upon plugin, because the same rule is taking care of the driver binding then.

If this very thing fails to happen during boot, there is a number of possible causes:

- the parameters (all those bits starting with % in the rule) are not good or incomplete
- the "check list" is not readable during boot
- the udev rule is not even triggered at all (less likely)

You can add all kinds of tests and outputs ("echo") to the little script. Unfortunately, the catching of any output may be tricky during boot because the file system may not be writable yet. So you can't be sure that redirecting output to a file will work. You can try redirecting to the console but that may just zip by unless you are able to catch it (e.g. by using a serial console from a second machine, which is what I did for testing).

The third possibility can be tested by setting udev to debug mode. It's easy: edit "/etc/udev/udev.conf" and set "udev_log" to "debug". It results in a lot of syslog output which you can search (after rebooting) for "usb_modeswitch".

If you think this issue is worth all the hassle, I'd be delighted. You can try other work-arounds though, like adding a little script to your boot process (look for "rc.local" in the /etc tree) which loads the "option" module and your modem ID at every boot:

Code: Select all

...
modprobe -v option
echo "12d1 1506" > /sys/bus/usb-serial/drivers/option1/new_id
...

bo538
Posts: 4
Joined: 18 Jan 2012, 17:56

Post by bo538 » 21 Jan 2012, 17:37

Hi Josh, Thanks again for the response.

The two lines of code definitely work and I can put them in the rc.local.
This wil fix my problem but it's not the nicest solution.

So I rebooted with udev debug on. I searched for "usb_modeswitch" but there are no matches dating after the reboot.

It looks like option three is the problem, the udev rule is not triggered at all.

Do you have any suggestions?

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

Post by Josh » 21 Jan 2012, 19:34

There is still the possibility that the first triggered RUN of usb_modeswitch is not logged during boot because syslog is not up yet at that moment.

As I said, debugging that boot process is a pain. The best way to catch every system message is to connect a second computer via null modem cable, and then use any terminal program (I chose PuTTY) to capture the complete boot output.

See http://tldp.org/HOWTO/Remote-Serial-Con ... o-why.html

Apart from that specific page, you basically need only Chapter 5 of this Howto.


Post Reply