About the USB Protocol, Common USB Bus Errors, and How to Troubleshoot Them

An Introduction to the USB Protocol

The History of USB

The USB protocol, also known as Universal Serial Bus, was first created and introduced in 1996 as a way to institutionalize a more widespread, uniform cable and connector that could be used across a multitude of different devices. With the increase in technological devices during this time, having a universal cable would help reduce the confusion and inconvenience of having a collection of cables needed for each individual device.

The USB architecture was conceptualized with the juncture of companies including Compaq, Digital Equipment, IBM, Intel, Microsoft, and Northern Telecom, and is currently maintained and regulated by the USB Implementors Forum, or USB-IF. USB-IF enforces the standards and specifications that USB device manufactures must comply with in order to a be verified as a trusted USB source. Devices that are compliant to both the USB standard’s physical layer (mechanical and electrical) and software layer are approved to use the USB logo, informing consumers and other USB adopters that their cables or devices are safe to use.

How Does USB Transmit and Receive Data?

How does the USB standard define how a USB cable or device should operate? There are a variety of mechanisms that must be adhered to, including how various USB devices should interact with each other upon enumeration and communication.

USB hosts are also known as master devices, and they initiate all the communication that occurs over the USB bus. Typically, a computer or other controller are considered to be the master, only responding to other devices if requesting certain information. The peripheral device, or the slave device, is connected to the host device, and is programmed to provide the host device with the information it needs to operate. Typically, peripheral devices include USB flash drives, computer mice and keyboards, cameras, and other such devices.

It is important for host and peripheral devices to be able to effectively communicate with each other. If either one isn’t able to perform its job function, the communication between two devices would falter. For instance, if a user plugs in a flash device on their host computer and nothing happens, this would likely indicate a problem with the communication over the bus. Which leads into how communication takes places over the USB bus. How is USB data transmitted and received? This can be better understood by getting to know the theory of operation on how USB data is sent over the bus, the different USB data packet fields and packet types, and the types of USB data transfers.

USB Data Packet Fields

The USB data packet fields are what make up a USB packet, consisting of individual bits.

USB data packet fields include a Sync field, a Packet ID (PID) field, ADDR (Address) field, ENDP (Endpoint) field, CRC (cyclical redundancy check) field, and EOP (end of packet) field.

  • The SYNC field is used to synchronize the clocks from both the receiver and transmitter.
  • The PID field provides information on what type of data is being sent. The below table presents the PID Type, the PID Name, and what its purpose is the packet:

Table 1: USB Packet Types

PID Type PID Name Description
Token OUT Host to device transfer
IN Device to Host transfer
SOF Start of Frame marker
SETUP Host to device control transfer
Data DATA0 Data packet
DATA1 Data packet
DATA2 High-Speed Data packet
MDATA Split/High-Speed Data packet
Handshake ACK The data packet was received error free
NAK Receiver cannot accept data or the transmitter could not send data
STALL Endpoint halted or control pipe request is not supported
NYET No response yet
Special PRE Preamble to full-speed hub for low-speed traffic
ERR Error handshake for Split Transaction
SPLIT Preamble to high-speed hub for low/full-speed traffic
PING High-speed flow control token
EXT Protocol extension token

 

  • The ADDR (Address) field includes the address of the device the packet is being sent to.
  • The ENDP (Endpoint) field specifies the Endpoint number
  • The CRC field is used to check the data in the packet for errors
  • THE EOP field indicates the end of the packet
USB Data Packets

These fields are used to form data packets, which define the various transactions. There are four USB packet types including:

Token Packet, which is initiated by the host and determines if the host will send or receive data.

Data Packet, where the Data is sent by the transmitter, and a device can return a NAK or Stall packet to indicate if they are not able to respond.

Handshake Packet, used for acknowledging data or reporting errors.

Start-of-Frame Packet, splits the USB bus into time segments and schedules the data transfers.

These packets are formed into frames and sent through a USB transaction. The length and frequency of the transaction depends upon the transfer type being used for an endpoint.

Types of USB Data Transfers

All communication between a USB host and a USB device is addressed to a specific endpoint on the device. Each device endpoint is a unidirectional receiver or transmitter of data; either specified as a sender or receiver of data from the host.

Each endpoint is different, specified through their bandwidth requirements and the way they transfer data. The four types of USB data transfers include: Control, Isochronous, Interrupt, and Bulk transfers.

Control: Non-periodic transfers. Typically, used for device configuration, commands, and status operation.

Interrupt: This is a transaction that is guaranteed to occur within a certain time interval. The device will specify the time interval at which the host should check the device to see if there is new data. This is used by input devices such as mice and keyboards.

Isochronous: Periodic and continuous transfer for time-sensitive data. There is no error checking or retransmission of the data sent in these packets. This is used for devices that need to reserve bandwidth and have a high tolerance to errors. Examples include multimedia devices for audio and video.

Bulk: General transfer scheme for large amounts of data. This is for contexts where it is more important that the data is transmitted without errors than for the data to arrive in a timely manner. Bulk transfers have the lowest priority. If the bus is busy with other transfers, this transaction may be delayed. The data is guaranteed to arrive without error. If an error is detected in the CRCs, the data will be retransmitted. Examples of this type of transfer are files from a mass storage device or the output from a scanner.

The Different USB Connectors Types and Signaling Rates

What are the Different USB Connector Types?

USB cables and connectors create an interface as a way for computers and peripheral devices to connect with each other and transfer data. There are numerous USB connector types that have been used to interface the USB 1.1/2.0 and USB 3.0 protocols. Some of the most commonly used connectors include USB Standard-A, USB Standard-B, USB Mini-B, USB Micro-B, and USB Type-C.

USB Type-A: Is the most widely used connector type. It is primarily used on host controllers in computers and hubs and is more commonly used as a downstream connection.

UBB Type-B: is mainly used for connecting USB peripheral devices including printers and compact devices like mobile phones. It is commonly used as an upstream connection.

USB Type-C: is an advanced connector type that uses a reversible design, and is intended to replace other connectors in the hopes of there being one cable to function with a variety of different devices.

Over the years, there have been multiple USB revisions and specifications that have been introduced to support the development of the USB standard and its ever-improving signaling speeds.

The USB Specifications and Their Signaling Rates

Full Speed USB (USB 1.1)

The first USB specification, USB 1.0, was introduced in 1996 and initially supported a Low-Speed transfer rate at 1.5 Mbps. This specification was later revised in 1998 to USB 1.1, also known as Full-Speed USB. This updated specification supports a bandwidth of 12 Mbps and power levels up to 2.5W. USB connectors supporting this spec include USB Type-A and USB Type-B.

High-Speed USB (USB 2.0)

In 2001, the USB 2.0 specification was introduced. USB 2.0, also known as High-Speed USB, supports a transfer rate of 480 Mbps and is backwards compatible with USB 1.1. USB 2.0 also uses the same USB Type-A and USB Type-B cables and connectors, as well as the same software interfaces as USB 1.1, but substantially increases the support for higher bandwidth peripheral devices, such as video camera devices.

SuperSpeed USB (USB 3.x)

USB 3.0

The USB 3.0 specification, also known as SuperSpeed USB, was first released in 2008 to address consumers’ growing needs for USB devices that could handle even more power and faster transfer speeds. USB 3.0 supports transfer rates up to 5 Gbps and power levels up to 4.5W, making it ten times faster and twice as powerful as USB 2.0. Like previous USB specifications, SuperSpeed USB is also backwards compatible with its predecessors and is supported on cable and connector types including USB Type-A and USB Type-B.

Over the years, SuperSpeed USB has undergone numerous revisions to reflect its constant speed improvements.

USB 3.1

In 2013, SuperSpeed USB 3.1 was introduced to reflect its support for transfer rates up to 10 Gbps by using a dual-lane operation within a USB Type-C connector.

USB 3.2

In 2017, USB 3.2 was released, further increasing the signaling rate. This revision supports USB transfer rates up to 20 Gbps, which is possible due the specification signaling 10 Gbps over 2 lanes in a USB Type-C cable.

Throughout the years, there have been numerous updates to the naming conventions and branding of the various releases of USB 3.0, USB 3.1 and USB 3.2. Today, USB 3.2 encompasses all prior USB 3.0 and USB 3.1 specifications, supporting signaling rates at 5 Gbps, 10 Gbps, and 20 Gbps.

  • USB 3.0 is now USB 3.2 Gen 1 (SuperSpeed USB) and has a maximum throughput of 5 Gbps.
  • USB 3.1 is now USB 3.2 Gen 2x1 (SuperSpeed USB 10 Gbps) and has a maximum throughput of 10 Gbps.
  • USB 3.2 is now USB 3.2 Gen 2×2 (SuperSpeed USB 20 Gbps) and has a maximum throughput of 20 Gbps. This is also known as SuperSpeed USB 20Gbps.
USB4

The USB4 specification was released in 2019 and offers users some of the most robust features and capabilities, including the ability to transfer data up to 40 Gbps using a dual-lane operation within a Type-C cable. USB4 permits the highest USB bandwidth available with multiple data and display protocols to efficiently share the maximum aggregate bandwidth over the bus. USB4 also has backwards compatibility with USB 3.2, USB 2.0, and Thunderbolt.

USB Power Delivery

USB Type-C cables are known for their ability to supply high power levels, up to 100W of power, which is possible due to its power negotiation capabilities known as USB Power Delivery (PD). The USB PD specification was released in 2012 as an extension of the USB specifications.  USB Power Delivery is a protocol that is implemented within USB Type-C cables on the communication channel (CC) lines to safely manage power contracts between source and sink connections. Once power negotiations between devices have been established, the correct current and voltage levels are supplied through the VBUS.

Common USB Traffic Errors in USB Device Development

When developing USB devices, it is common for developers to experience bus issues that can lead to USB communication errors. While some errors will cause system failures, other issues may still allow the system to operate, but with potentially erratic behavior. Below are examples of some USB bus issues that can occur:

Improper USB Packet Data and Data Sequencing

USB packets contain error checking mechanisms, including a CRC bit to ensure data validity and a toggle bit in the PID packet to ensure correct data sequencing. Sometimes during USB data transmission, even these can become compromised if there an error in this mechanism, causing individual USB transactions to be dropped or causing reduced throughput.

For instance, if the data packet is corrupt and the CRC is invalid, the receiver will send a NAK bit to the transceiver, informing of an erroneous data packet. Transceivers will then resend the data multiple times, but this can in turn cause data packets to drop as the receiver may consider this to be duplicate data.

One example of an incorrect sequence includes incorrect data bit toggling. In a normal data transaction, the data PID will toggle between DATA0 and DATA1 consecutively, however, if there are issues with this, data retransmission can occur where the toggle bit does not update correctly, causing a repetition of the same toggle bit. In these cases, sequential DATA0s or Data1s are not passed to the application because the receiver will ignore packets that are repeating. This will cause data to not be passed to the application.

USB Transmissions/Retransmissions

In a normal USB transaction, host and peripherals send and receive data, acknowledging (ACK) or denying (NAK) certain transactions, allowing for effective communication. In one example of effective USB transmission, the host will send an IN token to the peripheral, and the peripheral will respond with a data packet. The host will acknowledge this and respond with ACK packet, which will let the device know it received the data correctly and is ready to send another transaction.

However, sometimes transmission can be faulty. If a data packet is corrupted, the host may discard this packet will not send an ACK. The peripheral will then receive another IN token, but since there was no ACK, it will resend the same data. This can be categorized as a retransmission.

Some data retransmission can be okay, but if there is an overflow of retransmission on the bus, this can cause slow performance and/or packet loss.

Power/VBUS Related Issues

Another common USB bus error is related to power and VBUS issues. The VBUS is a wire within the USB connector that supplies power to devices. Host and peripheral devices have specific upper limits on current supplementation or consumption, so if there is detection of an overdraw of current from the device, the system can shut down when testing or operating.

Systems can also react to an over-draw of current by not connecting or enumerating correctly. If the host or device detects high current levels, either one can disconnect and enumeration will not fully complete.

Problems with Enumeration

Enumeration within a USB system is a process where the host detects the presence of a device, and determines what type of device is connected and the speed at which to communicate. This is when the handshake token takes place, as both devices are learning about each other’s capabilities.

Upon enumeration, the host will reset the device in order to read its descriptors and identify it. However, if the device descriptor is incorrect, for instance it is not the correct bit length, this can cause errors in enumeration, causing improper connection between the devices.

High Speed Negotiation Issues

High speed devices can also support low and full speed signaling as USB 2.0 is backwards compatible with previous specifications. When devices are first connected, the full-speed capabilities are initially used until the High-speed capabilities can be confirmed from either device. In order for USB 2.0 devices to perform High-speed negotiations, a protocol known as chirping is performed.

USB defines two data bus states during this stage, J and K chirps. When a High-speed USB host connects to another device, the host will reset the device and wait for a K chirp in return, which will signify that the device is High-speed capable. If it does not reply with a K chirp, the High-speed host device will terminate the handshake. However, if the device does return a K chirp, the host will respond with alternating pairs of Chirp K and Chirp J to tell the device it is High-speed capable. Once this transaction has been recognized, the High-speed connection is established.

Having speed negotiation issues can cause signaling issues between devices, leaving the devices to operate incorrectly. For instance, if a full speed device ends up responding with the K chirp by error, the host will think it is capable of handling High-speed. This can result in corrupt packets because the device does not understand High-speed.

Reset, Suspend, and Resume Events

Certain types of low-level bus events including reset, suspend, and resume events are vital to successful communication between two high speed devices, and any disruptions during these events can cause abnormal behavior in USB devices.

The reset event occurs when the host wants to start communicating with a device. This will allow the device to reset to a default unconfigured state to allow for seamless communication. If this event does not occur correctly, the devices may not be able to affectively enumerate or exchange USB data correctly.

USB devices are able to power down if they are not being used which is performed using a suspend event. During this time, a suspended device must recognize the resume signal and reset signal. If the host wants to wake a device back up, it can issue a resume signal. If there is an issue sending or receiving these signals, the USB device may not wake up correctly and can become unresponsive during or after these events take place.

What is a USB Protocol Analyzer (USB Sniffer)?

A protocol analyzer is a tool commonly used by hardware, software, and firmware developers to analyze and debug embedded systems in all stages of the product lifecycle. Protocol analyzers connect between the host computer and peripheral devices to capture and decode raw bus data and events into human readable format, often flagging bus errors for easier troubleshooting.

There are a variety of protocol analyzers, each specific to analyzing certain data protocols, including I2C, SPI, USB, CAN, and eSPI.

A USB protocol analyzer, also known as a USB bus sniffer or USB bus debugger, will specifically capture and decode USB bus data at the protocol level, including enumeration, USB data packets, individual USB transactions, timing and data events, speed negotiations, and much more. Engineers turn to protocol analyzers to get enhanced insight into the bus and to uncover errors that might otherwise be overlooked.

Software vs Hardware USB Protocol Analyzer

There are two different kinds of USB protocol analyzers that are used to debug USB devices:

  • Software USB Protocol Analyzer
  • Hardware USB Protocol Analyzer

A software protocol analyzer is a software-only based analyzer that replaces the USB software stack on the host machine under test in order to monitor USB data. Software USB protocol analyzers allow users to see data sent to and from the host controller, but because these analyzers rely on the host computer hardware to perform analysis, this can often limit what USB information is available for analysis.

Contrarily, a hardware analyzer is a hardware-based tool that operates separately and independently from a host computer. Hardware analyzers connect in between the host computer and peripheral device to non-intrusively monitor the communication between the two. They allow users to accessibly debug the embedded host and view specific data and events including speed negotiations, timing issues, and transmission errors.

One significant advantage of using a hardware protocol analyzer as opposed to a software protocol analyzer is its ability to capture, decode, and debug low-level bus events and errors. Low-level bus events include K/J chirps, Reset, Suspend, Resume, In/NAKs, SOF.

While software analyzers provide certain levels of visibility into a USB system, it cannot replace a hardware protocol analyzer. Often, USB developers will use both types of analyzers to ensure their system is operating optimally.

Things to Consider when Choosing a USB Protocol Analyzer

While many of the USB protocol analyzers available on the market provide analyzing and debugging capabilities of the USB protocol, each one is different in terms of how it is able to do so.

When choosing the right USB protocol analyzer, the user must consider which use cases the analyzer will be used for and if there are certain features that are vital to making this happen.

USB Capture Rates

In order to effectively analyze and debug USB devices, the protocol analyzer must be able to successfully capture the USB traffic at the rate it is being signaled. Ensuring an analyzer that can meet the signaling requirements is a vital first step in choosing the right one.

Real-Time Capabilities

Real-time monitoring capabilities allow the user to capture, decode, and analyze USB data in real time, meaning that it is possible to view the data as it occurs, not by capturing, downloading, and then displaying the data. This can be extremely helpful in reducing the time to pinpoint errors and allows users to get better insight into how the bus is behaving.

Memory

The data captured by a hardware protocol analyzer is generally saved in memory storage on the device and on the RAM in the host PC for even further storage space. A larger memory can be greatly beneficial to users who perform long-term data captures that need to record data traffic for multiple days at a time.

USB Class-level Decoding

USB defines class code information to identify a device’s functionalities and to group similar devices that allow them to share a common USB Class Driver. USB class-level decoding is the translation of the low-level USB data into human-readable USB class-level commands and instructions. Having this capability on a protocol analyzer is greatly beneficial for better understanding the data quickly and easily rather than trying to make sense of raw USB data format.

VBUS Current and Voltage Monitoring

Within a USB connector, there are multiple pins that transfer certain data across the cable, but there is also a VBUS wire that is used to transfer power between devices. Having an issue with the VBUS can be result in the devices not powering correctly or disconnecting from each other due to overdraws of current. Having a protocol analyzer that allows for VBUS current and voltage monitoring can help determine any power related issues upon enumeration and connection of devices.

Hardware Triggering

Advanced triggering capabilities can add another dimension of USB debugging that allows users to trigger a capture when certain criteria are met, like matching specific packet types, data, or bus states.

Digital I/O

Having the digital I/O functionality allow users to sync USB traffic with external logic.

Having this functionality also supports performing triggers and synching with external test systems.

Multi-Analyzer Synchronization

Synching multiple protocol analyzers is sometimes needed so you can reliably monitor both sides of a USB hub, or any number of points in a USB system. Having this capability with allow the synchronized capture of events, start, trigger, and stop, on multiple analyzers.

Cross Platform Support

Having a protocol analyzer that is supported on multiple different operating systems offers a more flexible and convenient debugging experience. Having the ability to use on an already familiar operating system also reduces the learning curve on using the tool.

Overview of Total Phase’s Beagle USB Protocol Analyzers

Total Phase offers a variety of USB protocol analyzers that support numerous different project requirements.

Beagle USB 12 Protocol Analyzer – USB Full Speed 1.1 Analyzer

Beagle USB 12 Protocol Analyzer

The Beagle USB 12 Protocol Analyzer monitors Low-/Full-Speed USB traffic, up to 12 Mbps. This analyzer offers real-time display, search, and filtering of captured data, as well as descriptor decoding.

For more detailed key features and abilities, please visit the Beagle USB 12 Protocol Analyzer Datasheet.

Beagle USB 480 Protocol Analyzer – USB High-Speed 2.0 Analyzer

Beagle USB 480 Protocol Analyzer

The Beagle USB 480 Protocol Analyzer non-intrusively monitors High-/Full-/Low-Speed USB 2.0 traffic, up to 480 Mbps. This analyzer offers real-time display, search, and filtering of captured data, and also offers descriptor decoding and USB class decoding.

For more detailed key features and abilities, please visit the Beagle USB 480 Protocol Analyzer Datasheet.

Beagle USB 480 Power Protocol Analyzer - USB High-Speed 2.0 Analyzer

Beagle USB 480 Power Protocol Analzyer - Ultimate Edition

The Beagle USB 480 Power Protocol Analyzer non-intrusively monitors USB 2.0 traffic, up to 480 Mbps. This analyzer offers real-time display, search, and filtering of captured data, and also offers descriptor decoding and USB class decoding. The Standard and Ultimate versions provide real-time monitoring and graphing of VBUS current and voltage values, while the Ultimate version also provides advanced USB 2.0 triggers that allow users to create state-based and flexible trigger conditions based on data patterns, packet types, error types, events, and other criteria.

For more detailed key features and abilities, please visit the Beagle USB 480 Power Protocol Analyzer Datasheet.

Beagle USB 50000 v2 SuperSpeed Protocol Analyzer – USB SuperSpeed 3.0 Analyzer

Beagle USB 5000 v2 SuperSpeed Protocol Analyzer

The Beagle USB 5000 v2 SuperSpeed Protocol Analyzer non-intrusively monitors SuperSpeed/High-/Full-/Low-Speed USB traffic, up to 5 Gbps. The Standard version can monitor either USB 2.0 or USB 3.0 traffic at one time, while the Ultimate version can monitor USB 2.0 and USB 3.0 traffic simultaneously. This analyzer offers real-time display, search, and filtering of captured data, and also offers descriptor decoding and USB class decoding. It also offers users the ability to perform USB 2.0/USB 3.0 advanced triggers, including state-based and flexible trigger conditions based on data patterns, packet types, error types, events, and other criteria. Additionally, it provides enhanced visibility into the USB 3.0 bus, detecting low-level bus events including link training, LFPS polling, training sequences, and provides a view into the LTSSM which tracks upstream and downstream link state transitions.

For more detailed key features and abilities, please visit the Beagle USB 5000 v2 SuperSpeed Protocol Analyzer Datasheet.

USB Power Delivery Analyzer

USB Power Delivery Analyzer

The USB Power Delivery Analyzer is a tool used to record the Power Delivery (PD) protocol traffic on the USB Type-C connector. It connects in-line between two Type-C products, and passively captures all communication between them on both the CC1 and CC2 (communication channel) signals. While connected, it does not disturb any USB 3.2 Gen 2 or USB 2.0 signals, enabling capture of PD negotiation for power, USB data roles, and DisplayPort, or other Type-C Alternate Modes. This device also supports Power Delivery 3.0, extended messages, handling of new messages, and DisplayPort VDM decoding.

For more detailed key features and abilities, please visit the USB Power Delivery Analyzer Datasheet.

 

For a complete overview of all our USB products and how they compare, please visit our USB Product Guide.