如何在Linux主机上将未知的USB设备配置为以太网?

时间:2018-10-16 08:22:07

标签: linux usb ethernet

连接USB设备后,我得到以下信息:

$ dmesg | tail
[   79.612133] usb 2-2: new full-speed USB device number 3 using ohci-pci
[   79.937340] usb 2-2: New USB device found, idVendor=238b, idProduct=0a21
[   79.937343] usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[   79.937344] usb 2-2: Product: DMR Radio
[   79.937346] usb 2-2: Manufacturer: Hytera Communications
[   80.282770] cfg80211: Loading compiled-in X.509 certificates for regulatory database
[   80.286007] cfg80211: Loaded X.509 cert 'sforshee: 00b28ddf47aef9cea7'
[   80.399206] usbcore: registered new interface driver cdc_ether
[   80.404402] usbcore: registered new interface driver rndis_host
[   80.421516] usbcore: registered new interface driver rndis_wlan

没有类似“ cdc_subset 1-4.4.2:1.1:usb0:在Linux设备usb-0000:00:02.1-4.4.2上注册'cdc_subset'”的消息。

因此,没有名为usb0的以太网。

$ uname -a
Linux VB1804 4.15.0-36-generic #39-Ubuntu SMP Mon Sep 24 16:19:09 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

它显示为未知设备。

$ lsusb
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 002 Device 003: ID 238b:0a21  
Bus 002 Device 002: ID 80ee:0021 VirtualBox USB Tablet
Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

$ lsmod | grep usbnet
usbnet                 45056  3 rndis_host,cdc_ether,rndis_wlan
mii                    16384  1 usbnet

我在物理Linux上也是如此。

然后

$ usb-devices 
--------- other usb devices ----

T:  Bus=02 Lev=01 Prnt=01 Port=01 Cnt=02 Dev#=  3 Spd=12  MxCh= 0
D:  Ver= 2.00 Cls=ff(vend.) Sub=fe Prot=fe MxPS= 8 #Cfgs=  1
P:  Vendor=238b ProdID=0a21 Rev=00.00
S:  Manufacturer=Hytera Communications
S:  Product=DMR Radio
C:  #Ifs= 3 Cfg#= 1 Atr=c0 MxPwr=4mA
I:  If#= 0 Alt= 0 #EPs= 1 Cls=02(commc) Sub=02 Prot=ff Driver=(none)
I:  If#= 1 Alt= 0 #EPs= 2 Cls=0a(data ) Sub=00 Prot=00 Driver=(none)
I:  If#= 2 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none)

1 个答案:

答案 0 :(得分:0)

我将rnVendor和idProduct添加到rndis_host.c文件中的结构数组prodocts []的白名单中。

static const struct usb_device_id   products [] = {
{   /* DMR Radio*/
    USB_DEVICE_AND_INTERFACE_INFO(0x238b, 0x0a21,
                  USB_CLASS_COMM, 2 /* ACM */, 0x0ff),
    .driver_info = (unsigned long) &rndis_info,
}, {

而且,它可行。