Skip to content

Commit 876c646

Browse files
committed
Fix Mac crash when waking up with an ejected CIRCUITPY
We now correctly set the reason for the unit not being ready and always start the unit. Fixes #2567
1 parent 90c6767 commit 876c646

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

supervisor/shared/usb/usb_msc_flash.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,8 @@ bool tud_msc_test_unit_ready_cb(uint8_t lun) {
208208
return false;
209209
}
210210
if (ejected[lun]) {
211+
// Set 0x3a for media not present.
212+
tud_msc_set_sense(lun, SCSI_SENSE_NOT_READY, 0x3A, 0x00);
211213
return false;
212214
}
213215

@@ -243,10 +245,8 @@ bool tud_msc_start_stop_cb(uint8_t lun, uint8_t power_condition, bool start, boo
243245
if (disk_ioctl(current_mount, CTRL_SYNC, NULL) != RES_OK) {
244246
return false;
245247
}
246-
} else {
247-
// Start the unit, but only if not ejected.
248-
return !ejected[lun];
249248
}
249+
// Always start the unit, even if ejected. Whether media is present is a separate check.
250250
}
251251

252252
return true;

0 commit comments

Comments
 (0)