USB

From Deskthority wiki
Jump to navigation Jump to search

This article is a stub. You can help Deskthority by expanding it.

Universal Serial Bus, commonly referred to as USB, is a modern serial peripheral interface that is the current method for connecting keyboards and mice. USB allows for the connection of a vast range of peripherals to computers, including printers, network adapters, microphones, displays and hard drives.

Properties

USB allows a peripherals to expose multiple interfaces for different types of devices. For instance, a peripheral could be both a keyboard and a storage device, each on a separate logic interface.[footnote 1]

Unlike e.g. PS/2, the bus is controlled by the host. The host decides speed, timing, power management and whenever devices are allowed to send bytes to the host. Peripherals don't communicate between each-other.

USB does not actually have daisy-chaining but allows tree-shaped networks with a "hub" in each node. When a device has one or more external ports, either the device itself and its ports are all under the hub or the port is a pass-through through the device cable to a separate plug on the host side.[footnote 2]

A hub can be powered or not powered. On a non-powered hub, all input devices must share 500 mA power from the host between them (and the hub itself). This can cause problems with some backlit keyboards that use more power. If a device requests too much power, the host is within its rights to shut it off. Devices are also required to go into a low-power mode whenever the host does.

Human Interface Device

The Human Interface Device (HID) subprotocol is used for input devices including keyboards, pointing devices and game controllers. HID uses the USB 2.0 protocol (or earlier), even if the port is capable of faster speeds. This uses the original four leads that are present in every cable. A keyboard with a USB C port on the keyboard side should therefore work when plugged into a USB-Type A port capable of only USB 2.0.

Report Descriptor

The USB-HID specifies that every peripheral declares its report format in a "Report Descriptor", defined in a binary language that needs to be parsed on the host side. This complex report descriptor language should —in theory— allow for a very large number of different report formats, including keyboards for n-key rollover over full-speed (or greater) USB.

Unfortunately, because of its complexity, the standard has not been interpreted the same everywhere and there have been (or are) still slight differences in how host implementations work. For instance, MacOS X does not permit the same key to be reported twice.[1]

Keyboard Boot Protocol

To avoid complexity in boot code, such as PC BIOS:es and bootloaders, the USB HID standard specifies that keyboards (and mice) should also support a hard-coded "boot protocol" and be able to switch between this and its regular protocol on the host's request. The keyboard boot protocol imposes a limitation of six concurrent keys plus modifiers to be pressed at one time. This behaviour is referred to as 6-key rollover, or 6KRO.

Most keyboards describe a protocol identical to the boot protocol as its regular protocol. There can be many arguments for such a design choice, including less complexity in the keyboard firmware, the protocol being well understood, 6KRO being more than enough for office use, 6KRO being more than what the keyboard's matrix supports, use of low-speed USB and compatibility with bad BIOS:es (read below).

BIOS problems

A problem is that many common BIOS:es and bootloaders do not follow the USB HID standard properly. They incorrectly expect that all keyboards talk the boot protocol from the start, and therefore they will never request the keyboard to switch from its regular protocol. This is the reason why some keyboards can not be used to enter BIOS on some PCs. Often the keyboard is blamed, while the fault lies with the BIOS.

Some keyboards work around this problem by allowing the user to change between 6-key and NKRO on-the-fly.

Firmware tricks

A workaround that simply increases the size of the report (with the first eight bytes being the same as the boot report) does unfortunately cause some BIOS:es to crash.

A workaround for increased rollover capacity with maintained PC BIOS compatibility is to divide a longer report into smaller chunks, each sent from a different logical interface. Unfortunately, several keyboards that employ this strategy do not work properly with MacOS X because it recognises each interface as a separate device and does not combine modifiers from one keyboard with non-modifiers from another.

Soarer's workaround

The forum user Soarer discovered a workaround that supposedly does work with both bad BIOS:es and MacOS. The keyboard presents two keyboard interfaces: The first is a "boot keyboard" that sends the boot report always but which is described in its Report Descriptor as empty - so the reports would be ignored by a capable host. The other interface sends the n-KRO protocol report but does not present itself as a "boot keyboard" - so it would be ignored by a non-capable BIOS. [2] This trick is known to be used in Soarer's Converter and firmware.

Footnotes

  1. One device known to actually be both a keyboard and a storage device is the Kinesis Advantage 2, where the storage device is used for upgrading the keyboard's firmware and settings
  2. Some keyboards carry passthrough not only for a second USB bus but also for analogue headphone and microphone jacks.

External links

See also

References

  1. Post by thefloweringash on Geekhack—Noppoo Choc Mini on MacOS. Dated 2011-12-06
  2. Post by Soarer on Geekhack—Re:Are there any USB NKRO keyboards on the market yet?. Posted 2013-10-04. Retrieved 2016-03-06.