1. 程式人生 > >[RK3399][Android7.1] 除錯筆記 --- USB:no configuration chosen from 1 choice

[RK3399][Android7.1] 除錯筆記 --- USB:no configuration chosen from 1 choice

Platform: RK3399
OS: Android 7.1
Kernel: v4.4.83

背景:

由於rk3399四個usb口不能滿足數量需求,對其中的usb3.0(非OTG口)進行外接Hub做擴充套件成3個USB2.0+1一個USB3.0。
原理圖如下:

在這裡插入圖片描述

現象:

插上U盤後出現error:

[   23.102908] usb 2-1.3: new high-speed USB device number 4 using ehci-platform
[   23.198825] usb 2-1.3: New USB device found, idVendor=0bda, idProduct=0316
[   23.198975] usb 2-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[   23.199005] usb 2-1.3: Product: USB3.0-CRW
[   23.199030] usb 2-1.3: Manufacturer: Generic
[   23.199054] usb 2-1.3: SerialNumber: 20120501030900000
[   23.202782] usb 2-1.3: rejected 1 configuration due to insufficient available bus power
[   23.202980] usb 2-1.3: no configuration chosen from 1 choice

原因:

由於外接Hub沒有使用自供電(4個USB口總電流超過500mA),而Hub驅動中對Hub的每個埠配置電流是100mA,導致錯誤出現。


解決方法:

  1. 硬體使用Hub晶片自供電方式,滿足電流需求。

  2. 臨時解決方法

rk3399_mid:/ #echo 1 > /sys/bus/usb/devices/2-1.2/bConfigurationValue 
  1. 原始碼修改方式
    是的hub能接受最大電流為500*4=2000mA,這個只是軟體的控制。
    硬體會對每個埠限流,所以不必擔心會出問題。

hub驅動對電流的計算在hub_configure()以及hub_power_remaining()中。

[email protected]:~/rk3399/kernel$ g df 
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index fb9223c..50e38b3 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -1482,8 +1482,19 @@ static int hub_configure(struct usb_hub *hub,
                        hub->limited_power = 1;
                }
        } else if ((hubstatus & (1 << USB_DEVICE_SELF_POWERED)) == 0) {
+
+#if 1
+               int remaining;
+               full_load = 2000;
+               hdev->bus_mA = full_load;
+               unit_load  = 500;
+               hub->descriptor->bHubContrCurrent = unit_load;
+               remaining = hdev->bus_mA -
+                       hub->descriptor->bHubContrCurrent;
+#else
                int remaining = hdev->bus_mA -
                        hub->descriptor->bHubContrCurrent;
+#endif
 
                dev_dbg(hub_dev, "hub controller current requirement: %dmA\n",
                        hub->descriptor->bHubContrCurrent);

參考:

USB error: no configuration chosen from 1 choice
USB小知識——500mA的匯流排供電模式