Help for USB Driver sample

Hi,

I’m learning the WDK with the samples. I want to write a custom driver for
an usb device which contains one interface and three endpoints (Interrupt
IN, Bulk Out, and Bulk IN). I want to know which driver sample from wdk that
I can take as a base code for this requirement. Should I go for kmdf or umdf
is enough. What are all the customizations I’ve to do in the code other than
the steps given in the document Sample Drivers for the User-Mode Driver
Framework(UMDF-samp.doc). It’ll be great if you can help me in this as I’m
really struggling to find out where to start. Thanks.

A good place to start is the OSR USB FX2 Sample board:

https://www.osronline.com/store/moreinfo.cfm?Product_ID=84

Good luck,

mm

My RAC Account wrote:

I’m learning the WDK with the samples. I want to write a custom driver
for an usb device which contains one interface and three endpoints
(Interrupt IN, Bulk Out, and Bulk IN). I want to know which driver
sample from wdk that I can take as a base code for this requirement.
Should I go for kmdf or umdf is enough. What are all the
customizations I’ve to do in the code other than the steps given in
the document Sample Drivers for the User-Mode Driver
Framework(UMDF-samp.doc). It’ll be great if you can help me in this as
I’m really struggling to find out where to start.

Do you really need a driver for this? The easiest solution is to use
WinUSB and access the endpoints directly from your user-mode applications.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Thanks for the replies.
The link talks about the WDM Sample driver. I read that WDF is the recent one.
Can you please explain me more about using WinUSB. I went thru the document ‘How to Use WinUSB to Communicate with a USB Device’. I tried installing the basic winusb driver first based on the instructions given in the document. But, i’m always getting the error message ‘This device cannot start. (Code 10)’.

I’m fed up of this error message. Earlier I tried with the Umdf usb samples with our company board to test it and got this error. Then we purchased the OSR FX2 sample board and getting the same error with Fx2 device also !!!

Can you pl help me. i’m struggling a lot with this error for many days. I didnt understand how to debug the umdf drivers. I didnt want to try installing in my development machine and so, i’m trying to install the umdf driver in a XP installed vm ware work station. Should I install WDK in the vm station in order to debug?
In the wdk docs, its mentioned that if we enable the debugger in the registry, the computer can detect the debugger after the driver manager starts the driver host process for the device.
In my case, the device start fails. Then how’ll I make sure the DriverEntry is called or not??

Do you really need a driver for this? The easiest solution is to use
WinUSB and access the endpoints directly from your user-mode applications

what do you mean by user-mode application here? There are many code snippets given in the winusb document on How to use the WinUSB API. Under which file should I place it? is there any sample code for user-mode application using winusb?

Sorry for asking more questions. Need help!!!

Thanks.

How are you installing the driver (winusb, umdf, etc)? using devcon, add new hardware wizard, etc?

d

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Tuesday, March 16, 2010 4:35 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Help for USB Driver sample

Thanks for the replies.
The link talks about the WDM Sample driver. I read that WDF is the recent one.
Can you please explain me more about using WinUSB. I went thru the document ‘How to Use WinUSB to Communicate with a USB Device’. I tried installing the basic winusb driver first based on the instructions given in the document. But, i’m always getting the error message ‘This device cannot start. (Code 10)’.

I’m fed up of this error message. Earlier I tried with the Umdf usb samples with our company board to test it and got this error. Then we purchased the OSR FX2 sample board and getting the same error with Fx2 device also !!!

Can you pl help me. i’m struggling a lot with this error for many days. I didnt understand how to debug the umdf drivers. I didnt want to try installing in my development machine and so, i’m trying to install the umdf driver in a XP installed vm ware work station. Should I install WDK in the vm station in order to debug?
In the wdk docs, its mentioned that if we enable the debugger in the registry, the computer can detect the debugger after the driver manager starts the driver host process for the device.
In my case, the device start fails. Then how’ll I make sure the DriverEntry is called or not??

Do you really need a driver for this? The easiest solution is to use
WinUSB and access the endpoints directly from your user-mode
applications

what do you mean by user-mode application here? There are many code snippets given in the winusb document on How to use the WinUSB API. Under which file should I place it? is there any sample code for user-mode application using winusb?

Sorry for asking more questions. Need help!!!

Thanks.


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

When I plug in the usb device, it automatically detects the new hardware and the Device Manager installation proceeds. I’m choosing manual installation and giving the path where the umdf/winusb package is present.

Are you choosing manual installation from the found new hw popup ? or choosing manual installation by going to device manager and picking add new hw wizard or update driver software? Have you looked at the setup logs to see what is going on?

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Tuesday, March 16, 2010 4:47 PM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Help for USB Driver sample

When I plug in the usb device, it automatically detects the new hardware and the Device Manager installation proceeds. I’m choosing manual installation and giving the path where the umdf/winusb package is present.


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Everytime, I uninstall the driver first from the device manager and then install by choosing the manual installation from the found new hw popup.

When I tried to install the winUSB with the OSR Fx2 device, there is a error message saying Error 1168: Element not found.

Have lot of doubts abt how to debug the umdf driver which I asked in my previous email. If I try thru from windbg from host maching by configuring the vm pipe, etc, I’m getting reconnecting to host msg and it never connects. Do I need to install WDK in my vm work station to debug umdf driver?

[2010/03/16 15:07:48 296.2]
#-199 Executing “C:\WINDOWS\system32\rundll32.exe” with command line: rundll32.exe newdev.dll,ClientSideInstall \.\pipe\PNP_Device_Install_Pipe_0.{59D902E5-A878-4806-839C-A91E77E2B517}
#I060 Set selected driver.
#-019 Searching for hardware ID(s): usb\vid_0547&pid_1002&rev_0000,usb\vid_0547&pid_1002
#-018 Searching for compatible ID(s): usb\class_ff&subclass_00&prot_00,usb\class_ff&subclass_00,usb\class_ff
#I022 Found “USB\VID_0547&PID_1002” in C:\WINDOWS\inf\oem0.inf; Device: “UMDF Sample Driver for OSR USB Fx2 Learning Kit”; Driver: “UMDF Sample Driver for OSR USB Fx2 Learning Kit”; Provider: “Microsoft Internal (WDF:UMDF)”; Mfg: “Microsoft Internal (WDF:UMDF)”; Section name: “OsrUsb_Install”.
#I087 Driver node not trusted, rank changed from 0x00000001 to 0x00008001.
#I023 Actual install section: [OsrUsb_Install.NT]. Rank: 0x00008001. Effective driver date: 03/16/2010.
#-166 Device install function: DIF_SELECTBESTCOMPATDRV.
#I063 Selected driver installs from section [OsrUsb_Install] in “c:\windows\inf\oem0.inf”.
#I320 Class GUID of device remains: {78A1C341-4539-11D3-B88D-00C04FAD5171}.
#I060 Set selected driver.
#I058 Selected best compatible driver.
#I060 Set selected driver.
#-019 Searching for hardware ID(s): usb\vid_0547&pid_1002&rev_0000,usb\vid_0547&pid_1002
#-018 Searching for compatible ID(s): usb\class_ff&subclass_00&prot_00,usb\class_ff&subclass_00,usb\class_ff
#I022 Found “USB\VID_0547&PID_1002” in C:\WINDOWS\inf\oem0.inf; Device: “UMDF Sample Driver for OSR USB Fx2 Learning Kit”; Driver: “UMDF Sample Driver for OSR USB Fx2 Learning Kit”; Provider: “Microsoft Internal (WDF:UMDF)”; Mfg: “Microsoft Internal (WDF:UMDF)”; Section name: “OsrUsb_Install”.
#I087 Driver node not trusted, rank changed from 0x00000001 to 0x00008001.
#I023 Actual install section: [OsrUsb_Install.NT]. Rank: 0x00008001. Effective driver date: 03/16/2010.
#-019 Searching for hardware ID(s): usb\vid_0547&pid_1002&rev_0000,usb\vid_0547&pid_1002
#-018 Searching for compatible ID(s): usb\class_ff&subclass_00&prot_00,usb\class_ff&subclass_00,usb\class_ff
#I022 Found “USB\VID_0547&PID_1002” in e:\testdrivers\winusbtest\winsubTest.inf; Device: “Test using WinUSB only”; Driver: “Test using WinUSB only”; Provider: “MyWinUsbTest”; Mfg: “MyWinUsbTest”; Section name: “USB_Install”.
#I087 Driver node not trusted, rank changed from 0x00000001 to 0x00008001.
#I023 Actual install section: [USB_Install]. Rank: 0x00008001. Effective driver date: 01/01/1601.
#-166 Device install function: DIF_SELECTBESTCOMPATDRV.
#I063 Selected driver installs from section [OsrUsb_Install] in “c:\windows\inf\oem0.inf”.
#I320 Class GUID of device remains: {78A1C341-4539-11D3-B88D-00C04FAD5171}.
#I060 Set selected driver.
#I058 Selected best compatible driver.
#-124 Doing copy-only install of “USB\VID_0547&PID_1002\6&22194588&0&2”.
#W334 Failed to verify catalog when scanning file queue. Error 1168: Element not found.
#E360 An unsigned or incorrectly signed file “c:\windows\inf\oem0.inf” for driver “UMDF Sample Driver for OSR USB Fx2 Learning Kit” will be installed (Policy=Ignore). Error 1168: Element not found.
#W187 Install failed, attempting to restore original files.
#E360 An unsigned or incorrectly signed file “c:\windows\inf\oem0.inf” for driver “UMDF Sample Driver for OSR USB Fx2 Learning Kit” will be installed (Policy=Ignore). Error 1168: Element not found.
#-024 Copying file “e:\testdrivers\usbfx2umdffin\WUDFOsrUsbFx2.dll” to “C:\WINDOWS\system32\DRIVERS\UMDF\WUDFOsrUsbFx2.dll”.
#E360 An unsigned or incorrectly signed file “e:\testdrivers\usbfx2umdffin\WUDFOsrUsbFx2.dll” for driver “UMDF Sample Driver for OSR USB Fx2 Learning Kit” will be installed (Policy=Ignore). Error 1168: Element not found.
#-336 Copying file “e:\testdrivers\usbfx2umdffin\WudfUpdate_01009.dll” to “C:\WINDOWS\system32\WudfUpdate_01009.dll” via temporary file “C:\WINDOWS\system32\SET6.tmp”.
#E360 An unsigned or incorrectly signed file “e:\testdrivers\usbfx2umdffin\WudfUpdate_01009.dll” for driver “UMDF Sample Driver for OSR USB Fx2 Learning Kit” will be installed (Policy=Ignore). Error 1168: Element not found.
#-336 Copying file “e:\testdrivers\usbfx2umdffin\WdfCoInstaller01009.dll” to “C:\WINDOWS\system32\WdfCoInstaller01009.dll” via temporary file “C:\WINDOWS\system32\SET9.tmp”.
#E360 An unsigned or incorrectly signed file “e:\testdrivers\usbfx2umdffin\WdfCoInstaller01009.dll” for driver “UMDF Sample Driver for OSR USB Fx2 Learning Kit” will be installed (Policy=Ignore). Error 1168: Element not found.
#-336 Copying file “e:\testdrivers\usbfx2umdffin\WinUsbCoinstaller2.dll” to “C:\WINDOWS\system32\WinUsbCoinstaller2.dll” via temporary file “C:\WINDOWS\system32\SETC.tmp”.
#E360 An unsigned or incorrectly signed file “e:\testdrivers\usbfx2umdffin\WinUsbCoinstaller2.dll” for driver “UMDF Sample Driver for OSR USB Fx2 Learning Kit” will be installed (Policy=Ignore). Error 1168: Element not found.
#-166 Device install function: DIF_REGISTER_COINSTALLERS.
#I056 Coinstallers registered.
#-166 Device install function: DIF_INSTALLINTERFACES.
#-011 Installing section [OsrUsb_Install.NT.Interfaces] from “c:\windows\inf\oem0.inf”.
#I054 Interfaces installed.
#-166 Device install function: DIF_INSTALLDEVICE.
#I123 Doing full install of “USB\VID_0547&PID_1002\6&22194588&0&2”.
#I163 Device not started: Device has problem: 0x0a: CM_PROB_FAILED_START.
#I121 Device install of “USB\VID_0547&PID_1002\6&22194588&0&2” finished successfully.

xxxxx@gmail.com wrote:

The link talks about the WDM Sample driver. I read that WDF is the recent one.
Can you please explain me more about using WinUSB. I went thru the document ‘How to Use WinUSB to Communicate with a USB Device’. I tried installing the basic winusb driver first based on the instructions given in the document. But, i’m always getting the error message ‘This device cannot start. (Code 10)’.

Then you must have made a mistake. Installing WinUSB is just as simple
as tweaking the sample INF file to insert your device’s VID and PID, and
creating your own GUID.

How did you install this? Do you actually have the device plugged in to
the VM you are trying to debug?

> Do you really need a driver for this? The easiest solution is to use
> WinUSB and access the endpoints directly from your user-mode applications
>

what do you mean by user-mode application here?

Seriously?

The whole reason we write a driver is so that our device can be used by
applications. We don’t buy computers to run drivers, we buy computers
to run applications. So, presumably, you have some application in mind
that will need to access your device. Your job, then, is to find a way
to connect the application with the USB pipes on the device.

There are many ways to do that, although a driver needs to be involved
at some point. Starting with XP, Microsoft has already provided a
generic USB driver that allows you to talk to your USB pipes from an
application. That’s what WinUSB is. No additional driver work is
required. You just call WinUsb_WritePipe and WinUsb_ReadPipe to your
heart’s content. All you need to do is adjust a simple INF file to
insert your device’s VID and PID (so the system knows to use the WINUSB
driver), and create a new GUID so your application can find the driver.
It could not be easier.

There are many code snippets given in the winusb document on How to use the WinUSB API. Under which file should I place it? is there any sample code for user-mode application using winusb?

You use the SetupDi APIs to find your device, you use CreateFile to open
a file handle, you call WinUsb_Initialize to connect that to WinUSB,
then you start reading and writing.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Hi Tim,

Thanks for the detailed explanation and your patience.
I’m sorry for my questions that may be too silly. I’m new to driver
development, c/c++ and windows environment.

I’ve missed to create a new GUID and used the one present in the sample.
Probabily that’s the problem. I’ll try the steps given by you.
Thanks.
On Wed, Mar 17, 2010 at 11:10 AM, Tim Roberts wrote:

> xxxxx@gmail.com wrote:
> > The link talks about the WDM Sample driver. I read that WDF is the recent
> one.
> > Can you please explain me more about using WinUSB. I went thru the
> document ‘How to Use WinUSB to Communicate with a USB Device’. I tried
> installing the basic winusb driver first based on the instructions given in
> the document. But, i’m always getting the error message ‘This device cannot
> start. (Code 10)’.
> >
>
> Then you must have made a mistake. Installing WinUSB is just as simple
> as tweaking the sample INF file to insert your device’s VID and PID, and
> creating your own GUID.
>
> How did you install this? Do you actually have the device plugged in to
> the VM you are trying to debug?
>
> >> Do you really need a driver for this? The easiest solution is to use
> >> WinUSB and access the endpoints directly from your user-mode
> applications
> >>
> >
> > what do you mean by user-mode application here?
>
> Seriously?
>
> The whole reason we write a driver is so that our device can be used by
> applications. We don’t buy computers to run drivers, we buy computers
> to run applications. So, presumably, you have some application in mind
> that will need to access your device. Your job, then, is to find a way
> to connect the application with the USB pipes on the device.
>
> There are many ways to do that, although a driver needs to be involved
> at some point. Starting with XP, Microsoft has already provided a
> generic USB driver that allows you to talk to your USB pipes from an
> application. That’s what WinUSB is. No additional driver work is
> required. You just call WinUsb_WritePipe and WinUsb_ReadPipe to your
> heart’s content. All you need to do is adjust a simple INF file to
> insert your device’s VID and PID (so the system knows to use the WINUSB
> driver), and create a new GUID so your application can find the driver.
> It could not be easier.
>
> > There are many code snippets given in the winusb document on How to use
> the WinUSB API. Under which file should I place it? is there any sample code
> for user-mode application using winusb?
>
> You use the SetupDi APIs to find your device, you use CreateFile to open
> a file handle, you call WinUsb_Initialize to connect that to WinUSB,
> then you start reading and writing.
>
> –
> Tim Roberts, xxxxx@probo.com
> Providenza & Boekelheide, Inc.
>
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>

Hi Tim,

I’m getting more basic doubts.
Is the user-mode application we write by calling the winusb api is what the
Driver for the USB device?
When the new usb hardware is detected by system, what am I supposed to
install? just the Winusb?
Do I need to install the WinUSB driver seperately? or just adding the
winusbcoinstaller in the driver inf (application) enough?

is there any sample code for user-mode application using winusb? Is it
correct to take the umd-skeleton sample driver code to add the winusb api
calls for read/write?
Pl forgive me if the questions are wrong or redundant. I have the deadline
till this friday to test our company’s usb device to check its functionality
to read/write in bulk mode and to found out the speed its giving.

thanks.

On Wed, Mar 17, 2010 at 11:35 AM, My RAC Account wrote:

> Hi Tim,
>
> Thanks for the detailed explanation and your patience.
> I’m sorry for my questions that may be too silly. I’m new to driver
> development, c/c++ and windows environment.
>
> I’ve missed to create a new GUID and used the one present in the sample.
> Probabily that’s the problem. I’ll try the steps given by you.
> Thanks.
> On Wed, Mar 17, 2010 at 11:10 AM, Tim Roberts wrote:
>
>> xxxxx@gmail.com wrote:
>> > The link talks about the WDM Sample driver. I read that WDF is the
>> recent one.
>> > Can you please explain me more about using WinUSB. I went thru the
>> document ‘How to Use WinUSB to Communicate with a USB Device’. I tried
>> installing the basic winusb driver first based on the instructions given in
>> the document. But, i’m always getting the error message ‘This device cannot
>> start. (Code 10)’.
>> >
>>
>> Then you must have made a mistake. Installing WinUSB is just as simple
>> as tweaking the sample INF file to insert your device’s VID and PID, and
>> creating your own GUID.
>>
>> How did you install this? Do you actually have the device plugged in to
>> the VM you are trying to debug?
>>
>> >> Do you really need a driver for this? The easiest solution is to use
>> >> WinUSB and access the endpoints directly from your user-mode
>> applications
>> >>
>> >
>> > what do you mean by user-mode application here?
>>
>> Seriously?
>>
>> The whole reason we write a driver is so that our device can be used by
>> applications. We don’t buy computers to run drivers, we buy computers
>> to run applications. So, presumably, you have some application in mind
>> that will need to access your device. Your job, then, is to find a way
>> to connect the application with the USB pipes on the device.
>>
>> There are many ways to do that, although a driver needs to be involved
>> at some point. Starting with XP, Microsoft has already provided a
>> generic USB driver that allows you to talk to your USB pipes from an
>> application. That’s what WinUSB is. No additional driver work is
>> required. You just call WinUsb_WritePipe and WinUsb_ReadPipe to your
>> heart’s content. All you need to do is adjust a simple INF file to
>> insert your device’s VID and PID (so the system knows to use the WINUSB
>> driver), and create a new GUID so your application can find the driver.
>> It could not be easier.
>>
>> > There are many code snippets given in the winusb document on How to use
>> the WinUSB API. Under which file should I place it? is there any sample code
>> for user-mode application using winusb?
>>
>> You use the SetupDi APIs to find your device, you use CreateFile to open
>> a file handle, you call WinUsb_Initialize to connect that to WinUSB,
>> then you start reading and writing.
>>
>> –
>> Tim Roberts, xxxxx@probo.com
>> Providenza & Boekelheide, Inc.
>>
>>
>> —
>> NTDEV is sponsored by OSR
>>
>> For our schedule of WDF, WDM, debugging and other seminars visit:
>> http://www.osr.com/seminars
>>
>> To unsubscribe, visit the List Server section of OSR Online at
>> http://www.osronline.com/page.cfm?name=ListServer
>>
>
>

My RAC Account wrote:

I’m getting more basic doubts.
Is the user-mode application we write by calling the winusb api is
what the Driver for the USB device?

The driver, in this case, is winusb.sys. Provided by Microsoft in the
WDK, but shipped by you along with your custom INF.

When the new usb hardware is detected by system, what am I supposed to
install? just the Winusb?

Yes. You point the system to your driver package, which includes only
your INF and the three coinstallers.

Do I need to install the WinUSB driver seperately? or just adding the
winusbcoinstaller in the driver inf (application) enough?

The WinUSB coinstaller will do the hard work of installing the driver.

is there any sample code for user-mode application using winusb? Is it
correct to take the umd-skeleton sample driver code to add the winusb
api calls for read/write?

Jan Axelson has some examples on her web site:
http://www.lvr.com/winusb.htm

Her sample INF files are spreading around the world as the canonical
example of how to do WinUSB.

The WinUSB API is very easy to use, assuming you understand USB terms
like vendor requests. You can get hints from the UMDF skeletons, but
the hardest part is the rather wordy chunk of SetupDi calls you need to
find the interface in the first place.

Pl forgive me if the questions are wrong or redundant. I have the
deadline till this friday to test our company’s usb device to check
its functionality to read/write in bulk mode and to found out the
speed its giving.

Your schedule allowed one week to figure out how to do a driver for a
USB device, for someone with no previous driver experience? That shows
a pretty clear project management failure. Please contact me off-list
if you are interested in contracting to get the basic work done.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.