shared/usb: correctly report the SD LUN as removable media#10967
Open
mikeysklar wants to merge 1 commit intoadafruit:mainfrom
Open
shared/usb: correctly report the SD LUN as removable media#10967mikeysklar wants to merge 1 commit intoadafruit:mainfrom
mikeysklar wants to merge 1 commit intoadafruit:mainfrom
Conversation
Respond with "unsupported" for the SD LUN (removable media) and OK for internal flash / SAVES LUNs (non-removable). Responding OK for a removable LUN tells macOS the medium is always present, and macOS then skips TEST_UNIT_READY polling. If the SD isn't ready at the single enumeration probe, macOS never re-checks and LUN 1 fails to publish an IOMedia node. Hathach documented this behavior back in adafruit#6555; the SD case wasn't differentiated at the time. Fixes adafruit#10965.
This was referenced Apr 22, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was wrong
The SD card exposed as a USB MSC LUN doesn't mount on macOS.
ioregshows the SCSI nub appears but never progresses to publishing anIOMedia. Linux handles the same firmware fine.Why: CircuitPython was telling the host "this LUN's medium is always present" for every LUN, including the SD card. On macOS that means "skip
TEST_UNIT_READYpolling" — so if the SD wasn't ready at the one-shot enumeration probe, macOS never re-checked and gave up on the LUN. Linux ignored the hint and kept polling, which is why it worked there.@hathach documented this exact macOS behavior back in #6555; the per-LUN distinction wasn't applied at the time.
What changed
Report the SD LUN as removable media, report internal flash and SAVES as non-removable. macOS now keeps polling TUR on the SD LUN and correctly picks up card insertion and removal.
~10 lines in
supervisor/shared/usb/usb_msc_flash.c— per-LUN branch on the existingPREVENT_ALLOW_MEDIUM_REMOVALhandler. No RAM or flash cost.Tested on
/dev/sdc+/dev/sddcorrect sizes, no regressionWindows not tested.
Related
Credit to @dhalbert for pointing at #6555 and @hathach for the original analysis.