TrueTask® USB is a portable embedded USB host stack. It supports USB 3.0 and USB 2.0 host controllers, as well as USB 3.0 and USB 2.0 hubs. It has been tested at the USB-IF PIL as part of xHCI certification in multiple designs, and has shipped to over 20 million PC customers. TrueTask USB also includes a portable embedded USB device stack, the MCCI USB DataPump, that has been deployed in nearly a billion products.
The notion of a software platform is familiar: it’s a design environment that allows code to be written that is subsequently unaffected by changes to the operating system, CPU, compiler, and so forth. In the embedded system world, Linux is a good example of a a platform for application programs.
For reasons of efficiency, USB system code (the host and device stacks, the class and protocol drivers, and the management code) normally resides in the operating system kernel. Unfortunately, most operating systems that serve as application platforms do not serve as good system software platforms. In Linux, for example, the kernel APIs are not stable, and may change from kernel version to kernel version (22.214.171.124 may be different than 126.96.36.199, for example). Windows has similar differences between major versions. For a system vendor, this is very inconvenient, because (at best) multiple source versions must be maintained; bug fixes and system-specific adaptations cannot be automatically applied to any given environment, but must be scrutinized for correctness.
This is particularly a problem when it comes to USB host stacks. By its nature, USB is an open standard. No matter how well tested and supported a stack is, patches may be required to support a new and popular device that deviates from USB standards (but just happens to work with Windows or MacOS X). This presents problems. If the stack is from a commercial vendor, often you must update to the latest version to get all the corrections. However, if the stack is not designed to be a platform, you will have to modify your code; and you may have to re-port the stack onto your platform. This may not be practical, because extensive testing may be required.
If working with Linux, the problem can be even more difficult. Because of changes in kernel APIs, it is usually not practical to port the entire USB stack back to an earlier kernel version. Instead bug fixes must be identified, and then back ported. However, fixes may depend on other corrections made to the stack; so they may not work by themselves. Furthermore, fixes in the enumeration code may cause other devices to stop working.
TrueTask USB is different than a traditional embedded USB host stack, in that it’s designed based on a foundation ofstable APIs. These APIs are designed portably, so that the C code using them is portable across CPUs, operating systems, and host/device controller register models. They are also designed to be stable over time, so that code written with one version of TrueTask USB will be reusable with subsequent versions. Furthermore, they’re internally stable as well. This means that a change, for example, in the host controller driver will not affect TrueTask USB code in any other layer; only minimal retesting is needed.
One way in which MCCI ensures that APIs are stable is by eliminating conditional compiles in our C code. The second way is by prohibiting use of OS header files except in the wrapper modules that bridge between TrueTask USB APIs and the local platform APIs. In addition to greatly simplifying compile-time configuration management, these practices force our code to depend on the inter-module APIs for managing all CPU, OS and hardware variations, rather than using “#if” and compile-time variables.
It is increasingly common to multiplex a single physical USB connector to operate it either as a host or device. To support this, TrueTask USB has complete support for dual-role USB 2.0, dual-role USB 3.0, and USB 2.0 On The Go, based on the MCCI USB DataPump. The following block diagram illustrates the configuration for a dual-role USB 2.0 or USB 3.0 host/device.
TrueTask USB includes role-switching support for root hub and Microchip role-switch hubs, in support of Apple CarPlay.
Local OS Host Stack Emulations are available for Windows and Linux. These emulations allow TrueTask USB to support “in-box” class drivers shipped with the local operating system.
On Windows, this allows direct test and validation of new USB controller designs with a minimum of effort. The TrueTask USB host controller driver (HCD) API is a platform API, and allows direct test of non-EHCI/xHCI architectures such as the Synopsys DesignWare OTG USB 2.0 core using the full variety of Windows devices.
When developing an embedded system, this allows first testing the host drivers, hub drivers, enumeration logic and applications using Windows. When the software is moved to the embedded system, any variations are systematic and easy to track down.