Aug 15, 2010

How to Install Winusb.sys as the Device's Function Driver

  1. Install the Windows Driver Kit.
  2. Create a driver package folder on the machine to which the USB device is connected. For example c:\UsbDevice.
  3. Copy the WinUSB co-installer (WinusbcoinstallerX.dll) from the WinDDK\BuildNumber\redist\winusb to the driver package folder.

    The WinUSB co-installer (Winusbcoinstaller.dll) installs WinUSB on the target system, if necessary. The WDK includes three versions of the co-installer depending on the system architecture: x86-based, x64-based, and Itanium-based systems. They are all named WinusbcoinstallerX.dll and are located in the appropriate subdirectory in the WinDDK\BuildNumber\redist\winusb folder.

  4. Copy the KMDF co-installer (WdfcoinstallerXXX.dll) from the WinDDK\BuildNumber\redist\wdf to the driver package folder.

    The KMDF co-installer (WdfcoinstallerXXX.dll) installs the correct version of KMDF on the target system, if necessary. The version of WinUSB co-installer must match the KMDF co-installer because KMDF-based client drivers, such as Winusb.sys, require the corresponding version of the KMDF framework to be installed properly on the system. For example, Winusbcoinstaller2.dll requires KMDF version 1.9, which is installed by Wdfcoinstaller01009.dll. The x86 and x64 versions of WdfcoinstallerXXX.dll are included with the WDK under the WinDDK\BuildNumber\redist\wdf folder. The following table shows the WinUSB co-installer and the associated KMDF co-installer to use on the target system.

    Use the following table to determine the WinUSB co-installer and the associated KMDF co-installer.

    WinUSB co-installerKMDF library versionKMDF co-installer
    Winusbcoinstaller.dllRequires KMDF version 1.5 or later.

    Wdfcoinstaller01005.dll

    Wdfcoinstaller01007.dll

    Wdfcoinstaller01009.dll

    Winusbcoinstaller2.dllRequires KMDF version 1.9 or later.Wdfcoinstaller01009.dll

  5. Write an INF that installs Winusb.sys as the function driver for the USB device.
  6. Create a signed catalog file for the package. This file is required to install WinUSB on x64 versions of Windows Vista.
  7. Attach the USB device to your computer.
  8. Run devcon.exe as follows:

    devcon.exe install inf_file.inf "hardware_id"

    • devcon.exe can be found in the \WinDDK\build_number\tools\devcon\\devcon.exe folder.
    • inf_file indicates the name of your INF.
    • hardware_id indicates the hardware identifier for the device provided by the device vendor. This can be found in the INF. For example, for the OSR USB-FX2 Learning Kit device from OSR, the identifier is USB\Vid_0547&Pid_1002.

      Note Because the hardware id contains '&', make sure that you specify the hardware id within quotes.

  9. Alternatively, you can use the Device Manager to install the driver. Follow the instructions on the Update Driver Software wizard and choose manual installation. You will need to provide the location of the driver package folder to complete the installation.
INF file sample:

Addendum to Thread "Calling WinUSB from an application"

Hi. Just for completeness sake, see below for a revised version of the inf file located in the following thread: http://www.osronline.com/showThread.cfm?link=102204 It was pointed out to me by Zhao Yu from Motica that the inf file needed to be revised for copying files correctly in a cross-platform manner (by that I mean 32-bit vs. 64-bit). Zhao quotes from a WDK 6000 document: "The CopyFiles directive does not support decorating a file-list-section name with a system-defined platform extension (.nt, .ntx86, .ntia64, or .ntamd64). ". Thus, the coinstaller in the previous inf file couldn't copy the two dlls on some platforms. Plus, he requested to have a SourceDiskFiles section put in as well. The inf template below puts in place his changes. So, this should be a better inf file to use to get started... For those of you who haven't followed this thread topic, this inf file is a template that can be used to install WinUSB as the primary device driver for a device (just replace the strings, GUIDs, VID and PID). To install, place your tweaked version of this inf file in a directory, then make two subdirectories, "amd64" and "x86", and place the co-installer dlls (found in the WDK) for those particular platforms in their respective directory and off you go... Thanks Zhao! --Brian Hindman ; ================ Version section ================= [Version] Signature = "$Windows NT$" Class = MyDeviceClass ClassGuid = {11111111-2222-3333-4444-555555555555} Provider = %ProviderName% DriverVer = 05/22/2007, 6.0.1.0 ; ========== Manufacturer/Models sections =========== [Manufacturer] %ProviderName% = MyDevice_WinUSB,NTx86,NTia64,NTamd64 [MyDevice_WinUSB.NTx86] %USB\MyDevice.DeviceDesc% =USB_Install, USB\VID_xxxx&PID_xxxx [MyDevice_WinUSB.NTamd64] %USB\MyDevice.DeviceDesc% =USB_Install, USB\VID_xxxx&PID_xxxx ; ================== 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,"{55555555-4444-3333-2222-111111111111}" [USB_Install.CoInstallers] AddReg = CoInstallers_AddReg CopyFiles = CoInstallers_CopyFiles [CoInstallers_AddReg] HKR, , CoInstallers32, 0x00010000, "WinUSBCoInstaller.dll", "WdfCoInstaller01005.dll, WdfCoInstaller" [CoInstallers_CopyFiles] WinUSBCoInstaller.dll WdfCoInstaller01005.dll [SourceDisksNames] 1 = %MediaDescription% [SourceDisksFiles] WinUSBCoInstaller.dll = 1, x86 WdfCoInstaller01005.dll = 1, x86 [SourceDisksFiles.amd64] WinUSBCoInstaller.dll = 1, amd64 WdfCoInstaller01005.dll = 1, amd64 [DestinationDirs] CoInstallers_CopyFiles = 11 ; ==================== Strings ===================== [Strings] ProviderName = "My Company" USB\MyDevice.DeviceDesc="My Device using WinUSB only" MediaDescription = "My Installation Media" WinUSB_SvcDesc = "WinUSB Driver Service"<br />from: <span class="Apple-style-span" style="font-family: Tahoma, geneva, lucida, 'lucida grande', arial, helvetica, sans-serif; white-space: normal; "><a href="http://www.osronline.com/showthread.cfm?link=109991">http://www.osronline.com/showthread.cfm?link=109991</a> and msdn</span>

No comments:

Post a Comment