上电前插入USB设备,启动后无法识别

123000   2009-9-16 10:43 楼主
我们的平台usb设备电源是上电后就一直供应的,这样造成了一些上电前插入的USB设备在系统启动后无法识别,必须重新插拔一次.有些设备又可以正常识别.
DEBUG usb 驱动发现,usb驱动在初始化的时候会查询每个端口的状态,并且会尝试枚举设备,但是上电前插入的设备在GetDescriptor的时候会失败,失败后usb驱动会执行ResetAndPoweronPort,再进行尝试,在失败3次以后就会DisablePort,造成无法识别设备. 重新插拔一次后,在GetDescriptor的时候就可以正常返回,枚举设备成功.
现在硬件已经做好,没有办法通过控制usb电源,或者拉低拉高数据线来模拟usb插拔.有没有人遇到过这种问题,有没有什么通过修改usb驱动的办法能解决它呢.

回复评论 (23)

我的wince系统也有这问题!感觉重启系统时最好能使usb设备电源也掉一次就好了,这样上电后就和刚插入的一样了,但是具体怎么实现还不理解呢?帮顶下!
点赞  2009-9-16 13:59
搜到一个老外也遇到这个问题,下面的回答是叫他用usb分析仪看看,可惜我没有呀
Hi all,

I am running Windows CE 5.0 with all available QFEs (including January 2008)
on a Samsung SMDK2410 CPU.

I have a problem with the USB OHCI (1.1) Host Controler:
-start device with a USB device attached to the single OHCI (USB 1.1) Host
Controller port
-occasionally (approximately 5-10 times out of 400 starts) the USB device is
not recognized

The problem occurs in the CHub::AttachDevice() function
(…\DRIVERS\USB\HCD\COMMON\cdevice.cpp):
-in the state machine in the
DEVICE_CONFIG_STATUS_SCHEDULING_GET_DEVICE_DESCRIPTOR_TEST step, I get an
USB_DEVICE_NOT_RESPONDING_ERROR (= 0x5).
-now the state machine goes back to the
DEVICE_CONFIG_STATUS_RESET_AND_ENABLE_PORT state and tries 2 more times
-ultimately after the 3 reties get the same error message the attach fails

The only way that I found to fix that problem is:
-physically unplugging the USB device and plugging it back in
-rebooting the system

Both solutions are not an option for me!

I also tried:
-more reties (10)
-timeout (100ms) before each retry
-powering off and repowering USB port between the reties
-making CHub::HubStatusChangeThread() belief the device was unplugged so do
a DetachDevice() and then (even after powering off and repowering the USB
port) let CHub::HubStatusChangeThread() do the AttachDevice() again

With all of these attempts the problem persisted: the device descriptor
could not be retrieved and the attach failed.

Any help is appreciated

Thanks
-Jochen
点赞  2009-9-16 14:19
期待答案。友情帮顶了,我们不用USB,所以一直没有研究。
点赞  2009-9-16 14:20
终于在万能的google上搜索到了答案,以下是EP93xx的bugfix
实验证明对于s3c24xx也是有用的

The file describes the cause and the fix of Windows CE 5.0's USB device
detection problem during power-up.  

1. USB Device Detection Problem during Powering-Up
   - Connect USB devices to EDB93xx's USB ports when the board is
     powered-off.
   - Power on EDB93xx.
   - Wait until CE 5.0 is fully loaded.
   - One or several USB devices are not detected by CE 5.0.


2. The Cause
   In USB's Open Host Controller Interface (OHCI) Specification, in
   Register HcRhDescriptorA (EP93xx address 0x80020048), Bits 24-31
   are PowerOnToPowerGoodTime. This POTPGT byte specifies the duration
   Host Controller Driver has to wait before accessing a powered-on port
   of the Root Hub.  It is implementation-specific.  The unit of time
   is 2 msec. The duration is calculated as POTPGT x 2msec.

   EP93xx's default value of Register HcRhDescriptorA is 0x02001203.
   The value of the POTPGT byte is 0x02. 2*2msec=4msec. It needs 4 msec
   delay after the Host Controller has supplied power to the Root Hub.
   
   The start-up sequence for EDB93xx's USB host controller should be

   1. Host Controller supplies power to the Root Hub.
   2. Delay 4 msec.
   3. Set Host Controller to Operational state. Access USB ports. Start
      to send SOF tokens...etc.

   CE 5.0's USB driver doesn't implement the code to read the HcRhDescriptorA
   register and deploy the required delay.  
   
   
3. The Fix:
   
   Add the 4-msec delay to CE's USB host driver then rebuild the platform.

   Modify the filebr>   WINCE500\PUBLIC\COMMON\OAK\DRIVERS\USB\HCD\OHCD2\chw.cpp
   Please look at the code "//QQQQQ" below.


BOOL CHW::Initialize(void)
{
..................
    InterruptDisable( m_dwSysIntr ); // Just to make sure this is really ours.
    // Initialize Interrupt. When interrupt id # m_sysIntr is triggered,
    // m_hUsbInterruptEvent will be signaled. Last 2 params must be NULL
    if ( !InterruptInitialize( m_dwSysIntr, m_hUsbInterruptEvent, NULL, NULL) )
{
        DEBUGMSG(ZONE_ERROR, (TEXT("-CHW::Initialize. Error on
InterruptInitializern")));
        return FALSE;
    }

    // Apply power to all root hub ports, just like OHCI.
    m_portBase->HcRhDescriptorA.NPS = 1;
    m_portBase->HcRhStatus.reg= HcRegisters::HcRhStatus:PSC;

//QQQQQQQ Add 4msec delay that is required by Host Controller.
Sleep(4);   
   
    // Start up our IST - the parameter passed to the thread
    // is unused for now
    DEBUGCHK( m_hUsbInterruptThread == NULL &&
              m_fUsbInterruptThreadClosing == FALSE );
    m_hUsbInterruptThread = CreateThread( 0, 0, UsbInterruptThreadStub, this, 0,
NULL );
    if ( m_hUsbInterruptThread == NULL ) {
        DEBUGMSG(ZONE_ERROR, (TEXT("-CHW::Initialize. Error creating
ISTn")));
        return FALSE;
    }
    CeSetThreadPriority( m_hUsbInterruptThread, g_IstThreadPriority );
......................
}
点赞  2009-9-16 15:14
恭喜了!
点赞  2009-9-16 15:41
樓主太強了, 佩服! 佩服!
点赞  2009-9-16 15:52
貌似更改硬件也可以。。。对USB口D+串一101电容接地也可以。。。。
点赞  2009-9-16 15:54
看了一下 wince60 的 code, 它是加上

    Sleep(m_portBase->HcRhDescriptorA.POTPGT * 2);

供大家参考

Paul, Chao @ Techware
点赞  2009-9-16 16:00
Sleep(m_portBase->HcRhDescriptorA.POTPGT * 2); 更加合理,谢谢paul_chao
点赞  2009-9-16 16:08
以前遇到过
标记一下!
点赞  2009-9-16 16:10
这个要收藏!
点赞  2009-9-16 22:22
学习了
点赞  2009-9-16 22:44
学习
点赞  2009-9-16 22:53
标记 学习
点赞  2009-9-16 23:30
学习了,标记
点赞  2009-9-23 10:19
mark  谢谢
点赞  2009-10-16 13:25
Sleep(m_portBase->HcRhDescriptorA.POTPGT * 2);
点赞  2009-10-16 14:16
学习
点赞  2009-11-11 22:48
这个要收藏,
点赞  2009-12-4 16:37
12下一页
电子工程世界版权所有 京B2-20211791 京ICP备10001474号-1 京公网安备 11010802033920号
    写回复