Skip to content

Commit b12c140

Browse files
committed
shared/filesystem: mount SD at filesystem_init for reliable MSC probe
The lazy automount in tud_msc_test_unit_ready_cb can lose races with macOS's USB MSC probe timing -- the host asks whether LUN 1 is ready before the card has finished mounting, sees NOT_READY, and may give up before trying again. Mounting during filesystem_init ensures the SD card is live by the time USB enumerates, so the first probe succeeds. Affects boards that define DEFAULT_SD_CARD_DETECT; behavior on boards without an auto-mount path is unchanged.
1 parent 26f70c1 commit b12c140

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

supervisor/shared/filesystem.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,13 @@ bool filesystem_init(bool create_allowed, bool force_create) {
219219

220220
#if CIRCUITPY_SDCARDIO
221221
sdcardio_init();
222+
#if defined(DEFAULT_SD_CARD_DETECT) && CIRCUITPY_SDCARD_USB
223+
// Mount the SD card now so it's ready when USB enumerates.
224+
// Lazy mount from tud_msc_test_unit_ready_cb can lose races with
225+
// macOS's probe timing. Gated on CIRCUITPY_SDCARD_USB to match the
226+
// existing call site in usb_msc_flash.c (guarded by SDCARD_LUN).
227+
automount_sd_card();
228+
#endif
222229
#endif
223230

224231
return true;

0 commit comments

Comments
 (0)