wiki:windows_backend

Version 33 (modified by pbatard, 3 years ago) (diff)

--

Windows backend

About

The aim of this project is to bring a Windows backend to the mainline libusb 1.0 branch, so that libusb 1.0 can easily be used on Windows platforms.

Status

The Windows backend is now in beta stages. As of 2010.01.13, it should include the main libusb v1.0 features, apart from isochronous transfers (which is a limitation from the WinUSB Microsoft API) and concurrent access support.
It currently supports all Windows platforms from Windows XP, including 64 bit versions of Windows (untested on Windows 2003).

Source

The current development Windows backend is available in the libusb main git repository under libusb-pbatard.git.

For those not familiar with git, here are the git commands you can use retrieve and compile the Windows branch:

git clone git://git.libusb.org/libusb-pbatard.git ; retrieve development branch (this only needs to be done once)
git pull                                          ; keep in sync with the remote tree

On Windows, if you don't want to use git on the commandline, you can use TortoiseGit to access and keep in sync with the git repository.
Note that before you can install TortoiseGit you need to install MSysGit and make sure that, during the installation of MSysGit, when prompted to adjust the PATH environment, you select "Run Git from the Windows Command Prompt" (2nd option). Also, in the general settings of TortoiseGit, the MSysGit path must point to the MSysGit bin directory (eg: C:Program Files (x86)Gitin")

To compile this source, pthread-win32 is also required, except for cygwin, where pthread should be available by default.
For convenience, precompiled versions of pthread-win32 for 32 bit and 64 bit Windows platforms are provided here.

The following development environment are currently supported for libusb 1.0 on Windows:

To create projects relying on libusb 1.0, please refer to how the executables are compiled for the various environments above.

Finally, to access your USB devices with libusb-winusb, you need to download the WinUSB driver files, customize the .inf for your device, and then install the driver.
For more information on how to setup the WinUSB driver for your device, please see the WinUSB Driver Installation page or see the README file that comes with the driver.

Development Considerations

  • The method of dealing with USB devices in the first release will be WinUSB only, with provisions for other access modes to be included later.
  • Windows' handling of composite devices is done with multiple drivers (VID_####&PID_####&MI_##), descendants of the usbccgp.sys driver (Composite Generic Parent). For more info, see "2. How Windows handles a composite device" at http://www.cygnal.org/ubb/Forum9/HTML/001050.html.
  • Because Windows does not provide a native poll() function, and cygwin is the only development environment that provides such a call, the use of libusb file descriptors with poll() on cygwin is NOT supported. If you do need to manually poll the libusb file descriptors on Windows, you can use the undocumented _libusb_poll() function (same parameters as poll() on UNIX), but please note that the function will only accept libusb file descriptors and it is not possible to _libusb_poll() to poll for generic file descriptors. We might provide native Windows Event to wait on in a future version of libusb for Windows.

Current Issues

To Do

  • multithreading/concurrent access
  • automated WinUSB driver installation?
  • hotplug detection

Done

  • HID
  • device enumeration
  • descriptors retrieval
  • composite devices & interface selection
  • poll and pipe
  • control transfers
  • bulk/interrupt transfers
  • device reset
  • transfer cancellation
  • MSVC compatibility

Development's status log

  • [2010.01.14 and later] Please consult the git log or the raw Activity Log.
  • [2009.12.13 to 2010.01.13] Tracked on the the Work-In-Progress SVN Repository (no longer maintained).
  • [2009.12.12]
    • Back on track after resubmission of git patches and timer related fixes.
  • [2009.12.04]
  • [2009.12.03]
    • matching of libusb enumerated devices with WinUSB GUID devices (WIP)
    • WinUSB driver cleanup & documentation.
  • [2009.12.02]
    • WinUSB generic device installation (x86 & x64)
    • retrieval of device handles for use with WinUSB
    • WinUSB init
  • [2009.12.01]
    • configuration descriptors retrieval
    • initial possible API breakdown & more code cleanup
  • [2009.11.30]
    • Added clock_gettime() with hires timer detection for monotonic and GetSystemTimeAsFileTime?() (100 ns resolution) for realtime.
    • Moved the USB 2.0 root hub caps detection into set_hcd_device_descriptor()
  • [2009.11.29]
    • First release with working lsusb enumeration

Attachments

Download all attachments as: .zip