USB - mcaple/tmk_keyboard GitHub Wiki

Specification

https://www.usb.org/documents

HID

https://www.usb.org/document-library/device-class-definition-hid-111

HID Usage Tables

https://www.usb.org/document-library/hid-usage-tables-122

Compliance Tools

https://www.usb.org/compliancetools

XHCICV

TBD on AB350M Pro4 Windows10(XHCI)

USB3CV

TBD on AB350M Pro4 Windows10(XHCI)

USB20CV

device CH9 HID description
USB-USB pass pass 2021-08-31 1ef45c
USB-USB pass SET_Protocol:fail 2020-12-24 2b74203b Mouse interface
IBMPC-USB pass pass 39273d
HHKB Alt pass pass 2021-08-17

on Lenovo ThinkPad X201s Windows10(EHCI).

HID Report Dump

usbhid-dump -eall -t10000 -d feed:caaa
005:017:000:STREAM             1609920650.369302
 00 00 04 00 00 00 00 00

005:017:000:STREAM             1609920650.489261
 00 00 00 00 00 00 00 00

005:017:000:STREAM             1609920650.721188
 00 00 04 00 00 00 00 00

Wireshark USB capture

https://wiki.wireshark.org/CaptureSetup/USB

sudo modprobe usbmon
sudo setfacl -m u:$USER:r /dev/usbmon*

usbmon

https://www.kernel.org/doc/Documentation/usb/usbmon.txt

STALL

The STALL packet indicates that the endpoint has halted, or a control pipe does not support a certain request.

The host must never issue a STALL handshake packet.

https://www.silabs.com/community/mcu/8-bit/knowledge-base.entry.html/2017/06/18/the_role_of_stallha-pQTe

Control Transfer

https://www.beyondlogic.org/usbnutshell/usb4.shtml#Control p.225 of USB Rev 2.0

Control transfer is comprised of two or three transaction stages.

Setup stage

Device returns ACK or no response on error. STALL and NAK can be used.

SETUP[h] - DATA0[h] - ACK[d]

Data stage

This is optional.

IN[h] - DATAx[d] - ACK[h]
OUT[h] - DATAx[h] - ACK[d]

Status stage

OUT[h] - DATA1(ZLP)[h] - ACK[d]
IN[h] - DATA1(ZLP)[d] - ACK[h]

STALL on Control Transfer

8.5.3

When a STALL handshake is sent by a control endpoint in either the Data or Status stages of a control transfer, a STALL handshake must be returned on all succeeding accesses to that endpoint until a SETUP PID is received. The endpoint is not required to return a STALL handshake after it receives a subsequent SETUP PID. For the default endpoint, if an ACK handshake is returned for the SETUP transaction, the host expects that the endpoint has automatically recovered from the condition that caused the STALL and the endpoint must operate normally.

8.5.3.4

Control pipes have the unique ability to return a STALL handshake due to function problems in control transfers. If the device is unable to complete a command, it returns a STALL in the Data and/or Status stages of the control transfer. Unlike the case of a functional stall, protocol stall does not indicate an error with the device. The protocol STALL condition lasts until the receipt of the next SETUP transaction, and the function will return STALL in response to any IN or OUT transaction on the pipe until the SETUP transaction is received. In general, protocol stall indicates that the request or its parameters are not understood by the device and thus provides a mechanism for extending USB requests. A control pipe may also support functional stall as well, but this is not recommended. This is a degenerative case, because a functional stall on a control pipe indicates that it has lost the ability to communicate with the host. If the control pipe does support functional stall, then it must possess a Halt feature, which can be set or cleared by the host. Chapter 9 details how to treat the special case of a Halt feature on a control pipe. A well-designed device will associate all of its functions and Halt features with non-control endpoints. The control pipes should be reserved for servicing USB requests.

Device Qualifier Descriptor

A high-speed capable device that has different device information for full-speed and high-speed must have a Device Qualifier Descriptor (USB_DEVICE_QUALIFIER_DESCRIPTOR). For example, if the device is currently operating at full-speed, the Device Qualifier returns information about how it would operate at high-speed and vice-versa.

https://www.keil.com/pack/doc/mw/USB/html/_u_s_b__device__qualifier__descriptor.html

"If the device is attached to a USB 1.1 hub, is operating at Full-Speed, and its USB Device Descriptor bcdUSB field is greater than or equal to 0x200, the hub driver will issue a GET_DESCRIPTOR for descriptor type DEVICE_QUALIFIER (6). The successful completion of the request indicates the device can support USB 2.0 high-speed operation."

https://www.microchip.com/forums/m688392.aspx