Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 16 additions & 2 deletions supervisor/shared/usb/usb_msc_flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,8 +214,22 @@ int32_t tud_msc_scsi_cb(uint8_t lun, const uint8_t scsi_cmd[16], void *buffer, u

switch (scsi_cmd[0]) {
case SCSI_CMD_PREVENT_ALLOW_MEDIUM_REMOVAL:
// Host is about to read/write etc ... better not to disconnect disk
resplen = 0;
#ifdef SDCARD_LUN
if (lun == SDCARD_LUN) {
// Removable media (SD card). Respond "unsupported" so macOS
// keeps sending TEST_UNIT_READY periodically to detect card
// insertion/removal. Responding OK here causes macOS to skip
// TUR polling and miss media-present events on the SD LUN.
// See the discussion in adafruit/circuitpython#6555.
tud_msc_set_sense(lun, SCSI_SENSE_ILLEGAL_REQUEST, 0x20, 0x00);
resplen = -1;
} else
#endif
{
// Non-removable media (internal flash, SAVES). OK is fine;
// host assumes medium always present and skips TUR polling.
Comment thread
mikeysklar marked this conversation as resolved.
Outdated
resplen = 0;
}
break;

default:
Expand Down
Loading