lowRISC / lowRISC/opentitan

[usbdev] usbdev does not tolerate 'dribble'

Open
#19,663 3 comments 0 reactions 2 assignees Claimed by @a-will View on GitHub
Priority:P3 Type:Enhancement Type:FutureRelease
Dominant language
SystemVerilog
Stars
3.6k
Forks
1.1k
Avg merge
2d 22h
Merged PRs (30d)
141

Description

### Description

**Overview**

usbdev does not properly tolerate long 'dribble' (USB 2.0 Specification section 7.1.9.1) that may result from skew in the propagation of Full Speed signaling through USB hubs. This is anticipated to be observed only in the presence of multiple older/budget (USB 2.0-only?) hubs being connected between the host controller and device. Presently it has been observed only in simulation.

**Workaround**

If CRC errors are observed, use fewer levels of hub hierarchy, or faster/more recent hubs which are expected to be less likely to introduce skew in the propagation of Full Signals. There may also be some benefit to reducing cable lengths.

**Details**

The specification permits the propagation of the EOP signaling to take up to 15ns longer than the propagation of J-K or K-J transitions (whichever is the longer), as also [annotated here](https://microchip.my.site.com/s/article/USB-Full-Speed-Signal-Quality-Dribble-Bit) and usbdev tolerates accommodates only half a bit interval of delay in the EOP signaling before it will sample another bit which then becomes part of the CRC calculation.

With two USB hubs introducing 15ns of skew each between the host controller and the USB device, operation can be maintained. With 3 or more hubs there is a risk of communications failing because usbdev is sampling an additional bit and raising CRC errors.

The issue may be anticipated to be worse with longer received DATA packets and the presence of frequency mismatch between the host and device as the sampling drifts further.

Simulating the introduction of a single 48MHz clock cycle of dribble at the end of a short SETUP DATA packet, we see correct reception of the packet, and the usbdev acknowledging the transaction from the DPI model.

![DribbleCRC_1tick](https://github.com/lowRISC/opentitan/assets/117650394/24747964-c717-4ddb-93fa-69509ab85012)

With the introduction of 2 clock cycles of dribble (= half a bit interval, ie. 41.7ns) the device accepts another bit and the CRC16 mismatches.

![DribbleCRC_2ticks](https://github.com/lowRISC/opentitan/assets/117650394/3edcb17e-d261-4b8f-b0a6-8b13a832abdf)

It seems that with our present sampling/clocking scheme, we may be better aligning the CRC16 within the packet at 8n bits received (byte boundary) rather than implicitly aligning it with the final bit sampled before EOP.

The mention of dribble tolerance in the specification seems directed at preventing spurious bit stuffing errors, ie. that in this special case, the EOP detection should take precedence over the expectation of a 'bit stuffing 0' after the receipt of 6 consecutive '1's. In that regard, usbdev is robust. The specified maximum dribble does not result in packet rejection through bit stuffing error.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.