Skip to content

Commit a2b9e97

Browse files
committed
shared/usb: reply unsupported to PREVENT_ALLOW on all LUNs
Per @tannewt review on #10967: tinyusb advertises is_removable=1 for every LUN in its default INQUIRY response (msc_device.c line 781), so the per-LUN branch was inconsistent with what the host already sees. Collapse to a single unconditional ILLEGAL_REQUEST reply — host keeps polling TUR on all LUNs, so eject/re-mount works uniformly across CIRCUITPY, SAVES, and SD.
1 parent 060019f commit a2b9e97

1 file changed

Lines changed: 7 additions & 16 deletions

File tree

supervisor/shared/usb/usb_msc_flash.c

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -214,22 +214,13 @@ int32_t tud_msc_scsi_cb(uint8_t lun, const uint8_t scsi_cmd[16], void *buffer, u
214214

215215
switch (scsi_cmd[0]) {
216216
case SCSI_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL:
217-
#ifdef SDCARD_LUN
218-
if (lun == SDCARD_LUN) {
219-
// Removable media (SD card). Respond "unsupported" so macOS
220-
// keeps sending TEST_UNIT_READY periodically to detect card
221-
// insertion/removal. Responding OK here causes macOS to skip
222-
// TUR polling and miss media-present events on the SD LUN.
223-
// See the discussion in adafruit/circuitpython#6555.
224-
tud_msc_set_sense(lun, SCSI_SENSE_ILLEGAL_REQUEST, 0x20, 0x00);
225-
resplen = -1;
226-
} else
227-
#endif
228-
{
229-
// Non-removable media (internal flash, SAVES). OK is fine;
230-
// host assumes medium always present and skips TUR polling.
231-
resplen = 0;
232-
}
217+
// All LUNs advertise is_removable=1 in INQUIRY (tinyusb default).
218+
// Reply "unsupported" so the host keeps polling TUR and can
219+
// re-mount after an eject. Responding OK tells the host to skip
220+
// TUR polling, which breaks re-mount and can miss SD insertion
221+
// events at boot. See adafruit/circuitpython#6555.
222+
tud_msc_set_sense(lun, SCSI_SENSE_ILLEGAL_REQUEST, 0x20, 0x00);
223+
resplen = -1;
233224
break;
234225

235226
default:

0 commit comments

Comments
 (0)