Two device-controller defects that break standard host error recovery, found while root-causing why macOS never mounts a NuttX mass-storage function (full analysis and host traces in apache/nuttx#19435): 1. epsubmit() aborted (-EBUSY) any IN request submitted while the endpoint was halted. The mass storage class halts bulk-IN for a failed device-to-host command (BOT-legal) and then submits the CSW; the CSW was dropped on the floor, so after the host's Clear-Halt the endpoint NAKed forever and the host timed out (macOS: 30 s, then a Bulk-Only-reset/device-reset spiral until it disables the port). This is exactly the race documented for years in the usbmsc_scsi.c header (David Hewson's analysis); the USBMSC_STALL_RACEWAR sleep workaround only survives hosts that clear the halt within 100 ms -- Linux does, macOS does not, which is why Linux testing never saw it. Implement the stall-queueing contract instead: requests submitted while an endpoint is halted are queued without arming the hardware (arming rewrites the buffer control word and would silently clear the STALL bit); a halt terminates any in-flight IN transfer (its hardware buffer is disarmed by the STALL write and would never complete); clearing the halt resets the data toggle and re-arms the head of the queue; stale buffer completions latched for transfers aborted by a halt are ignored. RP2040/RP23XX now select ARCH_USBDEV_STALLQUEUE, which also retires the RACEWAR's two 100 ms sleeps per failed command. 2. The USB_REQ_GETSTATUS handler in ep0setup() validated the request but never queued the two-byte response, for all three recipients (device/interface/endpoint), so EP0 NAKed the host's data stage forever and every GET STATUS timed out. macOS issues GetPipeStatus = GET STATUS(endpoint) on a halted pipe before running Bulk-Only reset recovery and hit this on every probe; lsusb -v's device-status query hangs on it as well. Send the response: endpoint recipient reports the halt bit, device recipient reports self-powered, interface reports zeros; the status stage is armed by handle_zlp() exactly as for class-dispatched IN transfers. Validated on RP2350 silicon (Raspberry Pi Pico 2 W, composite CDC-ACM + CDC-NCM + USBMSC): pre-fix, a raw-usbfs replay of macOS's sequence and timing reproduced both defects deterministically (CSW read ETIMEDOUT after a delayed clear-halt; all GET STATUS variants ETIMEDOUT). Post-fix: the CSW survives the halt and is delivered after Clear-Halt with correct tag/status/residue across a post-stall delay sweep of 0-1000 ms; all GET STATUS variants answer immediately with correct halt reporting; no regressions in the exact-length SCSI suite, Bulk-Only reset, FAT mount and full reads, CDC-NCM/ACM, or warm reboots; and macOS now mounts the volume (together with the companion usbmsc fixes). The rp2040 driver shares the code and receives the identical fix (build-tested). Assisted-by: Claude (Anthropic Claude Code) Signed-off-by: Ricard Rosson <ricard@groundbits.com> |
||
|---|---|---|
| .github | ||
| arch | ||
| audio | ||
| binfmt | ||
| boards | ||
| cmake | ||
| crypto | ||
| Documentation | ||
| drivers | ||
| dummy | ||
| fs | ||
| graphics | ||
| include | ||
| libs | ||
| mm | ||
| net | ||
| openamp | ||
| pass1 | ||
| sched | ||
| syscall | ||
| tools | ||
| video | ||
| wireless | ||
| .asf.yaml | ||
| .codespell-ignore-lines | ||
| .codespellrc | ||
| .editorconfig | ||
| .gitignore | ||
| .gitmessage | ||
| .pre-commit-config.yaml | ||
| .yamllint | ||
| AUTHORS | ||
| CMakeLists.txt | ||
| CONTRIBUTING.md | ||
| INVIOLABLES.md | ||
| Kconfig | ||
| LICENSE | ||
| Makefile | ||
| NOTICE | ||
| README.md | ||
| ReleaseNotes | ||
Apache NuttX is a real-time operating system (RTOS) with an emphasis on standards compliance and small footprint. Scalable from 8-bit to 64-bit microcontroller environments, the primary governing standards in NuttX are POSIX and ANSI standards. Additional standard APIs from Unix and other common RTOSs (such as VxWorks) are adopted for functionality not available under these standards, or for functionality that is not appropriate for deeply-embedded environments (such as fork()).
For brevity, many parts of the documentation will refer to Apache NuttX as simply NuttX.
Getting Started
First time on NuttX? Read the Getting Started guide! If you don't have a board available, NuttX has its own simulator that you can run on terminal.
Documentation
You can find the current NuttX documentation on the Documentation Page.
Alternatively, you can build the documentation yourself by following the Documentation Build Instructions.
The old NuttX documentation is still available in the Apache wiki.
Supported Boards
NuttX supports a wide variety of platforms. See the full list on the Supported Platforms page.
Contributing
If you wish to contribute to the NuttX project, read the Contributing guidelines for information on Git usage, coding standard, workflow and the NuttX principles.
License
The code in this repository is under either the Apache 2 license, or a license compatible with the Apache 2 license. See the License Page for more information.