Libusb Port : Post Mid Term

Blog post by akshay1994 on Sat, 2014-07-12 08:35

The work on Libusb is, to a large extend, complete. I would like to invite the community to try it out, test it, and report bugs, if any.
It is most stable with the EHCI bus driver, followed by UHCI (which still has a bug I am unable to fix).

Steps to test :-

  • Patch Haiku sources with the patch mentioned at [1].
  • Update the HaikuPorts recipe to the latest commit of the libusb fork. [2]
  • Use HaikuPorter to build and install the recipe.

The build works fine with both gcc2 and gcc4. Pulkomandy also confirmed build of AVRDude. Also added is a recipe for dfu-programmer which we can use to flash Arduino. (Use at your own risk :P)
The patch to the EHCI code is to enable handling of Short Packet Transfers which otherwise hung out indefinitely. I'm still unable to find what causes the same problem in UHCI. [6]
I have myself tested the port with a Flash Drive, a PS3 Controller and to dump the firmware of an Arduino Uno.

My recent work was to get XHCI working on Haiku.
(Patches [3] and [4], Ticket [5])

The issues addressed in these patches are :

  • Add support for Hubs in XHCI::AllocateDevice()
  • Prevent page fault in FinishTransfers(), for transfers submitted in UserLand
  • Correction in BIOS - OS handoff code
  • Fix SMI Code
  • Fix Memory/Device Slot leaks
  • Fix area allocation for TRBs
  • Fix for Intel Lynx Point and Panther Point chipsets.
  • Fix Max Packet Size Identification for Full Speed Devices
  • Fix IRQ rate
  • Fix Device speed Identification
  • Update slot input context for LS/FS devices connected to a HS non-root hub
  • Correction/Updating of bit offsets according to the latest specification
With these I was able to boot from a USB 3.0 port on an Intel 7 Series Panther Point xHC.

Still a lot of work remains in the driver before it can be fully functional. Keyboard and Trackpad do not work correctly (thanks Jessica for testing this out). Short Packet Transfers need to be fixed, and so does the part handling submission of transfers if the queue is full.

I would like to thank you all for giving me a chance to work on this, and everyone on the IRC channel and the mailing list for helping me out :)

[1] https://dev.haiku-os.org/attachment/ticket/10867/0001-Fix-Short-Packet-EHCI-Transfers.patch
[2] https://github.com/akshay1994/libusb/commit/c8f7684a853c322f048a1f57457837c32dae2fac
[3] https://github.com/haiku/haiku/commit/17aa359b5df69f658b4b33e29546c9fb2f0cfce3
[4] https://github.com/haiku/haiku/commit/192f01c669102651bdc81273811079e90e0a29e5
[5] https://dev.haiku-os.org/ticket/8954
[6] https://dev.haiku-os.org/ticket/10915