From b12c140a92ffd5b3b4db8998370335ac4e28c2ad Mon Sep 17 00:00:00 2001 From: mikeysklar Date: Tue, 21 Apr 2026 12:28:46 -0700 Subject: [PATCH] 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. --- supervisor/shared/filesystem.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/supervisor/shared/filesystem.c b/supervisor/shared/filesystem.c index eb4b6548d11ff..55fef541a6792 100644 --- a/supervisor/shared/filesystem.c +++ b/supervisor/shared/filesystem.c @@ -219,6 +219,13 @@ bool filesystem_init(bool create_allowed, bool force_create) { #if CIRCUITPY_SDCARDIO sdcardio_init(); + #if defined(DEFAULT_SD_CARD_DETECT) && CIRCUITPY_SDCARD_USB + // Mount the SD card now so it's ready when USB enumerates. + // Lazy mount from tud_msc_test_unit_ready_cb can lose races with + // macOS's probe timing. Gated on CIRCUITPY_SDCARD_USB to match the + // existing call site in usb_msc_flash.c (guarded by SDCARD_LUN). + automount_sd_card(); + #endif #endif return true;