Fix USB disconnect issue when no SD card is installed
authorMichael McMaster <michael@codesrc.com>
Mon, 9 Aug 2021 11:15:40 +0000 (21:15 +1000)
committerMichael McMaster <michael@codesrc.com>
Mon, 9 Aug 2021 11:15:40 +0000 (21:15 +1000)
CHANGELOG
src/firmware/usb_device/usbd_msc_scsi.c

index c0359db8fddf97d75f01037ec0ac64507349206f..2a408335aabe5e8e8a9179ef484883deb6874a52 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,6 @@
+2021xxxx        6.4.x
+    - Fix USB disconnect issue when no SD card is installed.
+
 20210628        6.4.11
     - Remove the "Blind Writes" option from scsi2sd-util. The firmware no longer
     requires this option for improved write performance
index 9cedc7be667feabeb5b32cbdda08fe083b5382d6..9ebccb8c553839ba233967bbe7b33f1c37982715 100755 (executable)
@@ -166,6 +166,13 @@ int8_t SCSI_ProcessCmd(USBD_HandleTypeDef  *pdev,
                    lun,
                    ILLEGAL_REQUEST, 
                    INVALID_CDB);    
+
+    {
+        USBD_CompositeClassData *classData = (USBD_CompositeClassData*) pdev->pClassData;
+        USBD_MSC_BOT_HandleTypeDef *hmsc = &(classData->msc);
+        hmsc->bot_state = USBD_BOT_NO_DATA;
+    }
+
     return -1;
   }
 }
@@ -264,6 +271,7 @@ static int8_t SCSI_ReadCapacity10(USBD_HandleTypeDef  *pdev, uint8_t lun, uint8_
                    lun,
                    NOT_READY, 
                    MEDIUM_NOT_PRESENT);
+    hmsc->bot_state = USBD_BOT_NO_DATA;
     return -1;
   } 
   else
@@ -718,9 +726,6 @@ static int8_t SCSI_ProcessRead (USBD_HandleTypeDef  *pdev, uint8_t lun)
 
   len = MIN(len, S2S_MSC_MEDIA_PACKET);
 
-  // TODO there is a dcache issue here.
-  // work out how, and when, to flush cashes between sdio dma and usb dma
-  memset (hmsc->bot_data, 0xAA, len);
   if( ((USBD_StorageTypeDef *)pdev->pUserData)->Read(lun ,
                               hmsc->bot_data, 
                               hmsc->scsi_blk_addr,