Thought Leadership

USB – even more

By Colin Walls

I have written about USB many times – here, here and here, for example – and get a good response. Downloads of technical papers and web seminar attendances seem to break all records. It is clearly a topic of interest to many embedded developers. This is hardly surprising, as it is rare for any electronic device nowadays not to sport a USB interface. If you want a wired connection that just works, USB is an easy choice.

This ease of use comes at a price. The internal functions of USB are quite complex. This does not matter at all to the average user, but to the software developer of a USB-enabled device, it matters a lot. Even if a commercial USB stack is employed [which, naturally, I advocate and urge you to ensure that it is fully certified for standards compliance], having an understanding of the internals is useful to obtain the maximum performance and functionality. Today I want to talk about Endpoints, Pipes and Interfaces …

A USB connection between two devices [or between a computer and a peripheral – in the USB jargon, between a host and a function] is usually just 4 wires [prior to USB 3, which has 9 wires]. This is not important unless you are making cables and connectors, as, from a usage/software perspective, this connection carries a number of logical channels of communication or Pipes. A USB interface is configured to include a number [up to 32 – 16 IN and 16 OUT] Endpoints. These are the logical termination points of a pipe. As I mentioned on a previous occasion, USB communications may be performed using one of four modes: control, bulk, interrupt or isochronous. The endpoints are each characterized to support a single one of these modes.

An endpoint is normally part of the electronics hardware, with a set of registers set up by the USB stack. It is configured when the USB software is initialized. A pipe is a purely logical entity, which does not exist until a connection between two endpoints is established.

A USB enabled device can support a number of configurations. For each configuration, a number endpoints may be grouped into an Interface, which is associated with a specific function or purpose of a device and will use some or all of the endpoints. All the interfaces associated with a configuration can be set at the same time, so it is not possible to use the same endpoints for different interfaces. The first endpoint [Endpoint 0, which is actually a pair – IN and OUT] is exceptional, as it does not belong to an interface, but is used specifically for device configuration. A simple device will tend to have a single interface. A very simple device may only have a single endpoint [Endpoint 0, of course]. USB hubs also have a single endpoint.

I acknowledge the assistance I gratefully received from my colleague Stephen Olsen, who helped me get all of my terminology and concepts reasonably straight.


0 thoughts about “USB – even more
  • Very interesting blog Colin, as I have a love-hate relationship with USB that I want to better understand. As a user rather than a developer these days, I am dependant on USB functionality, and constantly reminded that there is still a plug-and-pray element to this excellent interface.

    All too often (say one in five times), I plug in some external memory (from camera card, backup drive or scanner for example) and have to mess around with several insertions until the system is happy. Sometimes I get a reassuring bleep indicating a successful status change, only to find the USB port not being recognized despite multiple successful driver loads in the past. Or simply not turning up in the reported devices list without reinsertion, even after the beep. If I keep everything connected no problem, but when I make a system change the USB function needs, like any worthwhile relationship, some serious attention every now and then.

    I can not be sure that this is not a problem with my motherboard USB drivers, and I do run a fairly full stack, but I suspect some quirkiness that is yet to be ironed out by the interface manufactures, or indeed the USB spec itself.

    Am I alone in my plug-and-pray experiences?

    • You are not alone Peter, but I think that’s got a lot more to do with Windows than with USB. I have found that Windows 7 seems to play somewhat better than earlier versions.

      My pet beef with USB storage devices is the disconnection issue. If you forget to tell Windows you’re going to unplug it, you might lose data. Sometimes Windows won’t let go of a device, which is where utilities like Unlocker are invaluable. Devices can be configured to not cache data and cause this problem, but that reduces performance, so it’s not the default. Add to this the practice of naive PC users, who move files to such a drive and call it a backup and there is plenty of room for misery.

Leave a Reply

This article first appeared on the Siemens Digital Industries Software blog at