host: local data toggle reset unsupported on rp2040, pio-usb, WCH USBFS, MAX3421E, RUSB2 and non-halted OHCI EDs

Open
#4,490 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
35/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
c

Research direction

Read the HCD implementations named in the issue: hcd_rp2040.c, hcd_ch32_usbfs.c, hcd_max3421.c, hcd_pio_usb.c, hcd_rusb2.c, and ohci.c, along with each controller’s reference manual and errata. Then validate tuh_msc_reset() on hardware for each board family, followed by TEST UNIT READY and a known-data read without re-enumeration. The work is done when all six HCD cases pass validation and their ports are removed from the unsupported list in docs/reference/class/msc.rst.

Written by the indexing model from the issue text.

Description

follow-up Prio 📌

Follow-up from #4009, which adds tuh_msc_reset() (BOT Reset Recovery). After each CLEAR_FEATURE(ENDPOINT_HALT) it
calls the new usbh_edpt_clear_stall() → hcd_edpt_clear_stall() to reset the host toggle to DATA0 (USB 2.0
§9.4.5). On the HCDs below this returns false, so tuh_msc_reset() always fails and leaves the interface fenced.

Remaining work

HCD State in #4009 What a fix needs
rp2040 (hcd_rp2040.c) false (was panic()) ep->next_pid = 0 on the idle endpoint; it is loaded into USB_BUF_CTRL_DATA1_PID when the buffer is armed
WCH USBFS (hcd_ch32_usbfs.c) false; the old body, which sent its own blocking CLEAR_FEATURE, is kept as send_clear_stall_sync() for the internal STALL path edpt_info->data_toggle = 0; it feeds the HOST_TX_CTRL/HOST_RX_CTRL TOG bits in hardware_start_xfer()
MAX3421E (hcd_max3421.c) false (unchanged) ep->data_toggle = 0; it becomes the HCTL_SNDTOG0/1/RCVTOG0/1 write
pio-usb (hcd_pio_usb.c) false (was a no-op true) endpoint_t.data_id lives in the Pico-PIO-USB library; needs a library accessor (the library is not modified from TinyUSB)
RUSB2 (hcd_rusb2.c) false; orphan addr_to_pipectr() removed The old body had two defects (below); rewrite with the documented sequence
OHCI (ohci.c) refuses unless the ED is halted Set sKip, wait a frame so the HC is not processing the ED, write toggleCarry, clear sKip
RUSB2 evidence (old body, removed in #4009)
  • addr_to_pipectr() indexed _hcd.ep[dev_addr]; every writer and reader uses [dev_addr - 1] (:326, :561,
    :650). For address 1 it resolved to DCPCTR (another device's row is 0), so SQCLR hit the control pipe and the
    bulk pipe's toggle was never reset; address 4 indexed past the array.
  • SQCLR was written while an OUT pipe could still be at PID=BUF. RA6M5 HW UM Rev 1.50 (Calibre 5584) §28.2.35 p866
    Note 2: set PID to NAK and wait for PBUSY=0 before SQCLR. Lookups 5c099c15f415, 7ecc06fec180.
OHCI evidence

OHCI 1.0a §4.2.3 (Calibre 774, printed p18 / PDF p32): the HCD writes HeadP/toggleCarry/Halted only while the ED is
halted, skipped or unlinked. Reset Recovery clears both endpoints, which are normally not halted. Lookup
c73480a67748. No runtime failure was observed; #4009 refuses that case conservatively.

Acceptance

  • Each HCD's change is checked against its reference manual and errata.
  • tuh_msc_reset() is validated on hardware for each board family: an idle reset between real commands, then TEST
    UNIT READY and a known-data read without re-enumeration.
  • Each port is removed from the unsupported list in docs/reference/class/msc.rst.

Why deferred

#4009 makes the fenced interface recoverable where the HCD already resets the toggle. Each change here alters
register or toggle state per port and needs its own hardware validation.

Dominant language
C
Stars
7.3k
Forks
1.6k
Avg merge
1d 19h
Merged PRs (30d)
67

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from hathach/tinyusb

All issues in hathach/tinyusb

Similar issues

More C issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.