audit 0.21.0: STM32 FSDEV follow-ups

Open
#4,535 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
15/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
c
Domain
embedded-iot

Research direction

Start by reading the ISO clear-stall and non-stalled clear-halt paths in dcd_stm32_fsdev.c around lines 838-854, then the core contract in src/device/dcd.h (171-173) and the caller in src/device/usbd.c (1840-1853). Cross-check #4197 and #4065 for overlapping locking and EP0 work before changing anything. Done means the ISO/no-stall clear-halt semantics and pending-transfer contract are agreed and covered by core/MSC tests, then confirmed with HIL on stm32f072disco.

Written by the indexing model from the issue text.

Description

follow-up Prio 📌

Deferred defects found in the repository audit of 0.21.0..ad7c83db8 (batch port-fsdev). Each was validated against the source at ad7c83db8 and judged real but too large, or too hardware-dependent, for the audit PR's contained fixes.

1. ISO clear-stall retains STAT bits in the write and resets DTOG. The core forwards endpoint-halt requests without filtering ISO endpoint types.
  • Where: dcd_stm32_fsdev.c:838–854
  • Verdict: valid, with qualification: VALID can become DISABLED; recovery does not necessarily require reopening—another arm may restore it; introduced: Older; ISO path unchanged; severity: medium
  • Hardware/spec dependence: Yes. F072 STAT semantics verified; ISO DTOG is also a buffer selector, making the proposed STAT-only fix incomplete. Other variants pending.
  • Overlap: #4198 is a different ISO completion race; #4197 adds locking but retains this logic. Neither covers it.
  • Remaining work and verification: Resolve ISO request handling and internal clear-stall semantics together. Avoid applying only the suggested STAT mask without checking buffer-selector preservation. Test malformed halt requests during ISO streaming.
2. Non-stalled clear-halt preserves the armed transfer but clears software BUSY. Preserving CLAIMED does not protect callers that submit directly.
  • Where: dcd_stm32_fsdev.c:847–850; src/device/usbd.c:1840–1853
  • Verdict: valid. Concrete caller: MSC clear-halt → usbd_edpt_ready() → prepare_cbw(); ready ignores CLAIMED and usbd_edpt_xfer() checks only BUSY.; introduced: Yes for FSDEV’s armed-but-not-busy combination; unconditional BUSY clearing is older; severity: medium
  • Hardware/spec dependence: Software mismatch established. Register behavior supported for F072; cross-DCD contract and hardware validation pending. No record.
  • Overlap: #4197 serializes register accesses, not transfer ownership; not covered
  • Remaining work and verification: Reconcile BUSY preservation with callers intentionally using clear-stall to discard state. Add core/MSC tests proving a non-stalled armed transfer cannot be submitted over; then clear-halt-under-load HIL.
3. Public clear-stall contract omits pending-transfer preservation.
  • Where: src/device/dcd.h:171–173; dcd_stm32_fsdev.c:841–845
  • Verdict: valid documentation gap, but usbd does not consistently honor the proposed contract, as C.F4 shows; introduced: Header omission older; new FSDEV behavior makes it material; severity: low
  • Hardware/spec dependence: Text edit is harmless mechanically; normative behavior needs the C.F4 contract review. No record.
  • Overlap: #4503 mentions this contract in a proposed porting skill, not a repair
  • Remaining work and verification: Document the agreed contract alongside the ownership fix; do not merely shorten the local comment and declare consistency established.
4. A simultaneous old TX completion and new SETUP can re-arm an old EP0 IN chunk.
  • Where: dcd_stm32_fsdev.c:267–268,428–439
  • Verdict: valid with narrowed trigger: requires a DCD transfer spanning multiple packets, e.g. CFG_TUD_ENDPOINT0_BUFSIZE=128, MPS=64. Default configuration does not take this continuation path.; introduced: Older: RX-first handling also continued the old transfer after handling SETUP; severity: medium
  • Hardware/spec dependence: F072 SETUP-to-NAK behavior verified; other variants and runtime reproduction pending. No record.
  • Overlap: #4065 covers superseded EP0 arms broadly, but not this specific ISR continuation; partial. #213 reports a different, undiagnosed symptom.
  • Remaining work and verification: Add this concrete case to #4065’s handoff. Suppress obsolete ISR continuation without losing valid completion ordering; test enlarged EP0 buffers with simultaneous flags, then superseding-SETUP HIL on stm32f072disco.
Adjudication notes: port-fsdev

Claims still needing read-doc completion or recorded evidence:

  • C.F1 / S.F03: F072 pull-up behavior was verified visually in book 6529, APM32F072x8xB Reference Manual, Rev 1.7, §26.4.1.7, pp.373–374. No APM32 errata were found. F103 searches returned no manual: does offset 0x58 exist, and what mechanism controls attachment? Keep F103 excluded from the proposed wrapper change.
  • C.F2: Book 3637, RM0091, Rev 10, pp.876, 898–899, confirms reception capacity is the programmed rounded block size; book 4926, ES0223, Rev 6, §2.15, pp.23–24, supplies no exception invalidating the example. Before a shared-driver fix is signed off: which other FSDEV variants accept/count rounded-capacity packets, including zero-length arms and ISO buffers?
  • C.F3–F5 / S.F07: RM0091 pp.877 and 893 supports the F072 SETUP and toggle analysis. USB specification book 775, §9.4.5, PDF p.284, confirms clear-halt resets data toggles. Still check USB errata 6726/6727, affected variant manuals/errata, and these questions: what should an ISO halt request do; which ISO DTOG bits select buffers; and how must pending transfers survive clear-halt or a superseding SETUP?
  • S.F04, only if revived: what ordering/barriers do APM32 Cortex-M0/M3 and each other vendor’s interrupt controller require before re-enabling interrupts? That lookup did not run.
  • C.F9: Visually checked book 2100, AT32F403A/407 RM Rev 2.07, §24.3.3 p.437, and book 2099, AT32F413 RM Rev 2.05, §21.3.3 p.344. Both refute the stated CAN-starvation premise. No matching AT32 errata were found. Persist the refutation if the audit requires a claim-record artifact.

No additional defect was established in the batch’s changes. typec_stm32.c changes only its license header. No builds, unit tests, or hardware runs were performed; the validation entries above are proposed checks, not passes. APM32 preprocessing succeeded for both variants. No files were changed.

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.