Page 1 of 1

GSM modem and USB serial port issue with UDEV

Posted: Thu Apr 21, 2016 9:22 am
by spoonzw
Been struggling with this for 2 days and cant seem to get around it. I have 2 devices 1) Dlink DWM-157 3g modem and 2) Trendnet TU-S9 usb to serial. The dlink modem came with a udev script which works fine when the usb-to-serial is NOT plugged in from boot. So if the modem is on its own from boot, it works and is assigned /dev/ttyUSB0-3 (3 devices) if you plug in the usb-to-serial after boot then its assigned /dev/ttyUSB4 and everything works fine. The minute you reboot with them both plugged in the modem does not come up and the usb-to-serial then takes /dev/ttyUSB0.

I have had a look at the udev script and i cant see whats wrong. I have tried all forms of variants including trying to get this script to run first before the usb-to-serial, blacklisting the usb-serial, renaming the ports etc. I even thought it maybe a power issue and tried a external powered hub.

Here is the UDEV script that came with the modem.

Code: Select all

ACTION!="add", GOTO="end"
ATTRS{idVendor}=="2001",ATTRS{idProduct}=="7600",GOTO="begin"
GOTO="end"

LABEL="begin"
KERNEL=="sr*", GOTO="switch"
SUBSYSTEM=="usb",GOTO="modprobe"
KERNEL=="ttyUSB*", SUBSYSTEMS=="usb",ATTRS{bInterfaceProtocol}=="00",GOTO="symlink"
GOTO="end"

LABEL="switch"
ATTRS{bNumInterfaces}==" 1",RUN+="/usr/sbin/usb_modeswitch -V 0x2001 -P 0x7600 -v 0x2001 -p 0x7600 -u 2"
GOTO="end"


LABEL="modprobe"
ATTRS{bNumInterfaces}!=" 1", RUN+="/sbin/modprobe usbserial vendor=0x2001 product=0x7600"
GOTO="end"


LABEL="symlink"
ATTRS{bInterfaceNumber}=="00", SYMLINK:="ttyUSB_sprd_extension"
ATTRS{bInterfaceNumber}=="01", SYMLINK:="ttyUSB_sprd_modem"
ATTRS{bInterfaceNumber}=="02", SYMLINK:="ttyUSB_sprd_control"
ATTRS{bInterfaceNumber}=="04", SYMLINK:="ttyUSB_sprd_service"
GOTO="end"

LABEL="end"
Its really strange how this is acting. Both devices hate each other :)

Any pointers would be hugely appreciated

thanks

Re: GSM modem and USB serial port issue with UDEV

Posted: Thu Apr 21, 2016 1:21 pm
by Aydan
Could you please provide the output of dmesg after plugging in first the usb serial and then the 3g modem?

do:

Code: Select all

dmesg -c
plugin serial
plugin 3g modem

Code: Select all

dmesg
also:

Code: Select all

ls /dev/ttyUSB_sprd_*
The udev rule file doesn't look as if it souldn't work with other ttyUSB devices attached.

Regards
Aydan

Re: GSM modem and USB serial port issue with UDEV

Posted: Thu Apr 21, 2016 4:37 pm
by spoonzw
Hi Ayden

Thanks for the reply. I also thought that the usb-to-serial adapter was being matched by the dlink script but i could not see how as the Dlink script has both vendor and device ids to match.

Please see the outputs as requested:

dmesg -c after plugging in the usb-to-serial

Code: Select all

root@blunap:/home/pi# dmesg -c
[  245.374818] usb 1-1.3: new full-speed USB device number 5 using dwc_otg
[  245.477107] usb 1-1.3: New USB device found, idVendor=067b, idProduct=2303
[  245.477134] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[  245.477152] usb 1-1.3: Product: USB-Serial Controller D
[  245.477169] usb 1-1.3: Manufacturer: Prolific Technology Inc.
[  245.537317] usbcore: registered new interface driver pl2303
[  245.537470] usbserial: USB Serial support registered for pl2303
[  245.537595] pl2303 1-1.3:1.0: pl2303 converter detected
[  245.543866] usb 1-1.3: pl2303 converter now attached to ttyUSB0
and then the 3G modem

Code: Select all

root@blunap:/home/pi# dmesg -c
[  340.105517] usb 1-1.4: new high-speed USB device number 6 using dwc_otg
[  340.207055] usb 1-1.4: New USB device found, idVendor=2001, idProduct=7600
[  340.207080] usb 1-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  340.207098] usb 1-1.4: Product: SC7702 HSPA+ Datacard
[  340.207115] usb 1-1.4: Manufacturer: Spreadtrum
[  340.207131] usb 1-1.4: SerialNumber: CF964D81B57032E
[  340.208669] usb-storage 1-1.4:1.0: USB Mass Storage device detected
[  340.211195] scsi host2: usb-storage 1-1.4:1.0
[  341.207453] scsi 2:0:0:0: Direct-Access     SPRD     MicroSD Card     2.31 PQ: 0 ANSI: 2
[  341.209561] sd 2:0:0:0: Attached scsi generic sg0 type 0
[  341.214158] scsi 2:0:0:1: CD-ROM            SPRD     CD-ROM           2.31 PQ: 0 ANSI: 2
[  341.226857] sd 2:0:0:0: [sda] Attached SCSI removable disk
[  341.233906] sr 2:0:0:1: [sr0] scsi-1 drive
[  341.235098] sr 2:0:0:1: Attached scsi CD-ROM sr0
[  341.235763] sr 2:0:0:1: Attached scsi generic sg1 type 5
[  341.509175] usbserial_generic 1-1.4:2.0: The "generic" usb-serial driver is only for testing and one-off prototypes.
[  341.509199] usbserial_generic 1-1.4:2.0: Tell linux-usb@vger.kernel.org to add your device to a proper driver.
[  341.509211] usbserial_generic 1-1.4:2.0: generic converter detected
[  341.509562] usb 1-1.4: generic converter now attached to ttyUSB1
[  341.509998] usbserial_generic 1-1.4:2.1: The "generic" usb-serial driver is only for testing and one-off prototypes.
[  341.510013] usbserial_generic 1-1.4:2.1: Tell linux-usb@vger.kernel.org to add your device to a proper driver.
[  341.510024] usbserial_generic 1-1.4:2.1: generic converter detected
[  341.510407] usb 1-1.4: generic converter now attached to ttyUSB2
[  341.510811] usbserial_generic 1-1.4:2.2: The "generic" usb-serial driver is only for testing and one-off prototypes.
[  341.510825] usbserial_generic 1-1.4:2.2: Tell linux-usb@vger.kernel.org to add your device to a proper driver.
[  341.510837] usbserial_generic 1-1.4:2.2: generic converter detected
[  341.511324] usb 1-1.4: generic converter now attached to ttyUSB3
[  341.511760] usb-storage 1-1.4:2.3: USB Mass Storage device detected
[  341.512139] scsi host3: usb-storage 1-1.4:2.3
[  341.512889] usbserial_generic 1-1.4:2.4: The "generic" usb-serial driver is only for testing and one-off prototypes.
[  341.512905] usbserial_generic 1-1.4:2.4: Tell linux-usb@vger.kernel.org to add your device to a proper driver.
[  341.512916] usbserial_generic 1-1.4:2.4: generic converter detected
[  341.514691] usb 1-1.4: generic converter now attached to ttyUSB4
[  342.507291] scsi 3:0:0:0: Direct-Access     SPRD     MicroSD Card     2.31 PQ: 0 ANSI: 2
[  342.508264] sd 3:0:0:0: Attached scsi generic sg0 type 0
[  342.513288] scsi 3:0:0:1: CD-ROM            SPRD     CD-ROM           2.31 PQ: 0 ANSI: 2
[  342.521491] sd 3:0:0:0: [sda] Attached SCSI removable disk
[  342.528592] sr 3:0:0:1: [sr0] scsi-1 drive
[  342.529355] sr 3:0:0:1: Attached scsi CD-ROM sr0
[  342.530061] sr 3:0:0:1: Attached scsi generic sg1 type 5
and this is ls /dev/ttyUSB_sprd_*

Code: Select all

root@blunap:/home/pi# ls /dev/ttyUSB_sprd_*
/dev/ttyUSB_sprd_control  /dev/ttyUSB_sprd_extension  /dev/ttyUSB_sprd_modem  /dev/ttyUSB_sprd_service
root@blunap:/home/pi#
this looks all good. I booted the unit with the 3G modem attached and then removed it and did the tests. If you need also without the modem from boot let me know.

thanks

Re: GSM modem and USB serial port issue with UDEV

Posted: Thu Apr 21, 2016 5:12 pm
by Aydan
your dialler script should not use ttyUSBn but /dev/ttyUSB_sprd_modem
you don't know if ttyUSBn is the correct tty. Thats why the udev rule sets up explicit symlinks.

Regards
Aydan

Re: GSM modem and USB serial port issue with UDEV

Posted: Thu Apr 21, 2016 5:49 pm
by spoonzw
If you leave both devices plugged in and reboot only the serial-to-usb is added to the system. If you want everything to work you have to boot with the modem then manually plug in the serial-to-usb after boot. Any idea what's the issue?

Re: GSM modem and USB serial port issue with UDEV

Posted: Thu Apr 21, 2016 5:58 pm
by Aydan
please provide the output of

Code: Select all

dmesg | grep usb

Code: Select all

ls /dev/ttyUSB*
and

Code: Select all

lsusb -t
after a reboot with both devices connected.

Regards
Aydan

Re: GSM modem and USB serial port issue with UDEV

Posted: Thu Apr 21, 2016 7:29 pm
by spoonzw
Hi Aydan

Herewith as requested. Both devices plugged in at boot.

dmesg | grep usb

Code: Select all

root@blunap:/home/pi# dmesg | grep usb
[    0.820419] usbcore: registered new interface driver usbfs
[    0.826031] usbcore: registered new interface driver hub
[    0.831518] usbcore: registered new device driver usb
[    1.233861] usbcore: registered new interface driver smsc95xx
[    1.759421] dwc_otg 3f980000.usb: DWC OTG Controller
[    1.766159] dwc_otg 3f980000.usb: new USB bus registered, assigned bus number 1
[    1.776830] dwc_otg 3f980000.usb: irq 32, io mem 0x00000000
[    1.794968] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002
[    1.805134] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1
[    1.815825] usb usb1: Product: DWC OTG Controller
[    1.822286] usb usb1: Manufacturer: Linux 4.1.13-v7+ dwc_otg_hcd
[    1.830085] usb usb1: SerialNumber: 3f980000.usb
[    1.849526] usbcore: registered new interface driver usb-storage
[    1.958816] usbcore: registered new interface driver usbhid
[    1.966183] usbhid: USB HID core driver
[    2.232903] usb 1-1: new high-speed USB device number 2 using dwc_otg
[    2.443260] usb 1-1: New USB device found, idVendor=0424, idProduct=9514
[    2.453707] usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[    2.752890] usb 1-1.1: new high-speed USB device number 3 using dwc_otg
[    2.873239] usb 1-1.1: New USB device found, idVendor=0424, idProduct=ec00
[    2.883888] usb 1-1.1: New USB device strings: Mfr=0, Product=0, SerialNumber=0
[    2.967032] smsc95xx 1-1.1:1.0 eth0: register 'smsc95xx' at usb-3f980000.usb-1.1, smsc95xx USB 2.0 Ethernet, b8:27:eb:42:8c:93
[    3.062883] usb 1-1.3: new full-speed USB device number 4 using dwc_otg
[    3.185225] usb 1-1.3: New USB device found, idVendor=067b, idProduct=2303
[    3.196282] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[    3.207767] usb 1-1.3: Product: USB-Serial Controller D
[    3.215108] usb 1-1.3: Manufacturer: Prolific Technology Inc.
[    6.009867] usbcore: registered new interface driver usbserial
[    6.019915] usbcore: registered new interface driver usbserial_generic
[    6.034005] usbserial: USB Serial support registered for generic
[    6.049589] usbcore: registered new interface driver pl2303
[    6.065327] usbserial: USB Serial support registered for pl2303
[    6.088926] usb 1-1.3: pl2303 converter now attached to ttyUSB0
[   11.612976] usb 1-1.4: new high-speed USB device number 5 using dwc_otg
[   11.724431] usb 1-1.4: New USB device found, idVendor=2001, idProduct=7600
[   11.735317] usb 1-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[   11.746704] usb 1-1.4: Product: SC7702 HSPA+ Datacard
[   11.746716] usb 1-1.4: Manufacturer: Spreadtrum
[   11.746726] usb 1-1.4: SerialNumber: CF964D81B57032E
[   11.748012] usb-storage 1-1.4:1.0: USB Mass Storage device detected
[   11.754176] scsi host0: usb-storage 1-1.4:1.0
[   13.179217] usb-storage 1-1.4:2.3: USB Mass Storage device detected
[   13.179742] scsi host1: usb-storage 1-1.4:2.3
root@blunap:/home/pi#
ls /dev/ttyUSB*

Code: Select all

root@blunap:/home/pi# ls /dev/ttyUSB*
/dev/ttyUSB0
root@blunap:/home/pi#
lsusb -t

Code: Select all

root@blunap:/home/pi# lsusb -t
1-1.4:2.0: No such file or directory
1-1.4:2.1: No such file or directory
1-1.4:2.2: No such file or directory
1-1.4:2.4: No such file or directory
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=dwc_otg/1p, 480M
    |__ Port 1: Dev 2, If 0, Class=hub, Driver=hub/5p, 480M
        |__ Port 1: Dev 3, If 0, Class=vend., Driver=smsc95xx, 480M
        |__ Port 3: Dev 4, If 0, Class=vend., Driver=pl2303, 12M
        |__ Port 4: Dev 5, If 0, Class=vend., Driver=, 480M
        |__ Port 4: Dev 5, If 1, Class=vend., Driver=, 480M
        |__ Port 4: Dev 5, If 2, Class=vend., Driver=, 480M
        |__ Port 4: Dev 5, If 3, Class=stor., Driver=usb-storage, 480M
        |__ Port 4: Dev 5, If 4, Class=vend., Driver=, 480M
root@blunap:/home/pi#
thank you

Re: GSM modem and USB serial port issue with UDEV

Posted: Thu Apr 21, 2016 7:41 pm
by Aydan
that really is strange.
The "subdevices" get enumerated (see here:

Code: Select all

        |__ Port 4: Dev 5, If 0, Class=vend., Driver=, 480M
        |__ Port 4: Dev 5, If 1, Class=vend., Driver=, 480M
        |__ Port 4: Dev 5, If 2, Class=vend., Driver=, 480M
        |__ Port 4: Dev 5, If 3, Class=stor., Driver=usb-storage, 480M
        |__ Port 4: Dev 5, If 4, Class=vend., Driver=, 480M
)
but no drivers are loaded.
Please you try to run

Code: Select all

/usr/sbin/usb_modeswitch -V 0x2001 -P 0x7600 -v 0x2001 -p 0x7600 -u 2
from a root terminal and the rerun

Code: Select all

lsusb -t
to see if it's only the modeswitch failing ore something else.

Regards
Aydan

Re: GSM modem and USB serial port issue with UDEV

Posted: Fri Apr 22, 2016 5:14 am
by spoonzw
HI Aydan

I thought so too. I have run this before and it always comes back "Nothing to do"

/usr/sbin/usb_modeswitch -V 0x2001 -P 0x7600 -v 0x2001 -p 0x7600 -u 2

Code: Select all

root@blunap:/home/pi# /usr/sbin/usb_modeswitch -V 0x2001 -P 0x7600 -v 0x2001 -p 0x7600 -u 2

Looking for target devices ...
   found matching product ID
   adding device
 Found devices in target mode or class (1)
Looking for default devices ...
   found matching product ID
Getting the current device configuration ...
 OK, got current device configuration (2)
 No devices in default mode found. Nothing to do. Bye.

root@blunap:/home/pi#
lsusb -t

Code: Select all

root@blunap:/home/pi# lsusb -t
1-1.4:2.0: No such file or directory
1-1.4:2.1: No such file or directory
1-1.4:2.2: No such file or directory
1-1.4:2.4: No such file or directory
/:  Bus 01.Port 1: Dev 1, Class=root_hub, Driver=dwc_otg/1p, 480M
    |__ Port 1: Dev 2, If 0, Class=hub, Driver=hub/5p, 480M
        |__ Port 1: Dev 3, If 0, Class=vend., Driver=smsc95xx, 480M
        |__ Port 3: Dev 4, If 0, Class=vend., Driver=pl2303, 12M
        |__ Port 4: Dev 5, If 0, Class=vend., Driver=, 480M
        |__ Port 4: Dev 5, If 1, Class=vend., Driver=, 480M
        |__ Port 4: Dev 5, If 2, Class=vend., Driver=, 480M
        |__ Port 4: Dev 5, If 3, Class=stor., Driver=usb-storage, 480M
        |__ Port 4: Dev 5, If 4, Class=vend., Driver=, 480M
root@blunap:/home/pi#

Re: GSM modem and USB serial port issue with UDEV

Posted: Fri Apr 22, 2016 2:46 pm
by spoonzw
HI Aydan

What i found is that a module was loading for the usb-to-serial (pl2303) that affected the 3G modems module (usbserial). I unloaded the usb-to-serials module and loaded the 3g'd module and hey presto the 3g modem worked. I then loaded the usb-to-serials modem and all was right again. I found a way around this issue by having a script that fires on start up. Its called from rc.local.

Code: Select all

#!/bin/bash
# Unload serial-to-usb module
/sbin/modprobe -rf pl2303
sleep 3
# Reload 3G Module
/sbin/modprobe usbserial vendor=0x2001 product=0x7600
sleep 3
# Reload serial-to-usb module
/sbin/modprobe pl2303
sleep 3
Hope this helps anyone else having this same issue

thanks for all your help!!!