Hi.

I've got a driver based on the FX2 sample. When plugging in the hardware,
the my driver starts loading and wudfhost is running. I've used the debugger
to break into it and see my driver calling
IWDFUsbTargetFactory::CreateUsbTargetDevice. That's failing with
ERROR_BAD_DEVICE. According to the docs, this would be an error code
returned by WinUSB_Initialize.

The device name is \\.\UMDFCtrlDev-3e5e32b1-51b0-11dd-813d-0010dc4ece8d from
a previous call to IWDFDevice::RetrieveDeviceName.

I've even tried taking the FX2 driver source as is and just modifiying the
vendor ID and PID to match my hardware, realizing that it would fail later in
the process after WinUSB initialized. The result is the same.

Any guesses as to what I might have wrong?

Thanks,
Steve

Re: WinUsb_Initialize failing with ERROR_BAD_DEVICE by Doron

Doron
Tue Jul 15 12:37:17 CDT 2008

are you sure you are running on a usb enumerated stack and not on a root
enumerated device? how did you install your driver? using the add new hw
wizard? or in response to the OS asking you for drivers when you plugged in
the usb device?

--
Please do not send e-mail directly to this alias. this alias is for
newsgroup purposes only.
This posting is provided "AS IS" with no warranties, and confers no rights.


"sschefter" <sschefter@discussions.microsoft.com> wrote in message
news:3BC09474-FE63-43BD-A959-883DB5F1CC0B@microsoft.com...
> Hi.
>
> I've got a driver based on the FX2 sample. When plugging in the hardware,
> the my driver starts loading and wudfhost is running. I've used the
> debugger
> to break into it and see my driver calling
> IWDFUsbTargetFactory::CreateUsbTargetDevice. That's failing with
> ERROR_BAD_DEVICE. According to the docs, this would be an error code
> returned by WinUSB_Initialize.
>
> The device name is \\.\UMDFCtrlDev-3e5e32b1-51b0-11dd-813d-0010dc4ece8d
> from
> a previous call to IWDFDevice::RetrieveDeviceName.
>
> I've even tried taking the FX2 driver source as is and just modifiying the
> vendor ID and PID to match my hardware, realizing that it would fail later
> in
> the process after WinUSB initialized. The result is the same.
>
> Any guesses as to what I might have wrong?
>
> Thanks,
> Steve


Re: WinUsb_Initialize failing with ERROR_BAD_DEVICE by sschefter

sschefter
Tue Jul 15 13:32:02 CDT 2008

"Doron Holan [MSFT]" wrote:
> are you sure you are running on a usb enumerated stack and not on a root
> enumerated device? how did you install your driver? using the add new hw
> wizard? or in response to the OS asking you for drivers when you plugged in
> the usb device?

It is in response to the OS asking for drivers when the device is plugged in
(Found New Hardware Wizard). I failed to mention that this is on XP SP3 as
well.

I'm beginning to think that the problem is that I don't have a proper stack
all the way down through the reflector and into winusb. I've added a break
to the start up of wudfhost.exe and enter into windbg. I also load the
wudfext.ddl for debugging extensions. When my driver is at the point that
will call CreateUsbTargetDevice(), I display the stacks with !umdevstacks.
It shows nothing. And yet WudfHost.exe is still running.

It's as if I have an error in the stack instructions in my .inf, but I don't
see anything wrong there (copied below). And I get the same result with the
sample FX2 driver (with the VID and PID in the .inf modified to match my
hardware).

Steve

[Version]
Signature="$Windows NT$"
Class=%ClassName%
ClassGuid={05B49F23-71E4-4228-9A44-A324B8175CE8}
Provider=%Provider%
DriverVer=07/15/2008,6.0.6001.18000
CatalogFile=wudf.cat

[Manufacturer]
%Provider%=SteveUsb,NTx86

[SteveUsb.NTx86]
%DeviceName%=SteveUsb_Install, USB\VID_ABCD&PID_CDE2

[ClassInstall32]
AddReg=Class_RegistryAdd

[Class_RegistryAdd]
HKR,,,,%ClassName%
HKR,,Icon,,"-10"

[SourceDisksFiles]
SteveUsb.dll=1
WudfUpdate_01007.dll=1
WdfCoInstaller01007.dll=1
WinUsbCoinstaller.dll=1

[SourceDisksNames]
1 = %MediaDescription%

; =================== UMDF SteveUsb Device ==================================

[SteveUsb_Install.NT]
CopyFiles=UMDriverCopy
Include=WINUSB.INF ; Import sections from WINUSB.INF
Needs=WINUSB.NT ; Run the CopyFiles & AddReg
directives for WinUsb.INF

[SteveUsb_Install.NT.hw]
AddReg=Usb_Device_AddReg

[SteveUsb_Install.NT.Services]
AddService=WUDFRd,0x000001fa,WUDFRD_ServiceInstall ; flag 0x2 sets this as
the service for the device
AddService=WinUsb,0x000001f8,WinUsb_ServiceInstall ; this service is
installed because its a filter.

[SteveUsb_Install.NT.Wdf]
KmdfService=WINUSB, WinUsb_Install
UmdfDispatcher=WinUsb
UmdfService=SteveUsb, SteveUsb_Install
UmdfServiceOrder=SteveUsb

[SteveUsb_Install.NT.CoInstallers]
AddReg=CoInstallers_AddReg
CopyFiles=CoInstallers_CopyFiles

[WinUsb_Install]
KmdfLibraryVersion = 1.7

[SteveUsb_Install]
UmdfLibraryVersion=1.7.0
DriverCLSID = "{0865b2b0-6b73-428f-a3ea-2172832d6bfc}"
ServiceBinary = "%12%\UMDF\SteveUsb.dll"

[Usb_Device_AddReg]
HKR,,"LowerFilters",0x00010008,"WinUsb" ; FLG_ADDREG_TYPE_MULTI_SZ |
FLG_ADDREG_APPEND
;HKR,,"DeviceIdleEnabled",0x00010001,1
;HKR,,"SystemWakeEnabled",0x00010001,1

[WUDFRD_ServiceInstall]
DisplayName = %WudfRdDisplayName%
ServiceType = 1
StartType = 3
ErrorControl = 1
ServiceBinary = %12%\WUDFRd.sys
LoadOrderGroup = Base

[WinUsb_ServiceInstall]
DisplayName = %WinUsb_SvcDesc%
ServiceType = 1
StartType = 3
ErrorControl = 1
ServiceBinary = %12%\WinUSB.sys

[CoInstallers_AddReg]
HKR,,CoInstallers32,0x00010000,"WudfUpdate_01007.dll",
"WinUsbCoinstaller.dll", "WdfCoInstaller01007.dll,WdfCoInstaller"

[CoInstallers_CopyFiles]
WudfUpdate_01007.dll
WdfCoInstaller01007.dll
WinUsbCoinstaller.dll

[DestinationDirs]
UMDriverCopy=12,UMDF ; copy to driversMdf
CoInstallers_CopyFiles=11

[UMDriverCopy]
SteveUsb.dll

; =================== Generic ==================================

[Strings]
MediaDescription="USB Driver Installation Media"
ClassName="SteveUsb"
WudfRdDisplayName="Windows Driver Foundation - User-mode Driver Framework
Reflector"
DeviceName="My Device"
WinUsb_SvcDesc="WinUSB Driver"