Skip to content

Commit 8eb8aaa

Browse files
committed
raspberrypi: bump MSC buffer to 16KB for RP2040 boards with SD-over-MSC
On Adafruit Feather RP2040 Adalogger and similar RP2040 boards that expose an SD card as a second USB MSC LUN, the default 1024-byte MSC buffer triggers bulk-IN endpoint stalls on macOS during multi-sector READ(10) probes. macOS retries ~18 times over 5 minutes then gives up; Linux handles the same firmware cleanly. Bumping CFG_TUD_MSC_BUFSIZE to 16384 clears the stall. This PR only applies the bump when CHIP_VARIANT=RP2040 and CIRCUITPY_SDCARDIO=1, so RP2350 boards and non-SD RP2040 boards keep the small buffer and the ~15KB RAM cost. This is a stopgap workaround. Metro RP2350 and Fruit Jam (both RP2350) handle the same macOS traffic fine at 1024 bytes, so the underlying issue is almost certainly in the RP2040 USB peripheral or tinyusb's rp2 device driver. Root-cause ticket will be filed separately.
1 parent 26f70c1 commit 8eb8aaa

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

ports/raspberrypi/Makefile

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,20 @@ CFLAGS += \
200200
-DCFG_TUD_CDC_RX_BUFSIZE=256 \
201201
-DCFG_TUD_MIDI_TX_BUFSIZE=128 \
202202
-DCFG_TUD_CDC_TX_BUFSIZE=256 \
203-
-DCFG_TUD_MSC_BUFSIZE=1024 \
204203
-DPICO_RP2040_USB_DEVICE_UFRAME_FIX=1 \
205204
-DPICO_RP2040_USB_DEVICE_ENUMERATION_FIX=1 \
206205

206+
# CFG_TUD_MSC_BUFSIZE: 1024 bytes is enough for internal flash MSC but
207+
# causes macOS bulk-IN endpoint stalls on RP2040 during multi-sector
208+
# SD card READ(10) probes. Bump to 16 KB only for RP2040 boards that
209+
# actually expose an SD card over MSC. Other chips and non-SD boards
210+
# stay at the small default. Root cause tracked at hathach/tinyusb.
211+
ifeq ($(CHIP_VARIANT)_$(CIRCUITPY_SDCARDIO),RP2040_1)
212+
CFLAGS += -DCFG_TUD_MSC_BUFSIZE=16384
213+
else
214+
CFLAGS += -DCFG_TUD_MSC_BUFSIZE=1024
215+
endif
216+
207217
# option to override default optimization level, set in boards/$(BOARD)/mpconfigboard.mk
208218
CFLAGS += $(OPTIMIZATION_FLAGS)
209219

0 commit comments

Comments
 (0)