USB software stack
In the area of “System-On-Chip” microprocessors, which have everything from power management over audio hardware (DAC and ADC) to USB (Device/Host/OTG) in one chip, the processing power is big enough to move from hardware based components to software based ones. A very good example is the Archos Jukebox units , which have used chips to handle mp3 decoding and USB2ATA?
-Bridge. In contrast to it there is the SanDisk
Sansa player , which makes use of software codec’s to de/encode audio and needs a software based USB Stack.
Always new hardware targets are big challenges for software developers, in this case the RockBox
community , because you need to design new subsystems in a very portable way and keep every time in mind that you are working on an embedded device.
The goal for this Summer of Code project will be to write a portable USB stack, with the main focus on the Sansa e2xx players. I'd rather have this formulated as 'first test platform on sansa e2xx, but to be used on all targets that do not have an USB/ATA bridge' -- PeterDHoye
What should the usb stack support:
- USB device mode - use RockBox as mass storage device to copy music, pictures,...
Optional if time permits:
- USB host mode/OTG - allow RockBox to be an USB host -> connect an usb stick to the dap and copy data (if there is enough time). OTG should be the least of our concerns as iriver engineers disabled this on h300 and I don't know if other targets have this possibility (X5 maybe?). In any case, HOST mode will be a separate stack as we do not have a target that needs both host and device SW stacks -- PeterDHoye
As writing an USB stack is not an easy task I will look at existing open-source solutions and port one of them to RockBox
I will use the best fitting one as "place to look" when I do the coding work of an usb stack from scratch.
Here is a list of candidates found:
- IRQ handler: OK
- Include Gadget include-files and modify them to fit into RockBox: OK
- get modified arotg_udc driver compiling: work in progress
- include gadget driver for file storage: todo
In the evaluation process I looked at every usb stack to see if the following requirements
- Layer based architecture?
- How easy is it to add support for a new hardware
- How easy is it to add support for new classes?
- Source code quality.. is a brutal hack or a easy-going design
- Dependencies (kernel, runtime enviroment)
- How much is already done (classes,...)
USB for Real-Time aims at providing a hard real-time capable implementation of an USB stack on top of Linux/Xenomai. It comes with a stack core and an UHCI host controller drivers. Future work will deal with a EHCI (2.0) and various high-layer drivers.
- The design of this usb stack is inspired by the "normal" linux usb stack.
- It should be quite easy to add new hardware, because of its good design. At the moment this stack supports uhci usb controllers
- The sourcode of this stack does not include any single line for class stuff. Maybe the stack uses classes provided by "normal" linux kernel.
- Depends heavily on "normal" linux kernel, so if this stack will be used we need to clean it up.
- Core and uhci are done. Provides a simple usb ping utilitiy for testing
PORUS is a portable USB stack for USB peripherals. It handles enumeration and many standard control requests, and provides a portable API for performing USB transactions.
- This stack offers a layer from usb core to usb hardware.
- The usb-hw interface needs to be implemented.
- In the sourcecode you can find a lot of documentation and its easy to read/understand
- No deps
- Does only the very very basic usb stuff and so there isnt anything class realated.
- Only the usb core and a port to a usb chip
lpcusb is a small usb stack for the built-in USB controller in LPC214x microcontrollers.
- small and easy to read code
- No deps
- the layer design is not finished, the class part exists only in example folder to show how to work with this usb stack
- to support new devices some work is needed, as this usb stack is wirrten for LPC214X? controllers only
- There exits only some examples, but there are no classes
- core and some examples
- Offers also a layer based design.
- There is no need to add extra classes
- Looks okay, but i dont like tabs
- No deps
- core, driver for ISP1362/ISP1363 and host classes for storage, printer, audio, hid, hub
- No standard device classes like UMS
- To support more devices a lot of work needs to be done, as the whole stack was written for ISP1362/ISP1363
List of documentation that may be usefull:
Blog of ChristianGmeiner
: dump of sansa usb registers inside manufacturer mode (thanks webguest83 whoever you are)
: reg dump in manufacturer mode (some more regs than in the zip)
: result of usb test suite as on 29/08/2007
Copyright © by the contributing authors.