如果在上电之前插入 USB 设备,我们的嵌入式 linux 系统将无法识别它。建议?

Bla*_*ine 6 linux usb embedded linux-kernel

我们正在小型嵌入式设备上进行开发。该设备是一个运行 OpenEmbedded linux 的 gunstix overo 板。我们的开发几乎已经完成,并且遇到了我们无法弄清楚的最奇怪的错误。

我们有一个 USB 设备(分光光度计),它有一个 USB2.0 连接一个用于光源的外部电源。典型的行为是插入电源,然后通过 USB 连接到主机。当设备检测到 USB 连接时,设备启动并启用光源和风扇。然后该设备可以被主机系统使用。

问题是,如果在我们打开 Gumstix 之前将设备插入 Gumstix,USB 设备显然没有被系统探测到(因此不会打开)。在正常情况下,当通过插入 USB 电缆初始化连接时,光谱会自行打开并可供系统使用(这通常可以通过“lsusb”看到)。这些事情都没有发生。没有通过“lsusb”检测到设备,也没有我们可以看到的任何类型的 dmesg 错误。 就好像设备没有插入一样。

如果我们拔下 USB 电缆并在系统启动后将其重新插入,该设备确实会显示并正常工作。它打开并显示在 USB 总线上,我们可以通过我们的驱动程序访问它。

在任何其他台式机或笔记本电脑上,当我们插入光谱仪时,主机系统是打开还是关闭都没有关系。这种行为是我认为是“正常的”——USB 系统在启动时被探测和初始化,并且 USB 设备上线。换句话说,只要我们在系统启动后插入 USB 设备,我们的系统就可以正常运行。不幸的是,这在我们的最终产品中是不可能的——一切都是同时发生的。

附加信息:1) 我们尝试在系统关闭时将闪存驱动器连接到系统。正如预期的那样,启动系统会使闪存驱动器联机 2) 没有关于光谱或 USB 设备的消息(使用 dmesg)。“lsusb”仅列出 USB 集线器/控制器。从字面上看,就好像设备不存在且未插入。 3) 我们尝试了来自gumstix 的全新图像和去年的旧图像。两张图都有这个问题。我们使用的所有 3 种 gunstix 设备都存在此问题。

有没有人有什么建议?据我所知,完全模拟 USB 设备的“拔出”和“重新插入”是不可能完全“重新启动”USB 系统的。我觉得正在发生的事情是 USB 总线上没有初始探测会触发 USB 握手,但这在某种程度上特定于光谱。这似乎是内核问题,或者至少是内核如何初始化 USB 子系统的问题。我不太确定。

我已经尝试过gumstix 邮件列表,但之前似乎没有人见过这个问题。关于从哪里开始寻找的任何建议或建议都会很棒。

谢谢!布莱恩

output etc.
$ uname -a
Linux overo 2.6.33 #1 Tue Apr 27 08:35:38 PDT 2010 armv7l GNU/Linux

When the system is up and running and spectro is plugged in (working as intended), this is lsusb:
Bus 001 Device 116: ID 2457:1022  
Device Descriptor:
  bLength                18
  bDescriptorType         1
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  idVendor           0x2457 
  idProduct          0x1022 
  bcdDevice            0.02
  iManufacturer           1 USB4000 1.01.11
  iProduct                2 Ocean Optics USB4000
  iSerial                 0 
  bNumConfigurations      1
  Configuration Descriptor:
    bLength                 9
    bDescriptorType         2
    wTotalLength           46
    bNumInterfaces          1
    bConfigurationValue     1
    iConfiguration          0 
    bmAttributes         0x80
      (Bus Powered)
    MaxPower              400mA
    Interface Descriptor:
      bLength                 9
      bDescriptorType         4
      bInterfaceNumber        0
      bAlternateSetting       0
      bNumEndpoints           4
      bInterfaceClass       255 Vendor Specific Class
      bInterfaceSubClass      0 
      bInterfaceProtocol      0 
      iInterface              0 
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x01  EP 1 OUT
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x82  EP 2 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x86  EP 6 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
      Endpoint Descriptor:
        bLength                 7
        bDescriptorType         5
        bEndpointAddress     0x81  EP 1 IN
        bmAttributes            2
          Transfer Type            Bulk
          Synch Type               None
          Usage Type               Data
        wMaxPacketSize     0x0200  1x 512 bytes
        bInterval               0
Device Qualifier (for other device speed):
  bLength                10
  bDescriptorType         6
  bcdUSB               2.00
  bDeviceClass            0 (Defined at Interface level)
  bDeviceSubClass         0 
  bDeviceProtocol         0 
  bMaxPacketSize0        64
  bNumConfigurations      1
Device Status:     0x0000
  (Bus Powered)

dmesg output:

usb usb1: usb auto-resume
hub 1-0:1.0: hub_resume
usb usb2: usb auto-resume
ehci-omap ehci-omap.0: resume root hub
hub 1-0:1.0: state 7 ports 1 chg 0000 evt 0000
hub 2-0:1.0: hub_resume
hub 2-0:1.0: state 7 ports 3 chg 0000 evt 0000
hub 1-0:1.0: hub_suspend
usb usb1: bus auto-suspend
hub 2-0:1.0: hub_suspend
usb usb2: bus auto-suspend
ehci-omap ehci-omap.0: suspend root hub
usb usb2: usb resume
ehci-omap ehci-omap.0: resume root hub
hub 2-0:1.0: hub_resume
ehci-omap ehci-omap.0: GetStatus port 2 status 001803 POWER sig=j CSC CONNECT
hub 2-0:1.0: port 2: status 0501 change 0001
hub 2-0:1.0: state 7 ports 3 chg 0004 evt 0000
hub 2-0:1.0: port 2, status 0501, change 0000, 480 Mb/s
ehci-omap ehci-omap.0: port 2 high speed
ehci-omap ehci-omap.0: GetStatus port 2 status 001005 POWER sig=se0 PE CONNECT
usb 2-2: new high speed USB device using ehci-omap and address 2
ehci-omap ehci-omap.0: port 2 high speed
ehci-omap ehci-omap.0: GetStatus port 2 status 001005 POWER sig=se0 PE CONNECT
usb 2-2: default language 0x0409
usb 2-2: udev 2, busnum 2, minor = 129
usb 2-2: New USB device found, idVendor=2457, idProduct=1022
usb 2-2: New USB device strings: Mfr=1, Product=2, SerialNumber=0
usb 2-2: Product: Ocean Optics USB4000
usb 2-2: Manufacturer: USB4000 1.01.11
usb 2-2: uevent
usb 2-2: usb_probe_device
usb 2-2: configuration #1 chosen from 1 choice
usb 2-2: uevent
usb 2-2: adding 2-2:1.0 (config #1, interface 0)
usb 2-2:1.0: uevent
drivers/usb/core/inode.c: creating file '002'


dmesg has nothing to say, and lusb simply lists nothing else but the two default usb controllers / hubs if we plug the device in before the system is turned on.
Run Code Online (Sandbox Code Playgroud)

Bla*_*ine 5

把它从死里带回来完成。

细节是模糊的,但事实证明设备本身在启动时崩溃了。我相信这与 uBoot 在 USB 线上产生的喋喋不休有关。本质上,uBoot 轮询所有硬件线路(包括 USB)以找到可启动映像。这种轮询应该是无害的,但我们 USB 设备上的固件无法处理它并立即崩溃,使其无法运行,直到硬重置(物理拔下设备并重新插入)。

我们确实向设备制造商报告了这个错误,但我们没有收到任何迹象表明该问题的修复(显然只影响我们)将是一个优先事项,因此我们求助于 0.50 美元的修复。

我们解决这个问题的方法非常有创意,但效果很好。我们搭建了一个简单的GPIO控制继电器,通过这个继电器拼接USB电源线。本质上,系统在继电器“关闭”的情况下启动,因此 USB 设备没有电源。系统正常启动,在我们的启动脚本中,我们只需切换 GPIO 线以激活继电器。USB设备可以自由正常启动,不受uBoot干扰。