Linux-Kernel

USB 設備沒有響應設置地址

  • March 4, 2021

我有一個不響應設置地址的內置 USB 設備。它嘗試不斷設置設備並不斷失敗:浪費電池、CPU、磁碟空間等。

有沒有辦法殺死 USB 埠或以其他方式阻止核心嘗試配置它?

我試過重啟,使用 uhubctl(不稱為智能集線器),使用埠的電源/autosuspend_delay_ms(獲取輸入/輸出錯誤),使用埠的電源/控制(已經自動),使用集線器的電源/電平(無效的論點)。當然,我不能嘗試其他電纜——它是嵌入式設備。

而且我寧願不完全禁用集線器,但我願意嘗試一下。我幾乎可以通過 Linux 移除 PCI 卡,但這會取出我真正需要的東西(高速 USB 集線器)。

我猜該設備實際上是我從未使用過或無法使用的筆記型電腦指紋讀取器,但我記得我就在身邊。

[ 7283.684834] usb usb1-port7: attempt power cycle
[ 7284.312659] usb 1-7: new full-speed USB device number 41 using xhci_hcd
[ 7284.312858] usb 1-7: Device not responding to setup address.
[ 7284.516966] usb 1-7: Device not responding to setup address.
[ 7284.724647] usb 1-7: device not accepting address 41, error -71
[ 7284.838653] usb 1-7: new full-speed USB device number 42 using xhci_hcd
[ 7284.838852] usb 1-7: Device not responding to setup address.
[ 7285.044852] usb 1-7: Device not responding to setup address.
[ 7285.252760] usb 1-7: device not accepting address 42, error -71
[ 7285.252861] usb usb1-port7: unable to enumerate USB device
[ 7285.366647] usb 1-7: new full-speed USB device number 43 using xhci_hcd
[ 7285.480810] usb 1-7: device descriptor read/64, error -71
[ 7285.702811] usb 1-7: device descriptor read/64, error -71
[ 7285.918653] usb 1-7: new full-speed USB device number 44 using xhci_hcd
[ 7286.032729] usb 1-7: device descriptor read/64, error -71
[ 7286.254780] usb 1-7: device descriptor read/64, error -71
[ 7286.356717] usb usb1-port7: attempt power cycle
Repeat forever

執行 lsusb 當然不會報告設備。但是,上游樞紐是:

Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
00:14.0 USB controller: Intel Corporation 100 Series/C230 Series Chipset Family USB 3.0 xHCI Controller (rev 31)

雖然,正如 OP 所說,一些 USB 集線器有一個額外的協議,允許關閉單個埠,從而輕鬆解決使用 uhubctl 的問題,但大多數 USB 集線器,包括內部在內,沒有這樣的控制。

在 Linux 中仍然可以通過將 0 寫入樹authorized中該設備的控製文件來要求核心禁用 USB 設備的使用。/sys/bus/usb/devices對於執行正常的設備,這將解決問題,但對於一直斷開連接並重新連接的設備則無法解決。

儘管如此,當任何 USB 集線器因此被禁用時,它將禁用並關閉其所有埠。因此,禁用連接設備的 USB 集線器將有效地禁用和關閉不當設備的電源。如果任何其他連接到此集線器的設備失去是可以接受的,那麼這是一種可能的方法。

寫回1文件authorized將再次啟用設備,對於集線器,重新為其埠供電,為任何連接的設備供電。

例子:

# cat /sys/bus/usb/devices/2-1/product
USB2.0 Hub
# echo 0 > /sys/bus/usb/devices/2-1/authorized
# dmesg|tail -1
[226616.900051] usb 2-1.3: USB disconnect, device number 30

usb 2-1.3是一個鍵盤,它的 LED 燈熄滅。

# echo 1 > /sys/bus/usb/devices/2-1/authorized
# dmesg|fgrep 2-1|tail -10
[227055.203089] hub 2-1:1.0: USB hub found
[227055.204441] hub 2-1:1.0: 4 ports detected
[227055.213891] usb 2-1: authorized to connect
[227055.405342] usb 2-1.3: new low-speed USB device number 41 using xhci_hcd
[227055.511969] usb 2-1.3: New USB device found, idVendor=413c, idProduct=2113, bcdDevice= 1.08
[227055.511975] usb 2-1.3: New USB device strings: Mfr=0, Product=2, SerialNumber=0
[227055.511978] usb 2-1.3: Product: Dell KB216 Wired Keyboard
[227055.520754] input: Dell KB216 Wired Keyboard as /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1.3/2-1.3:1.0/0003:413C:2113.001A/input/input136
[227055.583032] input: Dell KB216 Wired Keyboard System Control as /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1.3/2-1.3:1.1/0003:413C:2113.001B/input/input137
[227055.641748] input: Dell KB216 Wired Keyboard Consumer Control as /devices/pci0000:00/0000:00:14.0/usb2/2-1/2-1.3/2-1.3:1.1/0003:413C:2113.001B/input/input138

引用自:https://unix.stackexchange.com/questions/493607