Is there really a "USB communication protocol"?

According to Wikipedia, USB:

defines the cables, connectors and communications protocols used in a bus for connection, communication, and power supply between computers and electronic devices

But is there really a "USB communication protocol"? My understanding is that:

  1. You connect a USB device to a machine (say, Ubuntu or any kind of Linux)
  2. Linux finds the device driver for that device (somehow - bonus if you know!) and loads it
  3. The device is now connected under /dev/theDevice
  4. User space apps can now read/write to /dev/theDevice and the driver handles the low-level IO to the underlying device/hardware

To me, nowhere in this flow does a "USB communication protocol" appear. If my understanding is correct, the USB is just the cable and electrical connection between the PC and the device.

Am I wrong here? Does USB actually implement some kind of low-level protocol the underscores the flow above? If so, what is it and how does it work at a 30,000 foot view?


Solution 1:

Yes, see USB protocols

As I understand it, the USB spec defines a complex set of layered protocols and device profiles.

For example, USB devices can conform to high-level templates like mass-storage, keyboard (or Human Interface Device, etc) and be managed by a generic device driver. Some USB devices can communicate at a lower level such that the OS low level USB support can recognise that device-specific higher level drivers are needed.

Solution 2:

Question: Is there a low-level USB communication protocol in action and what is it?

Answer:

Yes there is, the USB specification includes the USB protocol which defines the way the bus is used on a bit level. This would be the 'low-level' protocol that underlies the higher level protocols i.e. mass-storage, HID, etc.

For specifics on how the USB protocol works, this OSDev wiki is helpful. Here is another interesting description using sequence diagrams to describe the various data transactions per the USB protocol.

Bonus Question: How does Linux find and load the device driver for that device?

Bonus answer:

'On Linux when using a USB-enabled kernel, a working USB device will be detected via the hardware and kernel due to the USB specification. On the hardware side the detection is done by the USB Host Controller. Then in the kernel the Host Controller Driver takes over and translates the low-level bits on the wire to USB protocol formatted information. This information then gets populated in the USB core driver in the kernel.'

I paraphrased from this excellent Opensourceforu article, which has much more detail and clarity about your question in the Linux context.