xieshigen
驱动牛犊
驱动牛犊
  • 注册日期2003-08-01
  • 最后登录2003-11-11
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
阅读:2068回复:22

usb驱动问题

楼主#
更多 发布于:2003-08-11 14:48
  我最近开发了一个基于USB1.1的数据采集卡,使用的是cypress的SL811HS,驱动用的是该公司的开发包中的驱动,在测试时发现该驱动只能在使用intel 82801的USB主机控制器的主板上用,而在实达这些牌子的机器上用的不是这种控制器,发现无法装上该驱动。不知道各位大侠遇到过这种情况没有?是驱动的原因吗?
  我把oney上的例子程序改了以后也是这种情况!

最新喜欢:

sunmaculasunmac...
flytomoon
驱动巨牛
驱动巨牛
  • 注册日期2003-07-09
  • 最后登录2004-10-18
  • 粉丝1
  • 关注1
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
沙发#
发布于:2003-08-11 16:41
觉得应该和主机控制器没关系,因为他作驱动的时候是按照USB1。1协议写的,所以和主机控制器没关系,估计还是你自己开发板的设置或系统的设置有问题。是2000的系统吗?
xieshigen
驱动牛犊
驱动牛犊
  • 注册日期2003-08-01
  • 最后登录2003-11-11
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
板凳#
发布于:2003-08-12 11:59
  是2000系统。我也觉得应该和主板关系不大,但是驱动在那些不用intel控制器的主板上就是装不上。我觉得我的硬件应该也是符合USB协议的啊?有什么方法可以调试这种问题吗?
flytomoon
驱动巨牛
驱动巨牛
  • 注册日期2003-07-09
  • 最后登录2004-10-18
  • 粉丝1
  • 关注1
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
地板#
发布于:2003-08-12 12:13
插上之后有发现新硬件吗?
xieshigen
驱动牛犊
驱动牛犊
  • 注册日期2003-08-01
  • 最后登录2003-11-11
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
地下室#
发布于:2003-08-12 13:42
有发现新硬件,不过说是我的驱动不含有相关的硬件信息??
flytomoon
驱动巨牛
驱动巨牛
  • 注册日期2003-07-09
  • 最后登录2004-10-18
  • 粉丝1
  • 关注1
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
5楼#
发布于:2003-08-12 13:50
很可能是INF里的PID,VID和驱动中提供的不符造成的。
xieshigen
驱动牛犊
驱动牛犊
  • 注册日期2003-08-01
  • 最后登录2003-11-11
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
6楼#
发布于:2003-08-12 14:11
这个是一样的,我设的都是0x4c3,而且在intel的主板上也没问题。
flytomoon
驱动巨牛
驱动巨牛
  • 注册日期2003-07-09
  • 最后登录2004-10-18
  • 粉丝1
  • 关注1
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
7楼#
发布于:2003-08-12 14:15
你的枚举过程怎么样啊?
xieshigen
驱动牛犊
驱动牛犊
  • 注册日期2003-08-01
  • 最后登录2003-11-11
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
8楼#
发布于:2003-08-12 14:31
以下是驱动的inf
您帮我看看,非常感谢!

[Version]
Signature=$CHICAGO$
Class=Image
ClassGuid={6BDD1FC6-810F-11D0-BEC7-08002BE2092F}
Provider=%MFGNAME%

[Manufacturer]
%MFGNAME%=DeviceList

[DestinationDirs]
DefaultDestDir=10,System32\\Drivers

[SourceDisksFiles]
USBCapture.sys=1

[SourceDisksNames]
1=%INSTDISK%,,,objfre\\i386

[DeviceList]
%DESCRIPTION%=DriverInstall,USB\\VID_04CE&PID_04CE

;------------------------------------------------------------------------------
;  Windows 2000 Sections
;------------------------------------------------------------------------------

; TODO Add a LogConfig command to the following install section if this is a legacy device

[DriverInstall.NT]
CopyFiles=DriverCopyFiles

[DriverCopyFiles]
USBCapture.sys,,,2

[DriverInstall.NT.Services]
AddService=USBCAPTURE,2,DriverService

[DriverService]
ServiceType=1
StartType=3
ErrorControl=1
ServiceBinary=%10%\\system32\\drivers\\USBCapture.sys

[DriverInstall.nt.hw]
AddReg=DriverHwAddReg

[DriverHwAddReg]
HKR,,FriendlyName,,%FRIENDLYNAME%

;------------------------------------------------------------------------------
;  Windows 98 Sections
;------------------------------------------------------------------------------

[DriverInstall]
AddReg=DriverAddReg
CopyFiles=DriverCopyFiles
; TODO Add a LogConfig command and section if this is a legacy device

[DriverAddReg]
HKR,,DevLoader,,*ntkern
HKR,,NTMPDriver,,USBCapture.sys

[DriverInstall.HW]
AddReg=DriverHwAddReg

;------------------------------------------------------------------------------
;  String Definitions
;------------------------------------------------------------------------------

[Strings]
MFGNAME=\"xsgHardware\"
INSTDISK=\"xsgHardware Installation Disc\"
DESCRIPTION=\"USB Image Captue\"
FRIENDLYNAME=\"usb image capture\"
xieshigen
驱动牛犊
驱动牛犊
  • 注册日期2003-08-01
  • 最后登录2003-11-11
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
9楼#
发布于:2003-08-12 14:36
下面是我的adddevice和startdevice的函数,是不是主要就和这两个函数有关啊?

NTSTATUS AddDevice(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT pdo)
{ // AddDevice
PAGED_CODE();

NTSTATUS status;

// Create a functional device object to represent the hardware we\'re managing.

PDEVICE_OBJECT fdo;
#define xsize sizeof(DEVICE_EXTENSION)

//xsg: add the device name
UNICODE_STRING devname;
RtlInitUnicodeString(&devname, L\"\\\\DosDevices\\\\USBCapture\");
status = IoCreateDevice(DriverObject, xsize, &devname,
FILE_DEVICE_UNKNOWN, FILE_DEVICE_UNKNOWN, FALSE, &fdo);

//status = IoCreateDevice(DriverObject, xsize, NULL,
// FILE_DEVICE_UNKNOWN, FILE_DEVICE_SECURE_OPEN, FALSE, &fdo);
if (!NT_SUCCESS(status))
{ // can\'t create device object
KdPrint((DRIVERNAME \" - IoCreateDevice failed - %X\\n\", status));
return status;
} // can\'t create device object

PDEVICE_EXTENSION pdx = (PDEVICE_EXTENSION) fdo->DeviceExtension;

// From this point forward, any error will have side effects that need to
// be cleaned up. Using a try-finally block allows us to modify the program
// easily without losing track of the side effects.

__try
{ // finish initialization
pdx->DeviceObject = fdo;
pdx->Pdo = pdo;
IoInitializeRemoveLock(&pdx->RemoveLock, 0, 0, 0);
pdx->state = STOPPED; // device starts in the stopped state

// Declare the buffering method we\'ll use for read/write requests

fdo->Flags |= DO_DIRECT_IO;

// Link our device object into the stack leading to the PDO

pdx->LowerDeviceObject = IoAttachDeviceToDeviceStack(fdo, pdo);
if (!pdx->LowerDeviceObject)
{ // can\'t attach device
KdPrint((DRIVERNAME \" - IoAttachDeviceToDeviceStack failed\\n\"));
status = STATUS_DEVICE_REMOVED;
__leave;
} // can\'t attach device

// Set power management flags in the device object

fdo->Flags |= DO_POWER_PAGABLE;

// Register a device interface

status = IoRegisterDeviceInterface(pdo, &GUID_DEVINTERFACE_USBCAPTURE, NULL, &pdx->ifname);
if (!NT_SUCCESS(status))
{ // unable to register interface
KdPrint((DRIVERNAME \" - IoRegisterDeviceInterface failed - %8.8lX\\n\", status));
__leave;
} // unable to register interface

// Indicate that our initial power state is D0 (fully on). Also indicate that
// we have a pagable power handler (otherwise, we\'ll never get idle shutdown
// messages!)

pdx->syspower = PowerSystemWorking;
pdx->devpower = PowerDeviceD0;
POWER_STATE state;
state.DeviceState = PowerDeviceD0;
PoSetPowerState(fdo, DevicePowerState, state);

// Clear the \"initializing\" flag so that we can get IRPs

fdo->Flags &= ~DO_DEVICE_INITIALIZING;
} // finish initialization
__finally
{ // cleanup side effects
if (!NT_SUCCESS(status))
{ // need to cleanup
if (pdx->ifname.Buffer)
RtlFreeUnicodeString(&pdx->ifname);
if (pdx->LowerDeviceObject)
IoDetachDevice(pdx->LowerDeviceObject);
IoDeleteDevice(fdo);
} // need to cleanup
} // cleanup side effects

return status;
} // AddDevice
//--------------------------------------------------

NTSTATUS StartDevice(PDEVICE_OBJECT fdo)
{ // StartDevice
PAGED_CODE();
NTSTATUS status;
PDEVICE_EXTENSION pdx = (PDEVICE_EXTENSION) fdo->DeviceExtension;

URB urb; // URB for use in this subroutine

// Read our device descriptor. The only thing this skeleton does with it is print
// debugging messages with the string descriptors.

UsbBuildGetDescriptorRequest(&urb, sizeof(_URB_CONTROL_DESCRIPTOR_REQUEST), USB_DEVICE_DESCRIPTOR_TYPE,
0, 0, &pdx->dd, NULL, sizeof(pdx->dd), NULL);
status = SendAwaitUrb(fdo, &urb);
if (!NT_SUCCESS(status))
{
KdPrint((DRIVERNAME \" - Error %X trying to read device descriptor\\n\", status));
return status;
}


// Read the descriptor of the first configuration. This requires two steps. The first step
// reads the fixed-size configuration descriptor alone. The second step reads the
// configuration descriptor plus all imbedded interface and endpoint descriptors.

USB_CONFIGURATION_DESCRIPTOR tcd;
UsbBuildGetDescriptorRequest(&urb, sizeof(_URB_CONTROL_DESCRIPTOR_REQUEST), USB_CONFIGURATION_DESCRIPTOR_TYPE,
0, 0, &tcd, NULL, sizeof(tcd), NULL);
status = SendAwaitUrb(fdo, &urb);
if (!NT_SUCCESS(status))
{
KdPrint((DRIVERNAME \" - Error %X trying to read configuration descriptor 1\\n\", status));
return status;
}

ULONG size = tcd.wTotalLength;
PUSB_CONFIGURATION_DESCRIPTOR pcd = (PUSB_CONFIGURATION_DESCRIPTOR) ExAllocatePool(NonPagedPool, size);
if (!pcd)
{
KdPrint((DRIVERNAME \" - Unable to allocate %X bytes for configuration descriptor\\n\", size));
return STATUS_INSUFFICIENT_RESOURCES;
}

__try
{
UsbBuildGetDescriptorRequest(&urb, sizeof(_URB_CONTROL_DESCRIPTOR_REQUEST), USB_CONFIGURATION_DESCRIPTOR_TYPE,
0, 0, pcd, NULL, size, NULL);
status = SendAwaitUrb(fdo, &urb);
if (!NT_SUCCESS(status))
{
KdPrint((DRIVERNAME \" - Error %X trying to read configuration descriptor 1\\n\", status));
return status;
}
                                  

// Locate the descriptor for the one and only interface we expect to find

PUSB_INTERFACE_DESCRIPTOR pid = USBD_ParseConfigurationDescriptorEx(pcd, pcd,
-1, -1, -1, -1, -1);
ASSERT(pid);
                                  

// Create a URB to use in selecting a configuration.

USBD_INTERFACE_LIST_ENTRY interfaces[2] = {
{pid, NULL},
{NULL, NULL}, // fence to terminate the array
};

PURB selurb = USBD_CreateConfigurationRequestEx(pcd, interfaces);
if (!selurb)
{
KdPrint((DRIVERNAME \" - Unable to create configuration request\\n\"));
return STATUS_INSUFFICIENT_RESOURCES;
}

__try
{

// Verify that the interface describes exactly the endpoints we expect

if (pid->bNumEndpoints != 2)
{
KdPrint((DRIVERNAME \" - %d is the wrong number of endpoints\\n\", pid->bNumEndpoints));
return STATUS_DEVICE_CONFIGURATION_ERROR;
}

PUSB_ENDPOINT_DESCRIPTOR ped = (PUSB_ENDPOINT_DESCRIPTOR) pid;
ped = (PUSB_ENDPOINT_DESCRIPTOR) USBD_ParseDescriptors(pcd, tcd.wTotalLength, ped, USB_ENDPOINT_DESCRIPTOR_TYPE);
if (!ped || ped->bEndpointAddress != 0x1 || ped->bmAttributes != USB_ENDPOINT_TYPE_BULK || ped->wMaxPacketSize != 64)
{
KdPrint((DRIVERNAME \" - Endpoint has wrong attributes\\n\"));
return STATUS_DEVICE_CONFIGURATION_ERROR;
}
++ped;
ped = (PUSB_ENDPOINT_DESCRIPTOR) USBD_ParseDescriptors(pcd, tcd.wTotalLength, ped, USB_ENDPOINT_DESCRIPTOR_TYPE);
if (!ped || ped->bEndpointAddress != 0x82 || ped->bmAttributes != USB_ENDPOINT_TYPE_BULK || ped->wMaxPacketSize != 64)
{
KdPrint((DRIVERNAME \" - Endpoint has wrong attributes\\n\"));
return STATUS_DEVICE_CONFIGURATION_ERROR;
}
++ped;

PUSBD_INTERFACE_INFORMATION pii = interfaces[0].Interface;

// Initialize the maximum transfer size for each of the endpoints
// TODO remove these statements if you\'re happy with the default
// value provided by USBD.

pii->Pipes[0].MaximumTransferSize = PAGE_SIZE;
pii->Pipes[1].MaximumTransferSize = PAGE_SIZE;

// Submit the set-configuration request

status = SendAwaitUrb(fdo, selurb);
if (!NT_SUCCESS(status))
{
KdPrint((DRIVERNAME \" - Error %X trying to select configuration\\n\", status));
return status;
}

// Save the configuration and pipe handles

pdx->hconfig = selurb->UrbSelectConfiguration.ConfigurationHandle;
pdx->Ep1Out = pii->Pipes[0].PipeHandle;
pdx->Ep2In = pii->Pipes[1].PipeHandle;

// TODO If you have an interrupt endpoint, now would be the time to
// create an IRP and URB with which to poll it continuously

// Transfer ownership of the configuration descriptor to the device extension

pdx->pcd = pcd;
pcd = NULL;
}
__finally
{
ExFreePool(selurb);
}

}
__finally
{
if (pcd)
ExFreePool(pcd);
}

return STATUS_SUCCESS;
} // StartDevice

flytomoon
驱动巨牛
驱动巨牛
  • 注册日期2003-07-09
  • 最后登录2004-10-18
  • 粉丝1
  • 关注1
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
10楼#
发布于:2003-08-12 15:14
以下是驱动的inf
您帮我看看,非常感谢!

[Version]
Signature=$CHICAGO$
Class=Image
ClassGuid={6BDD1FC6-810F-11D0-BEC7-08002BE2092F}
Provider=%MFGNAME%

[Manufacturer]
%MFGNAME%=DeviceList

[DestinationDirs]
DefaultDestDir=10,System32\\Drivers

[SourceDisksFiles]
USBCapture.sys=1

[SourceDisksNames]
1=%INSTDISK%,,,objfre\\i386

[DeviceList]
%DESCRIPTION%=DriverInstall,USB\\VID_04CE&PID_04CE

;------------------------------------------------------------------------------
;  Windows 2000 Sections
;------------------------------------------------------------------------------

; TODO Add a LogConfig command to the following install section if this is a legacy device

[DriverInstall.NT]
CopyFiles=DriverCopyFiles

[DriverCopyFiles]
USBCapture.sys,,,2

[DriverInstall.NT.Services]
AddService=USBCAPTURE,2,DriverService

[DriverService]
ServiceType=1
StartType=3
ErrorControl=1
ServiceBinary=%10%\\system32\\drivers\\USBCapture.sys

[DriverInstall.nt.hw]
AddReg=DriverHwAddReg

[DriverHwAddReg]
HKR,,FriendlyName,,%FRIENDLYNAME%

;------------------------------------------------------------------------------
;  Windows 98 Sections
;------------------------------------------------------------------------------

[DriverInstall]
AddReg=DriverAddReg
CopyFiles=DriverCopyFiles
; TODO Add a LogConfig command and section if this is a legacy device

[DriverAddReg]
HKR,,DevLoader,,*ntkern
HKR,,NTMPDriver,,USBCapture.sys

[DriverInstall.HW]
AddReg=DriverHwAddReg

;------------------------------------------------------------------------------
;  String Definitions
;------------------------------------------------------------------------------

[Strings]
MFGNAME=\"xsgHardware\"
INSTDISK=\"xsgHardware Installation Disc\"
DESCRIPTION=\"USB Image Captue\"
FRIENDLYNAME=\"usb image capture\"
 



你的CLASS为什么不定义成USB? 你的PID,VID在哪里?
xieshigen
驱动牛犊
驱动牛犊
  • 注册日期2003-08-01
  • 最后登录2003-11-11
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
11楼#
发布于:2003-08-12 15:36
  Class一定要定义成USB吗?我发现定义成Image以后,热插拔都不用点“拔下或弹出硬件”了。
VID和PID在如下项中:


  [DeviceList]
  %DESCRIPTION%=DriverInstall,USB\\VID_04CE&PID_04CE

flytomoon
驱动巨牛
驱动巨牛
  • 注册日期2003-07-09
  • 最后登录2004-10-18
  • 粉丝1
  • 关注1
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
12楼#
发布于:2003-08-12 15:41
 Class一定要定义成USB吗?我发现定义成Image以后,热插拔都不用点“拔下或弹出硬件”了。
VID和PID在如下项中:


  [DeviceList]
  %DESCRIPTION%=DriverInstall,USB\\VID_04CE&PID_04CE

 


我没试过,建议换成USB试试,是不是现象如故?
xieshigen
驱动牛犊
驱动牛犊
  • 注册日期2003-08-01
  • 最后登录2003-11-11
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
13楼#
发布于:2003-08-12 15:53
我们这的机器都是intel的控制器,都没问题,给别人以后发现这个问题的,所以我还无法测试,呵呵。
  我的驱动要在98下用的话,是不是用98ddk编译一下就可以?

  
flytomoon
驱动巨牛
驱动巨牛
  • 注册日期2003-07-09
  • 最后登录2004-10-18
  • 粉丝1
  • 关注1
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
14楼#
发布于:2003-08-12 15:57
我们这的机器都是intel的控制器,都没问题,给别人以后发现这个问题的,所以我还无法测试,呵呵。
  我的驱动要在98下用的话,是不是用98ddk编译一下就可以?

  


就把sys.c用DDK编译一下放到系统里就行了。
xieshigen
驱动牛犊
驱动牛犊
  • 注册日期2003-08-01
  • 最后登录2003-11-11
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
15楼#
发布于:2003-08-12 16:06
不是整个目录吗project吗?我的project有好多文件啊,没有sys.c这个文件。
flytomoon
驱动巨牛
驱动巨牛
  • 注册日期2003-07-09
  • 最后登录2004-10-18
  • 粉丝1
  • 关注1
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
16楼#
发布于:2003-08-12 16:08
不是整个目录吗project吗?我的project有好多文件啊,没有sys.c这个文件。


我说得SYS.C是驱动程序的源程序,DDK编译完后变成*.sys。
xieshigen
驱动牛犊
驱动牛犊
  • 注册日期2003-08-01
  • 最后登录2003-11-11
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
17楼#
发布于:2003-08-12 16:18
知道了,我在2000下装98DDK来编译98下的驱动应该没问题吧?
flytomoon
驱动巨牛
驱动巨牛
  • 注册日期2003-07-09
  • 最后登录2004-10-18
  • 粉丝1
  • 关注1
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
18楼#
发布于:2003-08-12 16:19
知道了,我在2000下装98DDK来编译98下的驱动应该没问题吧?


不行,必须在98下。
xieshigen
驱动牛犊
驱动牛犊
  • 注册日期2003-08-01
  • 最后登录2003-11-11
  • 粉丝0
  • 关注0
  • 积分0分
  • 威望0点
  • 贡献值0点
  • 好评度0点
  • 原创分0分
  • 专家分0分
19楼#
发布于:2003-08-12 16:29
知道啦,非常感谢大侠!
上一页
游客

返回顶部