Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

assessing winusb potential

27 views
Skip to first unread message

dmm

unread,
Apr 13, 2007, 11:54:01 AM4/13/07
to
My company manufactures a USB device that may attach to any USB port on the
PC but only one such device is allowed per PC. Our device is currently
driven by an HID kernel-mode driver in the W2k/XP platforms and basically
performs read/write operations aside from the power/pnp functionality.

If I am not mistaken, the WinUSB environment offers an attractive
alternative for us in the Vista platform. Is this true or should we be
looking at UMDF?

If WinUSB is suitable, where may I download the winusb.sys and .dll files
for testing on XP?

Thanks
dmm

Don Burn

unread,
Apr 13, 2007, 11:58:51 AM4/13/07
to
WinUSB is part of the WDK see
http://www.microsoft.com/whdc/DevTools/WDK/WDKpkg.mspx for details how to
get it.


--
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Remove StopSpam to reply

"dmm" <d...@discussions.microsoft.com> wrote in message
news:A8FDE0B4-12BE-42CD...@microsoft.com...

dmm

unread,
Apr 13, 2007, 1:32:09 PM4/13/07
to
Hi Don

I have installed WinDDK 6000 (which targets both vista and xp) on my PC. I
search the entire DDK for files "winusb.sys" and "winusb.dll" but I get no
hits.

Thanks
dmm

Don Burn

unread,
Apr 13, 2007, 1:37:45 PM4/13/07
to
Look in redist\winUSB the files are part of a coinstaller.


--
Don Burn (MVP, Windows DDK)
Windows 2k/XP/2k3 Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
Remove StopSpam to reply

"dmm" <d...@discussions.microsoft.com> wrote in message

news:BA76B8CC-E1C4-4158...@microsoft.com...

dmm

unread,
Apr 17, 2007, 10:16:02 AM4/17/07
to
Thanks Don -- just like you said. During the inf/installation process, the
winusb.sys is extracted and copied to directory "\windows\system32\driver."

dmm

Neel

unread,
Jan 10, 2008, 9:25:00 AM1/10/08
to
Hi dmm,

Please could you tell me, how did you install the winusb.sys?

I tried it 100 times but still not able to succeed.
I followed the instructions given in "WinUsb_HowTo.doc" which is from
Microsoft.
I tried it on internet with many options. But no use.

I am using USB stick (Pen drive) device for installation.

Thanks,
Neel

dmm

unread,
Jan 10, 2008, 1:24:01 PM1/10/08
to
Hi Neel

I checked my notes and this is what I have:

Goto the OSR Online site
http://www.osronline.com/cf.cfm?PageURL=showlists.CFM?list=NTDEV and search
for "winusb." There is a lot of good information there on editing your inf
file so that the co-installers will execute properly.

dmm

Neel

unread,
Jan 11, 2008, 6:18:00 AM1/11/08
to
Thanks dmm for your inputs.

I gone through many posting on the given link but my problem of installing
the winusb.sys driver for the USB Stick is not solved (Using the INF file
details provided my microsoft in "WinUsb_HowTo.doc") .

I am using the following WDK files (WDK - Windows Server 2008 RC1) for the
installation on WinXP:
1). WinUSBCoInstaller.dll
2). WdfCoInstaller01007.dll
3). WUDFUpdate_01007.dll
& INF file from the ""WinUsb_HowTo.doc"

I am installing the driver from "Device Manager->Update Driver" on the
connected "USB Mass storage Device".
Intallation start copying & installing "WinUSBCoInstaller.dll" &
"WdfCoInstaller01007.dll" but at the end, it displays the message dialog
"Cannot install this hardware", "There was a problem installing this
hardware".

Also, when I select the device in Device Manager and check the driver
details, then I found that the WINUSB.SYS is NOT installed (instead the
default USBTOR.SYS is installed).

I think there is problem withe INF file only.
What could be the problem?
Is this INF file not proper?
Is the WDK files not proper?

Thanks
Neel

dmm

unread,
Jan 11, 2008, 10:47:00 AM1/11/08
to

Doron Holan [MSFT]

unread,
Jan 11, 2008, 7:11:53 PM1/11/08
to
try the 1.5 versions from the 6000 WDK .. the installers you have may not be
able to install downlevle (IIRC, rc2 has coinstallers which can install
downlevel properly)

d

--
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.


"Neel" <Ne...@discussions.microsoft.com> wrote in message
news:F2FE6C0A-7267-45B7...@microsoft.com...

Neel

unread,
Jan 12, 2008, 9:21:01 AM1/12/08
to
Thanks dmm.

I have gone through those 2 links earliear.
Again now I tried once again with lot more care but still not able to succeed.

Today for the first time after installation at the end there were no errors
reported and message was The wizard has Finished installing the software for
WinUSB.
But when I check the driver details it shows the old USBTOR.Sys and not the
winusb.sys.

Here is my INF file
------------------------------------------------------------------------------------
[Version]
Signature = "$Windows NT$"
Provider = %ProviderName%
DriverVer=27/11/2007,1.0.0.0
Class = WinUSBControlledDevices
ClassGuid={1BBA3665-5FEB-4670-983A-9A0614839A0B}
;CatalogFile=MyCatFile.cat

; ========== Manufacturer/Models sections ===========

[Manufacturer]
%ProviderName% = MyDevice_WinUSB,NTx86,NTamd64

[MyDevice_WinUSB.NTx86]
%USB\MyDevice.DeviceDesc% =USB_Install, USB\VID_0457&PID_0151&REV_0100

[MyDevice_WinUSB.NTamd64]
%USB\MyDevice.DeviceDesc% =USB_Install, USB\VID_0457&PID_0151&REV_0100

; =================== Installation ===================

[ClassInstall32]
AddReg=_AddReg_ClassInstall

[_AddReg_ClassInstall]
HKR,,,,"%S_DeviceClassDisplayName%"
HKR,,Icon,,"-20"

;[1]
[USB_Install]
Include=winusb.inf
Needs=WINUSB.NT

;[2]
[USB_Install.Services]
Include=winusb.inf
AddService=WinUSB,0x00000002,WinUSB_ServiceInstall
;AddService=%S_DriverName%,0x00000002,WinUSB_ServiceInstall

;[3]
[WinUSB_ServiceInstall]
DisplayName = %WinUSB_SvcDesc%
ServiceType = 1
StartType = 3
ErrorControl = 1
ServiceBinary = %12%\WinUSB.sys
;ServiceBinary = %10%\System32\Drivers\%S_DriverName%.sys

;[4]
[USB_Install.Wdf]
KmdfService=WINUSB, WinUsb_Install
UmdfServiceOrder=WINUSB

[WinUSB_Install]
KmdfLibraryVersion=1.7

;[5]
[USB_Install.HW]
AddReg=Dev_AddReg

[Dev_AddReg]
HKR,,DeviceInterfaceGUIDs,0x10000,"{171FB059-3737-40a6-9225-AC2963FD89F8}"

;[6]
[USB_Install.CoInstallers]
AddReg=CoInstallers_AddReg
CopyFiles=CoInstallers_CopyFiles

[CoInstallers_AddReg]
HKR,,CoInstallers32,0x00010000,"WUDFUpdate_01007.dll","WinUSBCoInstaller.dll","WdfCoInstaller01007.dll,WdfCoInstaller"
;HKR,,CoInstallers32,0x00010000,"WinUSBCoInstaller.dll","WdfCoInstaller01007.dll,WdfCoInstaller"

[CoInstallers_CopyFiles]
WUDFUpdate_01007.dll
WinUSBCoInstaller.dll
WdfCoInstaller01007.dll

[DestinationDirs]
CoInstallers_CopyFiles=11

; ================= Source Media Section =====================
;[7]

;Commented the original code
;[SourceDisksNames]
;1 = %DISK_NAME%,,,\i386
;2 = %DISK_NAME%,,,\amd64
; Added following instead
[SourceDisksNames.x86]
1 = %DISK_NAME%,,,\i386
[SourceDisksNames.NTamd64]
2 = %DISK_NAME%,,,\amd64

[SourceDisksFiles.x86]
WUDFUpdate_01007.dll
WinUSBCoInstaller.dll=1
WdfCoInstaller01007.dll=1

[SourceDisksFiles.NTamd64]
WUDFUpdate_01007.dll
WinUSBCoInstaller.dll=2
WdfCoInstaller01007.dll=2


;******************************************************************************
; Copy Files section
;------------------------------------------------------------------------------
[_CopyFiles_sys]
; ### modify here ###
; Specify the correct file name of the driver binary.
winusb.sys
; If you want to copy a firmware file, activate the following line.
;YourFirmwareFile.ihx


;******************************************************************************
; Destination Directories
;------------------------------------------------------------------------------
;[DestinationDirs]
DefaultDestDir = 12 ; %SystemRoot%\system32\drivers
_CopyFiles_sys = 12

; =================== Strings ===================

[Strings]
ProviderName="Microsoft"
USB\MyDevice.DeviceDesc="WinUSB Device: Kadam"
WinUSB_SvcDesc="WinUSB Driver"
DISK_NAME="WinUSB Driver Disk"
S_DeviceClassDisplayName="WinUSB controlled devices"
S_DriverName="wiusb"
------------------------------------------------------------------------------------

~~~Neelesh

Neel

unread,
Jan 14, 2008, 1:28:01 AM1/14/08
to
Hello Doron,

Is 6000 WDK available for download?
I downloaded the version 1.7 (WDK 6001.17048) from the Microsoft Connect
site http://connect.microsoft.com/

If available, Please can you send me the version 1.5 files to my mail ID
neeles...@wipro.com?

Thanks
Neel

Neel

unread,
Jan 14, 2008, 5:07:03 AM1/14/08
to
Hello Doron,

Today again I am able to install the driver.
For this installation I used:
1) The INF file from USBIO driver (From Thesycon - usbio.sys, which is
similar in functionality of WinUSB) and modified for WinUSB data.
2) winusb.sys - from the Windows folder from my earlier installation.

At the end I am getting the following message

>>>>>>>
There was a problem installing this hardware

Windows cannot load the device driver for this hardware.
The driver may be corrupted or missing. (Code 39)
<<<<<<<<<.

But when I check the driver details in Device Manager, All ther entries are
proper including the driver name "winusb.sys".
The Only diff is that, on the device the yellow circle with "!" symbol.
(Mark of incomplete installation)

Please can you sense what could be the wrong?

Thanks
Neelesh

dmm

unread,
Jan 15, 2008, 1:27:02 PM1/15/08
to
Hi Neel

I have listed the working inf file that I use to install my usb driver on
the xp platform. I made a couple of changes: used your guids and device
identifier. Otherwise it is the same as mine. Note that I used a single
guid and you had two. I also specified a catalog file. Those were the 2
differences I noticied immediately except for the versions numbers of the
DLLs.

dmm

;=================== Version section ====================

[Version]
Signature = "$Windows NT$"

Class = MyDMMDeviceClass
ClassGuid = {1BBA3665-5FEB-4670-983A-9A0614839A0B}
Provider = %ProviderName%
DriverVer = 04/13/2007,4.13.0000.0
CatalogFile = MyDMMWinUSBInstall.cat

; ========== Manufacturer/Models sections ===========

[Manufacturer]
%ProviderName% = MyDevice_WinUSB,NTx86

[MyDevice_WinUSB.NTx86]

%USB\MyDevice.DeviceDesc% =USB_Install, USB\VID_0457&PID_0151&REV_0100

; =================== Installation ===================

[USB_Install]
Include=winusb.inf
Needs=WINUSB.NT

[USB_Install.Services]
Include=winusb.inf
AddService=WinUSB,0x00000002,WinUSB_ServiceInstall

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

[USB_Install.Wdf]
KmdfService=WINUSB, WinUsb_Install

[WinUSB_Install]
KmdfLibraryVersion=1.5

[USB_Install.HW]
AddReg=Dev_AddReg

[Dev_AddReg]
HKR,,DeviceInterfaceGUIDs,0x00010000,"{1BBA3665-5FEB-4670-983A-9A0614839A0B}"

[USB_Install.CoInstallers]
AddReg=CoInstallers_AddReg
CopyFiles=CoInstallers_CopyFiles,NTx86

[CoInstallers_AddReg]
HKR,,CoInstallers32,0x00010000,"WinUSBCoInstaller.dll","WdfCoInstaller01005.dll,WdfCoInstaller"

[CoInstallers_CopyFiles.NTx86]
x86\WinUSBCoInstaller.dll
x86\WdfCoInstaller01005.dll

[DestinationDirs]
CoInstallers_CopyFiles=11

; =================== Strings ===================

[Strings]
ProviderName="MyCompany"
USB\MyDevice.DeviceDesc="My Device using WinUSB only"
WinUSB_SvcDesc="WinUSB driver"

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

Neel

unread,
Jan 16, 2008, 9:25:02 AM1/16/08
to
Thanks dmm.

I tried your INF but again did not succeed.

Please can you send the following files from WDK 6000 i.e. KMDF ver 1.5
1. WdfCoInstaller01005.dll
2. WUDFUpdate_01005.dll
3. WinUSBCoInstaller.dll
to neeles...@wipro.com

I am able to install it on Vista successfully with the following INF.
But I am not able to enumurate it using WinUSB APIs.
Here I am not using the winusb co-installer, instead I am using the
winusb.sys directly from the Windows/System32/Drivers.
This INF is taken from Thesycon (USBIO driver - Third party) and modified.
---------------------------------------------------------------
[Version]
Signature="$Windows NT$"
Provider=%S_Provider%
DriverVer=04/11/2007,2.41.0.0


Class = WinUSBControlledDevices
ClassGuid={1BBA3665-5FEB-4670-983A-9A0614839A0B}


[ClassInstall32]
AddReg=_AddReg_ClassInstall

[_AddReg_ClassInstall]
HKR,,,,"%S_DeviceClassDisplayName%"
HKR,,Icon,,"-20"


[ControlFlags]
; Advanced options can be specified here.
; For details, refer to the Windows DDK documentation.


[Manufacturer]
%S_Mfg%=_Models

[_Models]
%S_DeviceDesc%=_Install, USB\Vid_0457&Pid_0151&Rev_0100


[_Install.ntx86]
CopyFiles=_CopyFiles_sys

[_Install.ntx86.Services]
AddService = %S_DriverName%, 0x00000002, _AddService, _EventLog

[_Install.ntx86.HW]
AddReg=_AddReg_HW

[_AddService]
ServiceType = 1 ; SERVICE_KERNEL_DRIVER
StartType = 3 ; SERVICE_DEMAND_START
ErrorControl = 1 ; SERVICE_ERROR_NORMAL


ServiceBinary = %10%\System32\Drivers\%S_DriverName%.sys

[_EventLog]
AddReg=_EventLog_AddReg

[_EventLog_AddReg]
HKR,,EventMessageFile,%REG_EXPAND_SZ%,"%%SystemRoot%%\System32\IoLogMsg.dll;%%SystemRoot%%\System32\drivers\%S_DriverName%.sys"
HKR,,TypesSupported, %REG_DWORD%,7


[_AddReg_HW]
;HKR,,CleanupWizard_DeviceIdentString,%REG_SZ%,"{DAB6A146-D93E-48ab-B3E5-374AB8FFF277}"
HKR,,DeviceInterfaceGUIDs,0x10000,"{171FB059-3737-40a6-9225-AC2963FD89F8}"

HKR,,PowerStateOnOpen, %REG_DWORD%, 0
HKR,,PowerStateOnClose, %REG_DWORD%, 0
HKR,,MinPowerStateUsed, %REG_DWORD%, 3
HKR,,MinPowerStateUnused, %REG_DWORD%, 3
HKR,,EnableRemoteWakeup, %REG_DWORD%, 0
HKR,,AbortPipesOnPowerDown,%REG_DWORD%, 1
HKR,,UnconfigureOnClose, %REG_DWORD%, 1
HKR,,ResetDeviceOnClose, %REG_DWORD%, 0
HKR,,MaxIsoPackets, %REG_DWORD%, 512
HKR,,ShortTransferOk, %REG_DWORD%, 1
HKR,,RequestTimeout, %REG_DWORD%, 1000
HKR,,SuppressPnPRemoveDlg, %REG_DWORD%, 1


[_CopyFiles_sys]
winusb.sys


[DestinationDirs]
DefaultDestDir = 12 ; %SystemRoot%\system32\drivers
_CopyFiles_sys = 12


[SourceDisksNames.x86]
1=%S_DiskName%,,

[SourceDisksFiles.x86]
winusb.sys=1


[Strings]
REG_SZ = 0x00000000
REG_MULTI_SZ = 0x00010000
REG_EXPAND_SZ = 0x00020000
REG_BINARY = 0x00000001
REG_DWORD = 0x00010001

S_Provider="Neelesh"
S_Mfg="Neelesh"
S_DeviceClassDisplayName="NMK: WinUSB controlled devices"
S_DeviceDesc="NMK: WinUSB Device (USB Mass Storage Device)"
S_DeviceDesc1="NMK:WinUSB Device"
S_DiskName="NMK: WinUSB Driver Disk"
S_DriverName="winusb"

; *** EOF ***
--------------------------------------------------------------

Tim Roberts

unread,
Jan 17, 2008, 11:09:35 PM1/17/08
to
Neel <Ne...@discussions.microsoft.com> wrote:
>
>I tried your INF but again did not succeed.
>
>Please can you send the following files from WDK 6000 i.e. KMDF ver 1.5
>1. WdfCoInstaller01005.dll
>2. WUDFUpdate_01005.dll
>3. WinUSBCoInstaller.dll
>to neeles...@wipro.com

PLEASE don't ask people to violate their license agreements. These files
are all part of the WDK, which you can get on your own.
--
Tim Roberts, ti...@probo.com
Providenza & Boekelheide, Inc.

pswork

unread,
Apr 23, 2008, 2:38:01 PM4/23/08
to
I am trying to install WinUSB on XP. I think I have reviewed all possible
documentation and am stuck. I installed WDK, used a sample INF from a
Microsoft site, the WinUSB co-installer works fine, however the KMDF does
not. I do not have WdfCoInstaller01005.dll on my system nor can I find out
why or where to get it. Can you help?

[CoInstallers_CopyFiles]
WinUSBCoInstaller.dll
WdfCoInstaller01005.dll

Doron Holan [MSFT]

unread,
Apr 23, 2008, 4:19:09 PM4/23/08
to
if you downloaded the latest WDK (6001) it comes with KMDF 1.7, which would
be in wdfcoinstaller01007.dll. even then, you might have the 1.7
coinstaller b/c there was a servicing problem which delayed the release of
the coinstaller. You can download the kmdf coinstaller separately,
http://blogs.msdn.com/doronh/archive/2008/04/17/the-wdf-1-7-cointstallers-are-now-available.aspx

d

--
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.


"pswork" <psw...@discussions.microsoft.com> wrote in message
news:A2FE7491-7DD4-46C9...@microsoft.com...

pswork

unread,
Apr 24, 2008, 12:07:01 PM4/24/08
to
Thanks, that did it. If I may, have another question.

Using a single bulk address with both a IN and OUT endpoint. I am a little
unclear on the device sending data to the host. When does the host send
notifcation to the device that it is expecting data? In particular my device
is monitoring some engine functions and based on some conditions will
asynchronously send status data to the host. I know a USB host initiates IN
data transfers. Does it periodically ask a device if it has any data to send?

Paul

Doron Holan [MSFT]

unread,
Apr 24, 2008, 4:51:00 PM4/24/08
to
no, the host controller by itself will not poll the device asking if it has
data. it is up to you to always have a pending transfer on the IN endpoint
so that the host controller is always asking for data. your device can then
send back data when it has something to send.

d

--
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.


"pswork" <psw...@discussions.microsoft.com> wrote in message

news:78DF78A7-1D8F-4F8E...@microsoft.com...

pswork

unread,
Apr 25, 2008, 9:38:02 AM4/25/08
to
Thanks. I am working with some example code from the micro-controller I am
using. So it appears in the USB interrupt handler that there is an event for
IN and OUT data. On OUT data it calls an endpoint handler that reads the data
sent by the host. But what triggers the IN data event. Does it go like this?

1. My device writes data to the IN endpoint.
2. USB hardware sends the data.
3. The IN data interrupt/event occurs after the data has been sent to the
host. My device can now write more data to the IN endpoint.

I'm still a little confused on when I can safely write to the data to the IN
endpoint and what is the significance of the IN data interrupt.

Doron Holan [MSFT]

unread,
Apr 25, 2008, 8:02:21 PM4/25/08
to
the device can only put bits on the wire when the host asks for it. this is
why the host driver must always pend a transfer on the IN endpoint if the
device is sending data asynchronously outside of the host asking for it
through a protocol (like writing a packet to the OUT endpoint). as for the
exact sequence of events in hw, i am a bit fuzzy, but any book on the usb
protocol will tell you.

d

--
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.


"pswork" <psw...@discussions.microsoft.com> wrote in message

news:FE329BF1-867F-40C5...@microsoft.com...

Tim Roberts

unread,
Apr 25, 2008, 11:31:07 PM4/25/08
to
pswork <psw...@discussions.microsoft.com> wrote:

>Thanks. I am working with some example code from the micro-controller I am
>using. So it appears in the USB interrupt handler that there is an event for
>IN and OUT data. On OUT data it calls an endpoint handler that reads the data
>sent by the host. But what triggers the IN data event. Does it go like this?
>
>1. My device writes data to the IN endpoint.
>2. USB hardware sends the data.
>3. The IN data interrupt/event occurs after the data has been sent to the
>host. My device can now write more data to the IN endpoint.
>
>I'm still a little confused on when I can safely write to the data to the IN
>endpoint and what is the significance of the IN data interrupt.

Usually, the sequence is pretty much as you describe. Most USB
microcontrollers have a flag that tells you if there is still room in an IN
endpoint's buffer. You write as much data as you can, or until the buffer
shows full. Then, you sit and wait (so to speak).

At some point, when your driver gets a read request queued up, the host
controller will send an IN token. The hardware in your microcontroller
will then automatically send the FIFO out the wire.

Now that there is room again, THAT'S usually the point that you get the IN
data interrupt, but the details depend on which microcontroller you are
using.

Pavel A.

unread,
Apr 26, 2008, 6:12:00 AM4/26/08
to
"pswork" <psw...@discussions.microsoft.com> wrote in message
news:FE329BF1-867F-40C5...@microsoft.com...

> Thanks. I am working with some example code from the micro-controller I am
> using. So it appears in the USB interrupt handler that there is an event
> for
> IN and OUT data. On OUT data it calls an endpoint handler that reads the
> data
> sent by the host. But what triggers the IN data event. Does it go like
> this?
>
> 1. My device writes data to the IN endpoint.
> 2. USB hardware sends the data.
> 3. The IN data interrupt/event occurs after the data has been sent to the
> host. My device can now write more data to the IN endpoint.
>
> I'm still a little confused on when I can safely write to the data to the
> IN
> endpoint and what is the significance of the IN data interrupt.

The USB host controller does poll the device periodically -
but it does so only if the driver submits a request to some IN
endpoint. This triggers the polling.

On the device side, the controller receives these IN tokens
and writes the data out if available, otherwise it responds with NAK
(see the USB 2.0 spec, 8.4.6.1).

Regards,
--PA

pswork

unread,
May 13, 2008, 5:40:01 PM5/13/08
to
Thanks. A related question....

I am now pouring over a USB book but the issue is still not clear. When the
hosts sends data to a device, how does it know that the device has had a
chance to read the data from it's USB hardware. What prevents the host from
overwriting data if the device is slow to respond?

Maxim S. Shatskih

unread,
May 13, 2008, 6:08:00 PM5/13/08
to
If the device is not ready to accept the packet, it returns NAK, and the
host _hardware_ (the driver stack does not know on this) retries this packet on
next USB frame.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
ma...@storagecraft.com
http://www.storagecraft.com

"pswork" <psw...@discussions.microsoft.com> wrote in message

news:40C70210-AF65-4F0F...@microsoft.com...

pswork

unread,
May 14, 2008, 12:30:01 PM5/14/08
to
Thanks.
So as I understand it... I am doing bulk transfers, which consists of a
Token, Data and Handshake transaction, in that order. So my device would
respond with a NACK to the Handskake transaction if my device was not ready
to receive? Why is the Data transaction before the Handshake? Seems like it
would test for ready before it sent the data?

Paul

pswork

unread,
May 14, 2008, 6:34:01 PM5/14/08
to
Sorry about multiple responses, I just thought of a better way to rephrase my
basci question.

Still confused about flow control on bulk transfers. Is it performed in
software, hardware or some sort of combination. Basically I want my device to
receive some data and process the data received so far, though there is still
more to come. While proccessing I obviously do no want to lose data.

Maxim S. Shatskih

unread,
May 14, 2008, 9:40:42 PM5/14/08
to
> Still confused about flow control on bulk transfers. Is it performed in
> software, hardware

Hardware.

Tim Roberts

unread,
May 15, 2008, 11:06:51 PM5/15/08
to
pswork <psw...@discussions.microsoft.com> wrote:
>
>So as I understand it... I am doing bulk transfers, which consists of a
>Token, Data and Handshake transaction, in that order. So my device would
>respond with a NACK to the Handskake transaction if my device was not ready
>to receive? Why is the Data transaction before the Handshake? Seems like it
>would test for ready before it sent the data?

Because you don't know how large the transfer is until you get it. You
might be able to handle 32 bytes, but not 512. USB never sends a "length"
beforehand, it just blasts data. If you can't handle all or part of it,
you NAK the handshake.

The difference between bulk and isochronous is that with a bulk pipe, the
host will keep retrying until your device accepts the data. With
isochronous, if you reject it, the packet is gone.

pswork

unread,
May 20, 2008, 12:15:01 PM5/20/08
to
Thanks. So now I am getting packets from the host but eventually (anywhere
between 10-100 packets) my device hangs up. I traced the problem with the USB
example code provided with the devlopment environment (Keil). I'm waiting to
hear back from them but perhaps you have some insight. At some point when I
read the USB buffer, the end of that operation involves sending a Clear
Buffer command to the USB hardware in order to receive the next packet. The
code for the Clear Buffer command send the command then immediately waits for
the Command Buffer register flag to be set. Sometime this flag never gets
set, thus hanging the system.

I have tried to make my application as simple as possible to debug. I am not
processing any of the data, bascially just sitting in the loop reading any
data that comes across, but I still see the problem.

Any ideas?

Maxim S. Shatskih

unread,
May 20, 2008, 2:24:31 PM5/20/08
to
I cannot understand why Clear Buffer is needed and what is it. I do not
remember such command in the spec, so, it is probably some proprietary command
of yours.

Once more: on bulk writes from host to device, device sees arriving
packets. After each packet, it must respond with ACK/NAK/STALL.

STALL is fatal error on pipe.
ACK means - OK, device have consumed the packet OK, the host will send the
next bytes of the pipe data as the next packet.
NAK means - sorry, device is not ready to accept more data on this pipe,
but will be ready soon when some internal conditions on the device (buffer
fullness) will change. After the device have responded with NAK, the host will
_retransmit the same packet again and again_ till STALL or ACK will be returned
by the device.

Also note that USB bulk transfers have the notion of logical frame
boundaries (unlike TCP which has none). The logical frame boundaries
established by the host can be sensed by the device, and can carry some
semantics the device can use.

The host establish a logical frame end on the end of each IRP's buffer.

The device senses this frame end when it either gets the zero-length
packet, or the packet of the incomplete length.

All of this is in host+device hardware and in device firmware, and is
hidden from the host software at all.

--
Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
ma...@storagecraft.com
http://www.storagecraft.com

"pswork" <psw...@discussions.microsoft.com> wrote in message
news:E3052006-2548-43E1...@microsoft.com...

0 new messages