我正在尝试将 mmx352g 调制解调器(Vendor=1c9e ProdID=f000)与我的 OpenWRT 路由器一起使用。
root@GL-AR150:/dev# lsusb
Bus 001 Device 002: ID 1c9e:f000 OMEGA TECHNOLOGY
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
但我收到以下日志:
root@GL-AR150:/dev# dmesg | grep -i usb
[ 0.590000] usbcore: registered new interface driver usbfs
[ 0.590000] usbcore: registered new interface driver hub
[ 0.600000] usbcore: registered new device driver usb
[ 2.070000] usbcore: registered new interface driver cdc_ether
[ 2.080000] usbcore: registered new interface driver lg-vl600
[ 2.080000] usbcore: registered new interface driver cdc_acm
[ 2.090000] cdc_acm: USB Abstract Control Model driver for USB modems and ISDN adapters
[ 6.900000] ehci_hcd: USB 2.0 'Enhanced' Host Controller (EHCI) Driver
[ 6.910000] ehci-platform ehci-platform: new USB bus registered, assigned bus number 1
[ 6.950000] ehci-platform ehci-platform: USB 2.0 started, EHCI 1.00
[ 6.950000] hub 1-0:1.0: USB hub found
[ 6.960000] ohci_hcd: USB 1.1 'Open' Host Controller (OHCI) Driver
[ 6.970000] uhci_hcd: USB Universal Host Controller Interface driver
[ 6.990000] usbcore: registered new interface driver usb-storage
[ 7.280000] usb 1-1: new high-speed USB device number 2 using ehci-platform
[ 7.430000] usb-storage 1-1:1.0: USB Mass Storage device detected
[ 7.440000] scsi host0: usb-storage 1-1:1.0
[ 8.440000] scsi 0:0:0:0: CD-ROM USBModem Disk 2.31 PQ: 0 ANSI: 2
[ 21.120000] usbserial: unknown parameter 'maxSize' ignored
[ 21.130000] usbcore: registered new interface driver usbserial
[ 21.130000] usbcore: registered new interface driver usbserial_generic
[ 21.140000] usbserial: USB Serial support registered for generic
[ 21.150000] usbserial_generic 1-1:1.0: The "generic" usb-serial driver is only for testing and one-off prototypes.
[ 21.160000] usbserial_generic 1-1:1.0: Tell [email protected] to add your device to a proper driver.
[ 21.170000] usbserial_generic 1-1:1.0: generic converter detected
[ 21.170000] usb 1-1: generic converter now attached to ttyUSB0
[ 21.350000] usbcore: registered new interface driver cdc_ncm
[ 21.480000] usbcore: registered new interface driver cdc_wdm
[ 21.510000] usbcore: registered new interface driver cp210x
[ 21.510000] usbserial: USB Serial support registered for cp210x
[ 21.520000] usbcore: registered new interface driver huawei_cdc_ncm
[ 21.680000] usbcore: registered new interface driver ipheth
[ 21.760000] usbcore: registered new interface driver qmi_wwan
[ 21.770000] usbcore: registered new interface driver rndis_host
[ 21.770000] usbcore: registered new interface driver sierra
[ 21.780000] usbserial: USB Serial support registered for Sierra USB modem
[ 21.790000] usbcore: registered new interface driver sierra_net
[ 21.820000] usbcore: registered new interface driver uvcvideo
[ 21.820000] USB Video Class driver (1.1.1)
[ 22.050000] usbcore: registered new interface driver sonixb
[ 22.060000] usbcore: registered new interface driver sonixj
[ 22.090000] usbcore: registered new interface driver gspca_zc3xx
[ 22.240000] usbcore: registered new interface driver option
[ 22.240000] usbserial: USB Serial support registered for GSM modem (1-port)
[ 22.480000] usbcore: registered new interface driver rt2800usb
[ 31.370000] generic ttyUSB0: generic converter now disconnected from ttyUSB0
[ 31.380000] usbserial_generic 1-1:1.0: device disconnected
我不是 Linux 专家,无法理解日志文件以检测问题。看来调制解调器正在被检测到usb 1-1: generic converter now attached to ttyUSB0, usbserial: USB Serial support registered for GSM modem (1-port)
但最后还是断线了。generic ttyUSB0: generic converter now disconnected from ttyUSB0, usbserial_generic 1-1:1.0: device disconnected
我还在 /etc/modules.d 中添加/修改了 2 个文件(60-usb-serial 和 usb-serial),并使用
usbserial vendor=0x1c9e product=0xf000 maxSize=4096
以下是一些可能有用的其他输出:
root@GL-AR150:/dev# cat /sys/kernel/debug/usb/devices
T: Bus=01 Lev=00 Prnt=00 Port=00 Cnt=00 Dev#= 1 Spd=480 MxCh= 1
B: Alloc= 0/800 us ( 0%), #Int= 0, #Iso= 0
D: Ver= 2.00 Cls=09(hub ) Sub=00 Prot=01 MxPS=64 #Cfgs= 1
P: Vendor=1d6b ProdID=0002 Rev= 3.18
S: Manufacturer=Linux 3.18.27 ehci_hcd
S: Product=EHCI Host Controller
S: SerialNumber=ehci-platform
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr= 0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=09(hub ) Sub=00 Prot=00 Driver=hub
E: Ad=81(I) Atr=03(Int.) MxPS= 4 Ivl=256ms
T: Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 2 Spd=480 MxCh= 0
D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
P: Vendor=1c9e ProdID=f000 Rev= 0.00
S: Manufacturer=USB Modem
S: Product=USB Modem
S: SerialNumber=1234567890ABCDEF
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=500mA
I:* If#= 0 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=(none)
E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E: Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
root@GL-AR150:/dev# ls | grep tty
tty
ttyATH0
ttyS0
ttyS1
ttyS10
ttyS11
ttyS12
ttyS13
ttyS14
ttyS15
ttyS2
ttyS3
ttyS4
ttyS5
ttyS6
ttyS7
ttyS8
ttyS9
调制解调器似乎可以自行工作(通过查看 LED 闪烁情况判断)。当前闪烁顺序表示它已在网络上注册),但 OpenWRT 无法让驱动程序进行通信。有人可以帮忙解决此问题吗?
答案1
问题是如何正确进行模式切换。来自 usb_modeswitch手动的:
在 Linux 上,大多数情况下驱动程序都以内核模块的形式提供,例如“usbserial”或“option”。但是,设备(WAN 加密狗)默认显示为“usb-storage”。usb_modeswitch 可以向已知启动模式切换的设备发送提供的批量消息(很可能是大容量存储命令)。
在我的 Linux 笔记本电脑上,加密狗曾经工作正常。因此,我查看了日志消息,发现模式切换“消息”与 OpenWRT 中使用的消息不同。
USB_ModeSwitch log from Wed Sep 12 12:19:46 PDT 2018
...OMITTED FOR CLARITY...
DefaultVendor= 0x1c9e
DefaultProduct= 0xf000
TargetVendor= 0x1c9e
TargetProductList="9000,9603,9605,9607,9900,9a00"
MessageContent="55534243123456788000000080000606f50402527000000000000000000000"
...OMITTED FOR CLARITY...
found USB ID 1c9e:f000
vendor ID matched
product ID matched
Found devices in default mode (1)
...OMITTED FOR CLARITY...
Looking for active drivers ...
OK, driver detached
Set up interface 0
Use endpoint 0x01 for message sending ...
Trying to send message 1 to endpoint 0x01 ...
OK, message successfully sent
...OMITTED FOR CLARITY...
Check success of mode switch for max. 20 seconds ...
...OMITTED FOR CLARITY...
Read attributes ...
All attributes matched
Mode switching was successful, found 1c9e:9605 (USB Modem: USB Modem)
...OMITTED FOR CLARITY...
All done, exit
OpenWRT 使用一个名为usbmode
,这似乎是经典 usb_modeswitch 的精简版。配置文件位于/etc/usb-mode.json
。默认配置对我来说不起作用,所以我用以下内容替换了原始文件的内容;
{
"messages" : [
"55534243123456788000000080000606f50402527000000000000000000000"
],
"devices" : {
"1c9e:f000": {
"*": {
"t_vendor": 7326,
"t_product": [ 38405 ],
"msg": [ 0 ],
"wait": 5
}
}
}
}
重启路由器后,加密狗被正确检测到。以下是日志中的相关部分:
在 [ 17.576569] 和 [ 18.653216] 处,它显示为存储设备。在 [ 21.384065] 处,它断开连接(因为 modeswitch 命令)。最后在 [ 22.542980] 处,它被检测为调制解调器。
[ 17.576569] usb-storage 1-1:1.0: USB Mass Storage device detected
[ 17.622021] scsi host0: usb-storage 1-1:1.0
[ 17.625508] usbcore: registered new interface driver usb-storage
[ 17.726435] usbcore: registered new interface driver usbserial
[ 17.730925] usbcore: registered new interface driver usbserial_generic
[ 17.737547] usbserial: USB Serial support registered for generic
[ 17.878689] xt_time: kernel timezone is -0000
[ 17.904942] usbcore: registered new interface driver cdc_ether
[ 18.200614] PPP generic driver version 2.4.2
[ 18.225069] NET: Registered protocol family 24
[ 18.248515] usbcore: registered new interface driver rndis_host
[ 18.450180] usbcore: registered new interface driver option
[ 18.454525] usbserial: USB Serial support registered for GSM modem (1-port)
...
[ 18.653216] scsi 0:0:0:0: CD-ROM USBModem Disk 2.31 PQ: 0 ANSI: 2
[ 18.712241] kmodloader: done loading kernel modules from /etc/modules.d/*
[ 21.384065] usb 1-1: USB disconnect, device number 2
[ 21.885051] usb 1-1: new high-speed USB device number 3 using ci_hdrc
[ 22.542980] option 1-1:1.0: GSM modem (1-port) converter detected
[ 22.548046] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB0
[ 22.555899] option 1-1:1.1: GSM modem (1-port) converter detected
[ 22.560931] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB1
[ 22.568813] option 1-1:1.2: GSM modem (1-port) converter detected
[ 22.573936] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB2
[ 22.581718] option 1-1:1.3: GSM modem (1-port) converter detected
[ 22.586759] usb 1-1: GSM modem (1-port) converter now attached to ttyUSB3
我们还可以看到productID已经从f000变成了9605,说明模式切换成功。
root@MrGhosh:~# lsusb
Bus 001 Device 003: ID 1c9e:9605 OMEGA TECHNOLOGY
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
root@MrGhosh:~# cat /sys/kernel/debug/usb/devices
...
T: Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 3 Spd=480 MxCh= 0
D: Ver= 2.00 Cls=00(>ifc ) Sub=00 Prot=00 MxPS=64 #Cfgs= 1
P: Vendor=1c9e ProdID=9605 Rev= 0.00
S: Manufacturer=USB Modem
S: Product=USB Modem
S: SerialNumber=1234567890ABCDEF
C:* #Ifs= 5 Cfg#= 1 Atr=e0 MxPwr=500mA
I:* If#= 0 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
E: Ad=81(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E: Ad=01(O) Atr=02(Bulk) MxPS= 512 Ivl=4ms
I:* If#= 1 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
E: Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E: Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=4ms
I:* If#= 2 Alt= 0 #EPs= 2 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
E: Ad=83(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E: Ad=03(O) Atr=02(Bulk) MxPS= 512 Ivl=4ms
I:* If#= 3 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=option
E: Ad=84(I) Atr=03(Int.) MxPS= 64 Ivl=2ms
E: Ad=85(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E: Ad=04(O) Atr=02(Bulk) MxPS= 512 Ivl=4ms
I:* If#= 4 Alt= 0 #EPs= 2 Cls=08(stor.) Sub=06 Prot=50 Driver=usb-storage
E: Ad=05(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
E: Ad=86(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms