Skip to content

Commit

Permalink
tinyusb/msc_fat_view: Fix directory population condition
Browse files Browse the repository at this point in the history
Condition to populate disk presented over USB checked if last SCSI command
was TEST_UNIT_READY.
This only worked if TEST_UNIT_READY was send twice one after the other.
It seems to work on Linux but for Windows it did not happen very often.

Now disk data is populated (init_disk_data()) on first TEST_UNIT_READY request
when medium state is set to MEDIUM_REALOAD.
  • Loading branch information
kasjer committed Jan 4, 2024
1 parent bdda7fa commit ce36f87
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions hw/usb/tinyusb/msc_fat_view/src/msc_fat_view.c
Original file line number Diff line number Diff line change
Expand Up @@ -1630,9 +1630,9 @@ tud_msc_inquiry_cb(uint8_t lun, uint8_t vendor_id[8], uint8_t product_id[16], ui
bool
tud_msc_test_unit_ready_cb(uint8_t lun)
{
bool ret = medium_state >= MEDIUM_RELOAD;
bool ret = medium_state == MEDIUM_PRESENT;

if (medium_state == MEDIUM_RELOAD && last_scsi_command == SCSI_CMD_TEST_UNIT_READY) {
if (medium_state == MEDIUM_RELOAD) {
/* This path will report medium not present */
medium_state = REPORT_MEDIUM_CHANGE;
init_disk_data();
Expand Down

0 comments on commit ce36f87

Please sign in to comment.