- Debugger: Getting mixed signals
- 'Packaging Infrastructure' Contract Weekly Report #4
- Haiku monthly activity report - 06/2015
- 'Packaging Infrastructure' Contract Weekly Report #3
- 'Packaging Infrastructure' Contract Weekly Report #2
- GCI 2014 winners trip report (mentor side)
- TeX Live and LyX; Changes to the boot code
- 'Packaging Infrastructure' Contract Weekly Report #1
- Beginning of 'Packaging Infrastructure' Contract
- Haiku monthly activity report - 05/2015
Libusb Port (Pencils Down)
Today is the firm 'pencils down' date for Google Summer of Code. I write this blog, summing over all the activities/tasks accomplished in the last three months and my journey with Haiku.
As you would know, my project was porting libusb to Haiku.
Initially I planned to use USBKit for the Haiku backend, as that was what was used by Pulkomandy in his port of libusbx (and my work thus was to hunt down bugs in this and complete this).
I started tracking the bugs one by one, starting with the Segment Violation on running a Mass Storage test. A null pointer was being accessed. Added a check, which libusb guys mentioned was a wrong way to do things. (I left this as is for a few weeks, completing other functionalities meanwhile. The bug was due to an int function returning no value.)
Next, the program hung while fetching string descriptors. A quick control transfer using USBKit told this behaviour was independent of libusb.
Dive into the lower layers!! (usb_raw -> bus_manager -> busses[EHCI,UHCI])
The problem was with Short Packet transfers. Our usb stack used a trick to avoid this problem: First get the string descriptor length, then query the exact amount. This wouldn’t work with libusb.
I was able to fix this for EHCI and Pulkomandy also tested my patch for UHCI.
At this point I decided to use usb_raw instead of USBKit for the port. Next few weeks were spent on writing the backend, fixing issues (a lot more issues popped up as the work progressed), etc.
Post mid-term, I decided to work on the XHCI driver. I list down some of the fixes to the XHCI HC:
- Add support for hubs in AllocateDevice().
- Prevent page fault in FinishTransfers().
- Set fCapabilityLength
- Correction in BIOS ownership code
- Fix context errors in _InsertEndpointForPipe().
- Update constants according to latest Specification (v1.1)
- Fix SMI code (reference http://lkml.iu.edu/hypermail/linux/kernel/1204.2/02460.html).
- Fix Memory/Device-Slot leaks.
- Fix area allocation for TRBs.
- Fix for Intel Lynx Point and Panther Point chipsets. Also move init of xhci before ehci, to switch USB 2.0 ports before the ehci module discovers them.
- Fix device speed identification.
- Fix Max Packet Size for Full-Speed devices.
- Fix IRQ rate.
- Update slot context for LS/FS devices connected to non-root HS hub.
- Fix Endpoint Context Initialisation (Refer xHCI v1.1 - 6.2.3)
- Fix Interval Calculation (Refer xHCI v1.1 - 6.2.3.6 , USB 2.0 - 9.6.6 page 271)
- Fix MaxBurst, MaxPacketSize Calculation (Refer xHCI v1.1 - 6.2.3.5, USB 2.0 - 9.6.6 page 271)
- Fix MaxESITPayload Calculation (Refer xHCI v1.1 - 4.14.2)
- Remove Link TRBs as they were never being used
- Increase Number of TRBs per endpoint (to utilise the whole area allocated for Device TRBs)
- Fix usage of XHCI_MAX_ENDPOINTS (most of the checks were failing at corner cases)
At this point I turned back to the libusb port, giving the port finishing touches.
I’m now waiting for libusb moderators to merge my work.
Pulkomandy tested the port with AVRDude, which works (except for some issues with UHCI). I myself tested this with a PS3 controller, and dfu-programmer (the recipe for which has been added to HaikuPorts), to dump the firmware of an Arduino UNO.
Ending this, I would like to thank everyone for allowing we to work on such an amazing project, and everyone who helped me out, on IRC, on the mailing lists, and everywhere else. :)
Thanks a lot.
—
Akshay Jaggi
[1] https://github.com/akshay1994/libusb
[2] http://cgit.haiku-os.org/haiku/log/?qt=author&q=akshay1994
[3] https://dev.haiku-os.org/ticket/8954
[4] https://dev.haiku-os.org/ticket/10867
[5] https://dev.haiku-os.org/ticket/10915
[6] http://www.google-melange.com/gsoc/proposal/public/google/gsoc2014/aksha...
- akshay1994's blog
- Login or register to post comments

Comments
Re: Libusb Port (Pencils Down)
I would like to thank you as well for working on this. Not only the availability of the libUSB will be a great help for some of my own projects, but also because you did great work on fixing and improving our USB stack, despite this being a bit out of scope of the original GSoC proposal.
This was a great GSoC, and I hope you will continue contributing to Haiku in the future.
Re: Libusb Port (Pencils Down)
I plan to work on xHCI, will probably try to make it stable enough for inclusion in the nightlies.
Sad that I can't start working on it right away, college commitments keep me busy :(
Re: Libusb Port (Pencils Down)
Re: Libusb Port (Pencils Down)
Re: Libusb Port (Pencils Down)
Re: Libusb Port (Pencils Down)
Re: Libusb Port (Pencils Down)
Looks like you made great progress in the USB department, Akshay!
Hope you can stick around. I bet there's still a ton left until our USB stack is perfect. :)
Congrats to your successful GSoc!
Regards,
Humdinger
Re: Libusb Port (Pencils Down)
Re: Libusb Port (Pencils Down)
Merge +1
Re: Libusb Port (Pencils Down)
Re: Libusb Port (Pencils Down)
I am a Haiku fan, but not a programmer.
Sorry if my question is already answered.
I have a brand new Macbook Air. I have tried to boot Haiku from a USB memory stick.
The USB ports on Macbook Air are USB3, and the boot fails after a while.
It starts, but fails when Haiku´s USB drivers are supposed to take over.
(Or so I was told on IRC)
I have tried both USB memory stick and USB CD-ROM.
Both fail.
Will your great work on USB allow my Mac to boot Haiku?
When will your work be a part of the nightly builds?
I understand that you may need to do more testing first. I am looking forward to testing Haiku on my new machine.
Screenshot of when my Mac fails during boot:
http://i.imgur.com/KbOEErj.jpg
Re: Libusb Port (Pencils Down)
Yes. This is a known issue. (https://dev.haiku-os.org/ticket/10609, https://dev.haiku-os.org/ticket/8954)
The support for USB3.0 devices is still not complete, and thus the XHCI driver is disabled in the nightlies.
I was able to boot off a USB3.0 port on a Sony Vaio, but somehow, on a Macbook Pro, it fails to find the xHC, and the boot fails again. (More information in the comments of ticket #8954)
My work is a little something in the direction, but it still needs a lot of work, before it finally works. :)
Re: Libusb Port (Pencils Down)
I also wanted to congratulate you on an excellent job this summer, and hope you continue to work with us as time permits. Nice work!
Re: Libusb Port (Pencils Down)
Re: Libusb Port (Pencils Down)
Thank you very much for your work on libusb, and the USB drivers! Your work will help me get a full Android development environment on Haiku natively (ADB supports libusb) which makes Haiku one step closer to being able to be my daily (development) platform.
Besides that, the work on our USB drivers is very much appreciated too! I had one question about that: does that mean that without logs enabled it did not work? Or just that you didn't test that?Thank you for your contributions, and hope to see you back after GSoC!
Ithamar.Re: Libusb Port (Pencils Down)
Attaching a mass storage device with the logs disabled gives a KDL at get_cached_block(...). (https://dev.haiku-os.org/ticket/8954#comment:50)
It's probably a timing issue. With the logs disabled, it operates at max speed, and we currently have a limit of 8 (up from the previous 3) transfers scheduled in the transfer ring. If this is the issue, we can fix it by removing this limit using a linked list kind of ring. I didn't want to change this, until I was sure this was the problem, but the KDL didn't allow me to get to the logs :(
Edit: The limit is still 3. (My last patch is not yet merged. Some coding style problems :( I'm still not good with them)
Re: Libusb Port (Pencils Down)
Great job, Akshay! \o/
One question: with this work, we can have graphic tablets like the Wacom Intuos 4 working on Haiku?
Thank you very much!!
https://dev.haiku-os.org/ticket/7354 (comment 28)
Re: Libusb Port (Pencils Down)
Thanks :)
Re: Libusb Port (Pencils Down)
Has been great working with you so far :)
Hope you'll still frequent IRC, and be around to fix the numerous bugs still lurking in our USB stack! Fixes to isochronous support for USB Audio, and more USB3 improvements ;-) Maybe even adding some sort of keyboard support for UHCI controllers in KDL land :p
Thanks for all the work you've done so far; as you can see, it's all been very appreciated!!
Re: Libusb Port (Pencils Down)
I will, surely. College keeps me busy, and so does all the new things I am learning this semester (Compilers, Cryptology, Advanced Algorithms). I'll be back in December (thats when we have our vacations)
Thanks a lot Jessica :)