为了开发,我买了一个带有 28 个 USB 集线器的 USB 集线器:Manhattan MondoHub II。该设备由外部电源供电,足以满足我的用例。
在 USB 集线器上,连接了 15 个开发板(STMicro Nucleo 板)。基本上,一旦您将开发板插入 USB 端口,ST-Link v2 芯片就会将底层微控制器的闪存作为 USB 驱动器公开,您可以在其上拖放固件文件。然后用该固件刷新电路板。我需要自动闪烁它们。因此,我将每块板连接到集线器并运行一个闪烁所有内容的脚本。
问题是并非所有 15 个连接的设备都被识别。其中只有 11 个。dmesg
引发有关 USB 主机控制器没有足够资源的错误。
在内部,USB 集线器似乎由多个 USB 集线器组成。
dmesg
当我插入 USB 集线器时,没有连接任何设备:
[269831.218406] usb 2-3: new high-speed USB device number 91 using xhci_hcd
[269831.369806] usb 2-3: New USB device found, idVendor=2109, idProduct=2811
[269831.369813] usb 2-3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[269831.369817] usb 2-3: Product: USB2.0 Hub
[269831.369821] usb 2-3: Manufacturer: VIA Labs, Inc.
[269831.370918] hub 2-3:1.0: USB hub found
[269831.371195] hub 2-3:1.0: 4 ports detected
[269831.678404] usb 2-3.1: new high-speed USB device number 92 using xhci_hcd
[269831.790645] usb 2-3.1: New USB device found, idVendor=1a40, idProduct=0201
[269831.790650] usb 2-3.1: New USB device strings: Mfr=0, Product=1, SerialNumber=0
[269831.790654] usb 2-3.1: Product: USB 2.0 Hub [MTT]
[269831.791150] hub 2-3.1:1.0: USB hub found
[269831.791177] hub 2-3.1:1.0: 7 ports detected
[269831.886375] usb 2-3.2: new high-speed USB device number 93 using xhci_hcd
[269831.998500] usb 2-3.2: New USB device found, idVendor=1a40, idProduct=0201
[269831.998504] usb 2-3.2: New USB device strings: Mfr=0, Product=1, SerialNumber=0
[269831.998506] usb 2-3.2: Product: USB 2.0 Hub [MTT]
[269831.998942] hub 2-3.2:1.0: USB hub found
[269831.998964] hub 2-3.2:1.0: 7 ports detected
[269832.090378] usb 2-3.3: new high-speed USB device number 94 using xhci_hcd
[269832.202654] usb 2-3.3: New USB device found, idVendor=1a40, idProduct=0201
[269832.202658] usb 2-3.3: New USB device strings: Mfr=0, Product=1, SerialNumber=0
[269832.202660] usb 2-3.3: Product: USB 2.0 Hub [MTT]
[269832.203232] hub 2-3.3:1.0: USB hub found
[269832.203258] hub 2-3.3:1.0: 7 ports detected
[269832.294400] usb 2-3.4: new high-speed USB device number 95 using xhci_hcd
[269832.415440] usb 2-3.4: New USB device found, idVendor=14cd, idProduct=8601
[269832.415449] usb 2-3.4: New USB device strings: Mfr=1, Product=3, SerialNumber=0
[269832.415454] usb 2-3.4: Product: USB 2.0 Hub
[269832.415458] usb 2-3.4: Manufacturer: USB Device
[269832.416721] hub 2-3.4:1.0: USB hub found
[269832.416838] hub 2-3.4:1.0: 4 ports detected
断开连接时:
[269873.242343] usb 2-3: USB disconnect, device number 91
[269873.242349] usb 2-3.1: USB disconnect, device number 92
[269873.243596] usb 2-3.2: USB disconnect, device number 93
[269873.244672] usb 2-3.3: USB disconnect, device number 94
[269873.245725] usb 2-3.4: USB disconnect, device number 95
然后我连接板接板。板 1 到 11 被识别并导致此类消息:
[269950.734094] usb 2-3.2.1: new full-speed USB device number 103 using xhci_hcd
[269950.856137] usb 2-3.2.1: New USB device found, idVendor=0483, idProduct=374b
[269950.856140] usb 2-3.2.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[269950.856142] usb 2-3.2.1: Product: STM32 STLink
[269950.856144] usb 2-3.2.1: Manufacturer: STMicroelectronics
[269950.856146] usb 2-3.2.1: SerialNumber: 0671FF323532543457250836
[269950.911199] usb-storage 2-3.2.1:1.1: USB Mass Storage device detected
[269950.911377] scsi host5: usb-storage 2-3.2.1:1.1
[269950.911809] cdc_acm 2-3.2.1:1.2: ttyACM2: USB ACM device
[269951.942405] scsi 5:0:0:0: Direct-Access MBED microcontroller 1.0 PQ: 0 ANSI: 2
[269951.942686] sd 5:0:0:0: Attached scsi generic sg4 type 0
[269951.942980] sd 5:0:0:0: [sdd] 2080 512-byte logical blocks: (1.06 MB/1.02 MiB)
[269951.943876] sd 5:0:0:0: [sdd] Write Protect is off
[269951.943887] sd 5:0:0:0: [sdd] Mode Sense: 03 00 00 00
[269951.944137] sd 5:0:0:0: [sdd] No Caching mode page found
[269951.944143] sd 5:0:0:0: [sdd] Assuming drive cache: write through
[269951.963779] sd 5:0:0:0: [sdd] Attached SCSI removable disk
连接第 12 块板时,无法识别。日志:
[270155.277574] usb 2-3.2.6: new full-speed USB device number 112 using xhci_hcd
[270155.407457] usb 2-3.2.6: New USB device found, idVendor=0483, idProduct=374b
[270155.407464] usb 2-3.2.6: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[270155.407468] usb 2-3.2.6: Product: STM32 STLink
[270155.407472] usb 2-3.2.6: Manufacturer: STMicroelectronics
[270155.407476] usb 2-3.2.6: SerialNumber: 066DFF323532543457074843
[270155.408451] usb 2-3.2.6: Not enough host controller resources for new device state.
[270155.408681] usb 2-3.2.6: can't set config #1, error -12
这里发生了什么?我是否受到 USB 协议、集线器或内核/驱动程序的限制?
在联想 ThinkPad E550 上运行 Ubuntu Budgie '18.04.1 LTS (Bionic Beaver)'。
如果需要,将获取更多日志。完整的日志文件:https ://pastebin.com/BarBHwnc
这似乎是我的不同笔记本电脑/他们的 USB 芯片组的问题。我切换到台式电脑,其主板有很多 USB 连接。
在那里,Windows 10 和 Linux (Debian 9) 都完美地识别了 100 台设备中的每台设备(4 台 MondoHub II,每台 25 位开发人员),没有弹出“主机控制器资源不足”消息。
我在我的 Windows 机器上遇到了同样的问题,我相信问题的根本原因归结为 USB 架构以及您在 PC 上拥有和连接的 USB 主机控制器的数量。这篇National Instruments 知识库文章是我为这个问题找到的最简洁的解释。
话虽如此,此链接解释了查看 PC 上 USB 设备和控制器数量的许多不同方法。