日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 运维知识 > windows >内容正文

windows

usb hub区分端口_树莓派上 USB 子系统拓扑浅析

發(fā)布時(shí)間:2025/3/15 windows 46 豆豆
生活随笔 收集整理的這篇文章主要介紹了 usb hub区分端口_树莓派上 USB 子系统拓扑浅析 小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

【注釋】以下實(shí)驗(yàn)基于 RaspberryPi 3B。

參考 “樹(shù)莓派官網(wǎng)”對(duì) USB 子系統(tǒng)的描述如下:

The number and type of USB ports on Raspberry Pi depends on the model. The Raspberry Pi Model B is equipped with two USB 2.0 ports; the B+, 2B, 3B and 3B+ have four USB 2.0 ports. The Pi 4 has two USB 2.0 ports and two USB 3.0 ports. In all models prior to the Pi 4, the USB ports connect to a combo hub/Ethernet chip, which is itself a USB device connected to the single upstream USB port on BCM2835. On the Pi 4, the USB hub chip is connected to the SoC using a PCIe bus.

怎么理解這段話呢,我們可以首先查看 Raspbian(Linux)的設(shè)備模型 。執(zhí)行如下命令:

ls /sys/bus/usb/devices

或者

ls /sys/devices

可以看到以下設(shè)備:

/sys/devices/platform/soc/3f980000.usb/usb1/1-0:1.0 /sys/devices/platform/soc/3f980000.usb/usb1/1-1 /sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.1 /sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1:1.0 /sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.1/1-1.1:1.0

結(jié)合 Raspbian 啟動(dòng)的日志流程,我們一起來(lái)看一下 USB 的設(shè)備模型的拓?fù)浣Y(jié)構(gòu)究竟是怎么一回事以及系統(tǒng)是如何構(gòu)造出這些文件的。

整體的 log 我們就不貼了,我只摘取了和 USB 相關(guān)的條目,參考時(shí)間戳由上至下排列,并在相應(yīng)日志下補(bǔ)上對(duì)應(yīng)的注釋。

[ 0.785594] dwc_otg 3f980000.usb: DWC OTG Controller

【注釋】這里系統(tǒng)提示找到了一個(gè) host controller,“3f980000.usb” 是 soc 上的 USB host controller。

啟動(dòng)繼續(xù):

[ 0.797191] usb usb1: New USB device found, idVendor=1d6b, idProduct=0002, bcdDevice= 4.19 [ 0.801703] usb usb1: New USB device strings: Mfr=3, Product=2, SerialNumber=1 [ 0.804114] usb usb1: Product: DWC OTG Controller [ 0.806480] usb usb1: Manufacturer: Linux 4.19.97-v7+ dwc_otg_hcd [ 0.808929] usb usb1: SerialNumber: 3f980000.usb

【注釋】usb1 是 USB host controller 直接控制的 roothub, roothub 是 1 起序的,所以這是第一個(gè) hub。

啟動(dòng)繼續(xù):

[ 0.811882] hub 1-0:1.0: USB hub found [ 0.814160] hub 1-0:1.0: 1 port detected

【注釋】這個(gè)usb1 是一個(gè) roothub,而且這個(gè) roothub 只有一個(gè) port,設(shè)備模型中 “/sys/devices/platform/soc/3f980000.usb/usb1/1-0:1.0”就是對(duì)應(yīng)的這個(gè) roothub,其中 “1-0:1.0”中的 “1-0”表示的是第 1 個(gè) hub(即usb1)的第 0 號(hào)端口,但實(shí)際上 hub 的 port 編號(hào)是從 1 開(kāi)始, 0 號(hào) port 就是指 hub 自身。而 ":" 后面的 "1.0" 對(duì)應(yīng)的語(yǔ)法格式是 "configID:interfaceID"。

啟動(dòng)繼續(xù):

[ 2.786999] usb 1-1: new high-speed USB device number 2 using dwc_otg [ 2.795901] Indeed it is in host mode hprt0 = 00001101 [ 3.037235] usb 1-1: New USB device found, idVendor=0424, idProduct=9514, bcdDevice= 2.00 [ 3.053286] usb 1-1: New USB device strings: Mfr=0, Product=0, SerialNumber=0 [ 3.064064] hub 1-1:1.0: USB hub found [ 3.070789] hub 1-1:1.0: 5 ports detected [ 3.396998] usb 1-1.1: new high-speed USB device number 3 using dwc_otg [ 3.537280] usb 1-1.1: New USB device found, idVendor=0424, idProduct=ec00, bcdDevice= 2.00 [ 3.551275] usb 1-1.1: New USB device strings: Mfr=0, Product=0, SerialNumber=01.1, smsc95xx USB 2.0 Ethernet, b8:27:eb:91:bc:d3

【注釋】檢測(cè)到連在 roothub(usb1) 上的另一個(gè)新設(shè)備 "1-1"。 它連在 roothub 的第 2 個(gè) port 上,編號(hào)從 1 開(kāi)始。 設(shè)備模型 sysfs 中的下面兩個(gè)設(shè)備都是在描述它,從上面的描述可以看出來(lái)這第二個(gè)設(shè)備也是一個(gè) hub,而且它有 5 個(gè) port。

/sys/devices/platform/soc/3f980000.usb/usb1/1-1 /sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1:1.0

同時(shí)在這個(gè) hub 上的第一個(gè)口連了一個(gè)usb以太網(wǎng)卡,設(shè)備名 “1-1.1”

也就是對(duì)應(yīng)設(shè)備模型中的以下兩個(gè)文件:

/sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.1 /sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.1/1-1.1:1.0

我在 3B 的第一個(gè) USB exteral port (四個(gè)中左上方的那個(gè))接入一個(gè)鼠標(biāo),系統(tǒng)產(chǎn)生 log 如下:

[ 1045.256993] usb 1-1.2: new low-speed USB device number 4 using dwc_otg [ 1045.392240] usb 1-1.2: New USB device found, idVendor=413c, idProduct=301a, bcdDevice= 1.00 [ 1045.392257] usb 1-1.2: New USB device strings: Mfr=1, Product=2, SerialNumber=0 [ 1045.392267] usb 1-1.2: Product: Dell MS116 USB Optical Mouse [ 1045.392276] usb 1-1.2: Manufacturer: PixArt [ 1045.401341] input: PixArt Dell MS116 USB Optical Mouse as /devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0/0003:413C:301A.0001/input/input0 [ 1045.402934] hid-generic 0003:413C:301A.0001: input,hidraw0: USB HID v1.11 Mouse [PixArt Dell MS116 USB Optical Mouse] on usb-3f980000.usb-1.2/input0

查看 sysfs 多了以下內(nèi)容

/sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2 /sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0

說(shuō)明我們?cè)?hub (“/sys/devices/platform/soc/3f980000.usb/usb1/1-1”)上的 2 號(hào) port 上接了一個(gè)鼠標(biāo)設(shè)備,這個(gè)設(shè)備的名字叫 “1-1.2”,全路徑是 “/sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2”,而“/sys/devices/platform/soc/3f980000.usb/usb1/1-1/1-1.2/1-1.2:1.0”就是該鼠標(biāo)設(shè)備的接口的全路徑名稱(chēng)。

綜上所示(在插入鼠標(biāo)的情況下),整個(gè)樹(shù)莓派設(shè)備的 USB 系統(tǒng)拓?fù)溥壿嬋缦聢D所示:

--------------+------------- platform bus(/sys/devices/platform/soc/3f980000.usb)|/-----------------| Host Controller | (usb1), which contains a roothub (1-0)-----------------/ the roothub has only one downstream port| --------------+--------------- usb bus (level 1)| /----------| 1-1 | hub (1-1), has 5 ports----------/| --------+--------------+------ usb bus (level 2)| || |eth (1-1.1) mouse (1-1.2)

總結(jié)

以上是生活随笔為你收集整理的usb hub区分端口_树莓派上 USB 子系统拓扑浅析的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺(jué)得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。