One of the important roles Windows plays as part of a broad ecosystem is developing support for new hardware. This is a pretty involved process and so for this post we wanted to take a look at supporting USB 3.0, something we know everyone is anxious to be using because of the improvements it brings. This is also our first video post – we aimed for "engineering" videos and not high production values but I think we make our point (note videos are embedded in HTML5 and available for download). If you’re like me when looking at the video, you might think that those file copy progress indicators are looking a bit dated…stay tuned. This post was authored by Dennis Flanagan, the Director of Program Management for the Devices and Networking group. –Steven
With throughput up to 10 times faster than USB 2.0 and improved power management that results in longer battery life, USB 3.0 introduces compelling reasons to improve the world’s most popular PC interface. By 2015, all new PCs are expected to offer USB 3.0 ports, and over 2 billion new "SuperSpeed" USB devices will be sold in that year alone.
The decision to invest in USB 3.0 was an easy one to make, but doing so without compromising the existing USB ecosystem was a big challenge to overcome. Our design had to follow the revised 3.0 specification precisely in order to enable emerging USB 3.0 hardware. There are also billions of older USB devices that Windows must remain compatible with. How do you write a single piece of software to enable the latest technology on evolving hardware, while making sure it still works with 10 billion existing devices in homes and offices across the world?
First, a bit of history
In 1996, the USB standards organization released the first USB specification, which defined two speeds for USB devices: low speed (1.5 Mbps) and full speed (12 Mbps). At the time, the idea of “hot plugging” a device (plugging in and unplugging without needing to reboot), was revolutionary. USB also supported different ways to transfer data: bulk, for devices like printers that send a lot of data and forget about it; isochronous, for devices like speakers that continuously receive data in a specific order; and interrupt, for devices like keyboards that only send data once in a while.
The 1996 specification also moved the complexity from the USB device into the PC, making devices cheaper and simpler to implement. These features made USB the most attractive external device connector. As a result, device makers adopted USB and joined the standards body to define common interfaces between software and hardware for different classes of devices. These common interfaces allow a single software driver, a class driver, to support an entire type of device. From the beginning, Microsoft embraced the USB technology and the standards organization, contributing to many specifications over the years. We introduced USB 1.1 support in Windows 95 OSR 2.
In 2000, the USB 2.0 specification came to light with a new, high speed (480 Mbps). Unfortunately, the host controller, the hardware used to connect a PC to devices, was not compatible with earlier versions. High speed devices worked with all controllers, but low and full speed devices could not work with USB 2.0 controllers. PCs needed to ship with two different controllers, or embed a USB 2.0 hub, in order to support all types of devices. In Windows XP SP1, we enhanced our existing software driver stack by adding USB 2.0 functionally.
The path to USB 3: start with a solid specification
By actively participating in the USB standards organization, we helped create a specification that was both compelling and interoperable. Like other members of the USB Implementer’s Forum, we wanted to see a faster, more power-efficient version of USB, where, unlike USB 2.0, a single combination of hardware and software could work with all USB devices.
In 2008 the USB Standards organization released the new USB 3.0 specification, which included a new host controller and defined the new “SuperSpeed” USB device (5 Gbps). Together, the controller and device could operate at theoretical speeds of up to 10 times faster than USB 2.0. With this new standard, you’d be able to copy a high definition movie from a USB storage drive in about 80 seconds instead of the 15 minutes it takes with USB 2.0. The specification also introduced a new transfer type —streams — which allows the storage drives to process reads and writes more efficiently.
The new specification provided 80% more power than USB 2.0. This meant faster charging and removed the need for odd “Y” cables used by external DVD drives and other high power devices. But charging isn’t the only power consideration. With mobile computing, people want PCs that conserve battery life. By also introducing new low power states, finishing tasks more quickly, and powering down at every opportunity, USB 3.0 is more power efficient than its predecessors. This translates to longer battery life for notebooks and less power consumption for desktops.
Most importantly, the specification promises to enable a new generation of USB while maintaining compatibility with full, low, and high speed devices. Even the plugs are backwards compatible.
Close partnership with the hardware industry
As the specification began to solidify, we started to design Windows and faced our first difficult decision. Do we update our existing USB software, which we’ve gradually modified since Windows 95 OSR2, or, do we write new software following modern design principles? Countless devices and their drivers rely on the behavior of our existing software, so we couldn’t simply jump into a brand new design. The solution? Don’t jump in. Instead, meticulously design a new USB software stack for the new controller while maintaining existing interfaces and behaviors, ensuring every device and driver will work. For older controllers, we retained our existing software stack.
To create a brand new USB software stack, we had to start work early. If we waited for hardware to be available we would be too late to support the budding USB 3.0 ecosystem. We decided to start before there were any USB 3.0 devices by building "virtual” devices. Virtual devices are software representations of real, physical USB hardware: the ports, the hubs, and other devices.
With virtual device development underway, we started designing and prototyping. USB software is complex because it has to manage hubs and devices while still dealing with any errors. To create something with longevity we needed to visualize and document the flow. We designed three massive flow charts and a code generator to automatically convert a Visio diagram into software. Together with Microsoft Research, we refined a tool called Zing, which could validate every aspect of this software model.
Once we finished some initial development, the first USB host controllers arrived. We recognized that simulation provided a great starting point, but it wasn’t enough. With hardware, we identified incorrect assumptions, timing issues, and other problems unique to real-world scenarios. The path forward also required us to help foster a new ecosystem that would require a strong collaboration with our hardware partners. We needed to work together to prototype, exchange ideas, have deep technical discussions, and report bugs in both directions. We had to build a shared commitment to work together closely so we could identify issues before designs were final.
As USB 3.0 development progressed, so did a sense of community. Software is only as successful as the hardware it enables. Together with our partners in the hardware industry, we were finding issues, developing solutions, and creating the foundation for a new USB ecosystem.
I test, therefore I am
While we were focused on building support for USB 3.0 chips inside the PC, we couldn’t ignore the world of devices. We had to think outside the box – literally. There are over 10 billion USB devices worldwide. Some are in use daily and some are tucked away collecting dust, but all were originally designed to work with Windows PCs. Compatibility is the Windows promise. Our customers have grown accustomed to expecting new versions of Windows to work with their existing devices and drivers. This commitment to compatibility remains a high priority for Windows 8 across the whole product.
For USB compatibility testing, the “brute force” approach does not work because there are so many devices, with new ones appearing every day, and many old devices that can no longer be purchased. We needed to develop a smart device test strategy. After analyzing the device statistics, we broke devices into three main categories:
- Device popularity
When looking at the telemetry sources for the most popular devices, we noticed a pattern. Each device class (keyboard, webcam, printers, storage, etc.) had a handful of prevalent manufacturers with just a few main product lines. After projecting these findings, we could represent 70-80% of devices with a few hundred devices. Testers use the mathematic term "equivalence classing" to describe this work.
We still had a significant percentage of devices that would go untested if we just settled for popularity data, so we looked deeper at the actual circuit design. Just like humans, devices that appear very different on the outside are pretty similar on the inside. If we could ensure all USB chipsets worked, then it’s highly likely the devices that contained them would work as well. A relatively small number of chipset makers are embedded in devices, so we chose to represent their USB IP with development boards.
- High-profile and challenging devices
It’s not often a USB device tops the support call lines. When it does, we want to make sure Windows will work with it going forward.
After 10 years of USB experience, a dozen telemetry sources, and tons of research and brainstorming, we were able to reduce the USB compatibility effort to roughly 1000 unique devices that we regularly test in the Windows labs. We ensure the devices get recognized correctly when connected to PCs, that they sleep and resume appropriately to conserve power, and that they are able to withstand various stress conditions. Our telemetry data indicates that over 90% of devices rely on the 16 class drivers in Windows, but for the more customized devices, we verify that their drivers get seamlessly downloaded from Windows Update whenever possible (the device maker needs to cooperate to support this scenario). With USB 3.0 providing full backwards compatibility, older drivers will still work without any changes.
We also made a heavy investment in building a custom tool – the Microsoft USB Test Tool (MUTT) to simulate a full range of device behaviors that we’d observed over the years. We built the MUTTs from the ground up, in house. Our software test engineers laid out the circuit design with the help of fancy design tools (MS Paint … seriously). They then developed the firmware and generated new test content to run internally. The MUTT was born – think of it as 1,000 devices on a USB thumb drive. Over time, we shared the MUTT with our hardware partners and they’ve used it to find and correct problems in their devices before releasing.
Perhaps the most important aspect of USB 3.0 is the expectation that customers have of USB: it’s just USB3 so it should just work, right? Each and every USB device, low, full, high, and SuperSpeed, has to work in Windows 8. That’s our focus while also delivering the most robust and reliable USB stack.
Let’s take a look at USB 3.0 in action as it takes on some pretty significant copy tasks and races against USB 2.0.