nuttx/drivers
Ricard Rosson cfcfa6b085 usbmsc: fix composite-mode class requests and Hi>Di stall behavior
Three defects that together prevented macOS from ever mounting a
composite USBMSC function (Linux was mostly unaffected because its
probe sequence and recovery timing never exercised these paths):

1. usbmsc_setup() compared the class-request wIndex against the
   compile-time constant USBMSC_INTERFACEID (= CONFIG_USBMSC_IFNOBASE,
   i.e. 0) instead of the composite-assigned priv->devinfo.ifnobase.
   In composite mode the MSC interface number is nonzero, so
   GET MAX LUN, Bulk-Only Mass Storage Reset, and GET/SET INTERFACE
   all failed the index check and stalled EP0.  Standalone MSC is
   unaffected (ifnobase == 0), which is why this went unnoticed.

2. usbmsc_deferredresponse() has its entire body inside
   #ifndef CONFIG_USBMSC_COMPOSITE, so the deferred EP0 status stage
   for MSRESET/SETINTERFACE was never sent in composite mode and the
   host's Bulk-Only reset timed out.  (Unreachable before fix 1 --
   MSRESET used to stall at the wrong-interface check.)  Compile the
   body in composite mode too, but suppress the worker's deferred
   response for SETCONFIGURATION there: the composite driver answers
   that request itself, and a duplicate zero-length packet corrupts
   the EP0 state.

3. usbmsc_cmdfinishstate() stalled the bulk IN endpoint whenever a
   device-to-host command left a residue, even when the response had
   already been sent and terminated by a short packet (or ZLP).  The
   stall is BOT-legal (USB MSC BOT 6.7.2) but gratuitous: the short
   packet already ended the data phase and the residue is reported in
   dCSWDataResidue.  Hosts such as macOS answer any bulk-IN halt during
   device probing with a full Bulk-Only reset sequence, which costs
   seconds per command or aborts the probe entirely (macOS probes
   MODE SENSE(6) with allocation lengths that exceed the response;
   Linux's probe does not).  Only halt the endpoint when nothing
   terminated the data phase.

Root-cause analysis and host traces in apache/nuttx#19435.

Validated on RP2350 silicon (Raspberry Pi Pico 2 W, composite
CDC-ACM + CDC-NCM + USBMSC): GET MAX LUN answers 1 LUN (previously
EP0 stall and a garbage LUN count on macOS), MSRESET completes 10/10
(previously ETIMEDOUT), MODE SENSE(6) alloc=0xC0 returns short data
plus a CSW with dCSWDataResidue and zero bulk-IN stalls across the
exact-length suite, and macOS now mounts the volume (together with the
companion DCD fixes).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Signed-off-by: Ricard Rosson <ricard@groundbits.com>
2026-08-03 20:59:08 +08:00
..
1wire drivers/efuse/efuse: Drivers Registered With World Write Permissions(Part 1) 2026-08-03 17:23:22 +08:00
aie drivers/efuse/efuse: Drivers Registered With World Write Permissions(Part 1) 2026-08-03 17:23:22 +08:00
analog drivers/efuse/efuse: Drivers Registered With World Write Permissions(Part 1) 2026-08-03 17:23:22 +08:00
audio drivers/efuse/efuse: Drivers Registered With World Write Permissions(Part 1) 2026-08-03 17:23:22 +08:00
bch drivers/efuse/efuse: Drivers Registered With World Write Permissions(Part 1) 2026-08-03 17:23:22 +08:00
can drivers/efuse/efuse: Drivers Registered With World Write Permissions(Part 1) 2026-08-03 17:23:22 +08:00
clk !include/fcntl.h: align open flags with Linux values 2026-07-03 10:33:47 +08:00
contactless drivers/efuse/efuse: Drivers Registered With World Write Permissions(Part 1) 2026-08-03 17:23:22 +08:00
coresight drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-08-03 17:23:22 +08:00
crypto drivers/efuse/efuse: Drivers Registered With World Write Permissions(Part 1) 2026-08-03 17:23:22 +08:00
devicetree include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
dma
dummy
eeprom drivers/efuse/efuse: Drivers Registered With World Write Permissions(Part 1) 2026-08-03 17:23:22 +08:00
efuse drivers/efuse/efuse: Drivers Registered With World Write Permissions(Part 1) 2026-08-03 17:23:22 +08:00
i2c drivers/efuse/efuse: Drivers Registered With World Write Permissions(Part 1) 2026-08-03 17:23:22 +08:00
i2s drivers/efuse/efuse: Drivers Registered With World Write Permissions(Part 1) 2026-08-03 17:23:22 +08:00
i3c drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-08-03 17:23:22 +08:00
input drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-08-03 17:23:22 +08:00
ioexpander drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-08-03 17:23:22 +08:00
ipcc drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-08-03 17:23:22 +08:00
lcd drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-08-03 17:23:22 +08:00
leds drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-08-03 17:23:22 +08:00
loop drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-08-03 17:23:22 +08:00
math drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-08-03 17:23:22 +08:00
misc libs/libc: Fix divide-by-zero in stat() with large filesystem block sizes 2026-08-03 20:58:39 +08:00
mmcsd libs/libc: Fix divide-by-zero in stat() with large filesystem block sizes 2026-08-03 20:58:39 +08:00
modem drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-08-03 17:23:22 +08:00
motor drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-08-03 17:23:22 +08:00
mtd libs/libc: Fix divide-by-zero in stat() with large filesystem block sizes 2026-08-03 20:58:39 +08:00
net drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-08-03 17:23:22 +08:00
note drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-08-03 17:23:22 +08:00
pci drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-08-03 17:23:22 +08:00
pinctrl drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-08-03 17:23:22 +08:00
pipes drivers/: Multiple Drivers Are Registered With World Writable Part 3 2026-08-03 17:23:22 +08:00
power drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-08-03 17:23:22 +08:00
rc drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-08-03 17:23:22 +08:00
regmap include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
reset include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
rf drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-08-03 17:23:22 +08:00
rpmsg drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-08-03 17:23:22 +08:00
rptun drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-08-03 17:23:22 +08:00
segger drivers/segger: Download systemview from NuttX Mirror Repo 2026-06-10 22:40:26 +08:00
sensors drivers/: Multiple Drivers Are Registered With World Writable Part 3 2026-08-03 17:23:22 +08:00
serial drivers/: Multiple Drivers Are Registered With World Writable Part 3 2026-08-03 17:23:22 +08:00
spi drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-08-03 17:23:22 +08:00
syslog drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-08-03 17:23:22 +08:00
thermal include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
timers drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-08-03 17:23:22 +08:00
usbdev usbmsc: fix composite-mode class requests and Hi>Di stall behavior 2026-08-03 20:59:08 +08:00
usbhost libs/libc: Fix divide-by-zero in stat() with large filesystem block sizes 2026-08-03 20:58:39 +08:00
usbmisc drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-08-03 17:23:22 +08:00
usbmonitor include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
usrsock drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-08-03 17:23:22 +08:00
vhost include/debug.h: Move to include/nuttx/debug.h 2026-04-07 07:50:06 -03:00
video drivers/: Multiple Drivers Are Registered With World Writable Part 3 2026-08-03 17:23:22 +08:00
virtio drivers/: Multiple Drivers Are Registered With World Writable Part 3 2026-08-03 17:23:22 +08:00
wireless drivers/: Multiple Drivers Are Registered With World Writable - Part 2 2026-08-03 17:23:22 +08:00
.gitignore
CMakeLists.txt
drivers_initialize.c serial/uart_rpmsg: add _raw version of driver 2026-02-23 09:19:57 -03:00
Kconfig espressif/rmt: replace rmtchar with arch-specific lirc adapter 2026-04-04 11:18:32 -03:00
Makefile docs/rc: document RC/LIRC drivers and remove empty drivers/rmt files 2026-04-04 11:18:32 -03:00