From ecde125fa7888a8d0c1fbfac1584caf5f58aa9a7 Mon Sep 17 00:00:00 2001 From: Frank Gevaerts Date: Sat, 22 Mar 2008 21:21:37 +0000 Subject: Sending an empty data block before sending the FAIL CSW seems to make Windows happier if a device is not present (e.g. an empty sd card slot) (fix proposed by Martin Ritter) git-svn-id: svn://svn.rockbox.org/rockbox/trunk@16750 a1c6a512-1295-4272-9138-f99709370657 --- firmware/usbstack/usb_storage.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'firmware') diff --git a/firmware/usbstack/usb_storage.c b/firmware/usbstack/usb_storage.c index c528a3a21d..0b433764cf 100644 --- a/firmware/usbstack/usb_storage.c +++ b/firmware/usbstack/usb_storage.c @@ -673,6 +673,8 @@ static void handle_scsi(struct command_block_wrapper* cbw) case SCSI_MODE_SENSE_10: { if(! lun_present) { + /* Windows expects an empty command result before the csw */ + usb_drv_send(usb_endpoint, 0, 0); send_csw(UMS_STATUS_FAIL); cur_sense_data.sense_key=SENSE_NOT_READY; cur_sense_data.asc=ASC_MEDIUM_NOT_PRESENT; @@ -717,6 +719,8 @@ static void handle_scsi(struct command_block_wrapper* cbw) MIN(sizeof(struct mode_sense_data_10), length)); break; default: + /* Windows expects an empty command result before the csw */ + usb_drv_send(usb_endpoint, 0, 0); send_csw(UMS_STATUS_FAIL); cur_sense_data.sense_key=SENSE_ILLEGAL_REQUEST; cur_sense_data.asc=ASC_INVALID_FIELD_IN_CBD; @@ -727,6 +731,8 @@ static void handle_scsi(struct command_block_wrapper* cbw) } case SCSI_MODE_SENSE_6: { if(! lun_present) { + /* Windows expects an empty command result before the csw */ + usb_drv_send(usb_endpoint, 0, 0); send_csw(UMS_STATUS_FAIL); cur_sense_data.sense_key=SENSE_NOT_READY; cur_sense_data.asc=ASC_MEDIUM_NOT_PRESENT; @@ -770,6 +776,8 @@ static void handle_scsi(struct command_block_wrapper* cbw) MIN(sizeof(struct mode_sense_data_6), length)); break; default: + /* Windows expects an empty command result before the csw */ + usb_drv_send(usb_endpoint, 0, 0); send_csw(UMS_STATUS_FAIL); cur_sense_data.sense_key=SENSE_ILLEGAL_REQUEST; cur_sense_data.asc=ASC_INVALID_FIELD_IN_CBD; @@ -819,6 +827,8 @@ static void handle_scsi(struct command_block_wrapper* cbw) } else { + /* Windows expects an empty command result before the csw */ + usb_drv_send(usb_endpoint, 0, 0); send_csw(UMS_STATUS_FAIL); cur_sense_data.sense_key=SENSE_NOT_READY; cur_sense_data.asc=ASC_MEDIUM_NOT_PRESENT; @@ -841,6 +851,8 @@ static void handle_scsi(struct command_block_wrapper* cbw) } else { + /* Windows expects an empty command result before the csw */ + usb_drv_send(usb_endpoint, 0, 0); send_csw(UMS_STATUS_FAIL); cur_sense_data.sense_key=SENSE_NOT_READY; cur_sense_data.asc=ASC_MEDIUM_NOT_PRESENT; @@ -852,6 +864,8 @@ static void handle_scsi(struct command_block_wrapper* cbw) case SCSI_READ_10: logf("scsi read10 %d",lun); if(! lun_present) { + /* Windows expects an empty command result before the csw */ + usb_drv_send(usb_endpoint, 0, 0); send_csw(UMS_STATUS_FAIL); cur_sense_data.sense_key=SENSE_NOT_READY; cur_sense_data.asc=ASC_MEDIUM_NOT_PRESENT; -- cgit v1.2.3