WINCE5.0上USB设备的自动检测
2011-03-14 17:26
399 查看
最近调试USB WIFI模块,采用RALINK的芯片RT2701制作的USB WIFI模组,发现WINCE启动后,需要重插拨一次WIFI模组,系统才能识别到USB模块,换用U盘,也是一样。由于到时候需要内置WIFI模组,到时候就无法手动插拨模组了,因此必须实现USB设备的自动检测。
如果能够实现在启动系统后,切换USB HOST的电源,然后再上电,应该就能够识别USB设备了,另外也可以通过上下拉USB的数据线实现,但是由于硬件电路已经接死了,故无法通过硬件的机制实现。
网上同样有人遇到类似的问题,有老外给出如下解决方案:
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 );
......................
}
这是public下的一段代码,在d:/wince500/public/common/oak/drivers/usb/hcd/ohcd2/Chw.cpp以及d:/wince500/public/common/oak/drivers/usb/hcd/uhcd/Chw.cpp文件的BOOL CHW::Initialize()函数中添加一个4ms的延时,然后build and sysgen,重新下载NK,问题解决。
看来这是微软USB驱动的一个小的BUG。CSDN上有牛人Paul_chao翻了WINCE6.0的源码,发现6.0中使用的如下语句:
Sleep(m_portBase->HcRhDescriptorA.POTPGT * 2);
由于编译一次需要1个小时以上,这里仅测试了使用Sleep(4),即已解决问题。
如果能够实现在启动系统后,切换USB HOST的电源,然后再上电,应该就能够识别USB设备了,另外也可以通过上下拉USB的数据线实现,但是由于硬件电路已经接死了,故无法通过硬件的机制实现。
网上同样有人遇到类似的问题,有老外给出如下解决方案:
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 );
......................
}
这是public下的一段代码,在d:/wince500/public/common/oak/drivers/usb/hcd/ohcd2/Chw.cpp以及d:/wince500/public/common/oak/drivers/usb/hcd/uhcd/Chw.cpp文件的BOOL CHW::Initialize()函数中添加一个4ms的延时,然后build and sysgen,重新下载NK,问题解决。
看来这是微软USB驱动的一个小的BUG。CSDN上有牛人Paul_chao翻了WINCE6.0的源码,发现6.0中使用的如下语句:
Sleep(m_portBase->HcRhDescriptorA.POTPGT * 2);
由于编译一次需要1个小时以上,这里仅测试了使用Sleep(4),即已解决问题。
相关文章推荐
- Linux下C语言来检测USB设备以及自动区分U盘和硬盘并自动挂载
- 如何实现WinCE系统中USB设备自动检测
- usb转rs232驱动无效,已经电脑自动扫描检测硬件改动.设备无法运行错误代码10
- Linux下C语言来检测USB设备以及自动挂载
- WINCE5.0上USB设备的自动检测
- 两种自动检测USB设备的添加和移除的方法
- (转) 两种自动检测USB设备的添加和移除的方法
- 两种自动检测USB设备的添加和移除的方法
- 如何实现WinCE系统中USB设备自动检测
- USB 设备的自动检测 /proc/bus/usb
- WINCE5.0上USB设备的自动检测 2410验证
- USB 设备热插拔的检测
- Android系统插入USB设备自动授权不弹出对话框
- 写的很好的一篇LINUX下USB设备检测的文章
- 树莓派USB存储设备自动挂载
- linux app应用如何检测USB设备热插拔
- QT5 检测 usb设备插拔
- android中usb设备驱动不能自动创建设备节点
- Windows平台下Qt4与Qt5检测USB设备插拔
- 开发wince下的usb音频设备驱动总结