-
Notifications
You must be signed in to change notification settings - Fork 0
Windows Backend
IMPORTANT: NEC/Renesas USB 3.0 users, please upgrade your drivers to version 2.1.16.0 or later. Older versions of the driver have a bug that prevents libusbx from accessing devices.
This project adds Windows platform support to the libusbx Open Source library, in order to help developers easily communicate with USB devices on Windows. Currently it supports the WinUSB and HID drivers for generic USB device access (with HID keyboards and mice not accessible, as they are reserved by the OS) as well as (since version 1.0.13) the libusb-win32 and libusbK drivers.
The Windows backend is part of the libusbx official release. Usage of the backend with the WinUSB or HID drivers should be considered fairly stable at this stage. On the other hand, because they were introduced very recently and are not yet feature complete, usage of the libusb-win32 and libusbK drivers should be considered EXPERIMENTAL.
Pre-built binary snapshots are provided in the release directory under /<current-version>/Windows/
.
These are provided AS IS for your convenience, generated for the following environments:
- Microsoft Visual Studio and DDK/WDK → MS32(32 bit) and MS64 (64 bit) directories
- MinGW -> MinGW32 (32 bit) and MinGW64 (64 bit) directories
7z
format so you may have to install 7-zip.
Supported systems are all Windows platforms, starting with Windows XP, and including 64 bit versions, with the following exceptions:
- Windows 2003 (Microsoft does not support WinUSB on 32bit/64bit Windows 2003)
- Windows XP 64 bit (Microsoft does not officially support WinUSB on 64bit Windows XP)
libusbx supports USB 3.0 controllers and devices on Windows. Proprietary controller drivers for Windows 7 and earlier as well as the Microsoft controller xHCI driver for Windows 8 are supported.
If you are using a NEC/Renesas USB 3.0 controller, such as the fairly widespread uPD720200
/uPD720200A
, remember to make sure that your controller drivers are version 2.1.16.0 or later. Older versions of the drivers are known to have a bug that prevents access to USB devices.
libusbx has been tested under the various Windows 8 Previews (Developer, Consumer, Release) for both 32 and 64 bit and no issues were found.
A .NET
version of libusbx, called LibUsbDotNet, based on libusbx 1.0, has also been developed by Travis Robinson. If you plan to use libusbx in a .NET
project, make sure you check http://libusbdotnet.sourceforge.net or http://sourceforge.net/projects/libusbdotnet/
If your target device is not HID, you install a driver before you can communicate with it using libusbx. Currently, this means installing one of Microsoft's WinUSB
, libusb-win32 or libusbK drivers. Two options are available:
-
Recommended: Use the most recent version of Zadig, an Automated Driver Installer GUI application for
WinUSB
,libusb-win32
andlibusbK
.. - Alternatively, if you are only interested in
WinUSB
, you can download the WinUSB driver files and customize theinf
file for your device.
The handling of composite devices under Windows is done with multiple drivers, descendants of the usbccgp.sys
driver (Composite Generic Parent), as this is the default for the OS. For more info, see "2. How Windows handles a composite device" at http://www.cygnal.org/ubb/Forum9/HTML/001050.html. If needed, it is also possible to replace the composite parent driver to access the device.
Because Windows does not provide a native poll()
function, and cygwin is the only development environment that provides such a call, the use of libusbx file descriptors with poll()
on cygwin is NOT supported. In a future version of libusbx, we should provide better handling of native Windows events, but this will require a redesign of the libusbx API, so it won't occur before libusbx 2.0.
-
WinUSB
cannot be used to send an actual reset command to an USB device. This is a limitation of WinUSB. -
WinUSB
andlibusbK
cannot be used to set a device configuration that is different from the first one. This is a limitation of KMDF USB I/O Target. -
WinUSB
does not support multiple concurrent applications (as per the MSDN documentation). -
WinUSB
does not support isochronous transfers. - HID keyboards and mice cannot be accessed using the native HID driver as Windows reserves exclusive access to them.
- The HID Report Descriptors provided by libusbx are recomposed and may present minor differences from the actual ones, as the Windows HID API does not allow to read them directly from the device.
- Because there is no native
poll()
on Windows, the ability to return externally pollable file descriptors on Windowslibusb_get_pollfd()
returns an error. - If you use a composite device, and plan to install a libusbx compatible driver for any of the interfaces, you should ensure that your driver package adds a Device Interface GUID in the registry, as proper enumeration of composite devices in libusbx depends on it. This is typically achieved by adding something like the following in your inf:
HKR,,DeviceInterfaceGUIDs,0x00010000,{12345678-1234-1234-1234-123456789ABC}
-
How to Use WinUSB to Communicate with a USB Device & WinUSB (Winusb.sys) Installation.
Note that the inf file given in the howto has a typo. If you don't changeSourceDisksFiles.NTamd64
toSourceDisksFiles.amd64
, the driver installation will fail to copy the required DLLs on 64 bit systems... - Using WinUSB for User-Mode to USB Device Communication
- WinUSB User-Mode Client Support Routines
- Microsoft's USB Core Team Blog (including resources on instrumenting the USB stack in Windows 7)
- additional information about Windows Co-Installers
- Finding Memory Leaks Using the CRT Library