dwc2 host (esp32-s3): MSC read intermittently hangs mid-transfer in msc_file_explorer_freertos

Open
#4,605 0 comments 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
8/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Active
Tech stack
c
Domain
embedded-iot

Research direction

Start in the dwc2 host driver around handle_channel_irq()'s abort-retire path and the invalid-CSW branch in msc_host.c, then reproduce with host/msc_file_explorer_freertos on the espressif_s3_devkitm HIL cell while running dd 1024. Under a debugger, dump HCCHAR/HCINT/HCTSIZ/HAINT/HAINTMSK and the endpoint xfer state at the stall, and cross-check the DWC2 Programming Guide on write-1-to-clear HCINT.ChHltd racing a new halt. Done means naming whether ChHltd or XferCompl is lost or the channel was never re-armed, with the hang no longer reproducing on the farm.

Written by the indexing model from the issue text.

Description

follow-up Prio 📌

host/msc_file_explorer_freertos on the farm's espressif_s3_devkitm hangs partway through dd 1024. The console stops right after dd: reading 1024 sectors (524288 bytes), 8 sectors/xfer ..., with no CSW error and no further output, and the cell fails with "MSC read produced no speed report". The disk is a UDisk 5.00 stick (30720000 blocks).

Evidence

Rates are per cell, slave-mode / DMA variant:

Build Failed
master 93aa62bce 3 of 16 (slave 3/8, DMA 0/8)
master 17301f1a6 0 of 4
audit branch (#4542) with an extra channel->hcint = HCINT_HALTED write in handle_channel_irq()'s abort-retire path about 9 of 16 (slave and DMA)
the same branch without that write 1 of 16
  • A debug print in msc_host.c's invalid-CSW branch never fired, so the stall is below the class: no completion arrives for an armed transfer.
  • Removing the extra HCINT write (now dropped from #4542) brings the rate back to about master's. The higher rate with it suggests a timing-sensitive lost or stale channel interrupt in the dwc2 host. It is not proven which.

Remaining work

  • Catch a hang under a debugger and record the channel's HCCHAR/HCINT/HCTSIZ/HAINT/HAINTMSK and the endpoint's xfer state, to see whether a ChHltd or XferCompl is lost or the channel was never re-armed.
  • Check against the DWC2 Programming Guide whether a host write-1-to-clear of HCINT.ChHltd on a channel can race a new halt for the same channel.

Found while validating #4542 on the HIL farm. Not reproduced on any other dwc2 host board.

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.