diff --git a/lib/main/STM32F4/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c b/lib/main/STM32F4/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c index 5d4d2521693..3c63a978f2c 100644 --- a/lib/main/STM32F4/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c +++ b/lib/main/STM32F4/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c @@ -343,6 +343,12 @@ static int8_t SCSI_ModeSense6 (USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t * len--; hmsc->bot_data[len] = MSC_Mode_Sense6_data[len]; } + + // set bit 7 of the device configuration byte to indicate write protection + if (((USBD_StorageTypeDef *)pdev->pMSC_UserData)->IsWriteProtected(lun) != 0) { + hmsc->bot_data[2] = hmsc->bot_data[2] | (1 << 7); + } + return 0; } @@ -365,6 +371,12 @@ static int8_t SCSI_ModeSense10 (USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t len--; hmsc->bot_data[len] = MSC_Mode_Sense10_data[len]; } + + // set bit 7 of the device configuration byte to indicate write protection + if (((USBD_StorageTypeDef *)pdev->pMSC_UserData)->IsWriteProtected(lun) != 0) { + hmsc->bot_data[3] = hmsc->bot_data[3] | (1 << 7); + } + return 0; } diff --git a/lib/main/STM32F7/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c b/lib/main/STM32F7/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c index ed3deef5959..b1d76cc25da 100644 --- a/lib/main/STM32F7/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c +++ b/lib/main/STM32F7/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c @@ -347,6 +347,12 @@ static int8_t SCSI_ModeSense6 (USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t * len--; hmsc->bot_data[len] = MSC_Mode_Sense6_data[len]; } + + // set bit 7 of the device configuration byte to indicate write protection + if (((USBD_StorageTypeDef *)pdev->pMSC_UserData)->IsWriteProtected(lun) != 0) { + hmsc->bot_data[2] = hmsc->bot_data[2] | (1 << 7); + } + return 0; } @@ -370,6 +376,12 @@ static int8_t SCSI_ModeSense10 (USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t len--; hmsc->bot_data[len] = MSC_Mode_Sense10_data[len]; } + + // set bit 7 of the device configuration byte to indicate write protection + if (((USBD_StorageTypeDef *)pdev->pMSC_UserData)->IsWriteProtected(lun) != 0) { + hmsc->bot_data[3] = hmsc->bot_data[3] | (1 << 7); + } + return 0; } diff --git a/lib/main/STM32H7/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c b/lib/main/STM32H7/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c index d15d9039a54..ffc615dac5a 100644 --- a/lib/main/STM32H7/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c +++ b/lib/main/STM32H7/Middlewares/ST/STM32_USB_Device_Library/Class/MSC/Src/usbd_msc_scsi.c @@ -346,6 +346,12 @@ static int8_t SCSI_ModeSense6(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t *p len--; hmsc->bot_data[len] = MSC_Mode_Sense6_data[len]; } + + // set bit 7 of the device configuration byte to indicate write protection + if (((USBD_StorageTypeDef *)pdev->pMSC_UserData)->IsWriteProtected(lun) != 0) { + hmsc->bot_data[2] = hmsc->bot_data[2] | (1 << 7); + } + return 0; } @@ -371,6 +377,11 @@ static int8_t SCSI_ModeSense10(USBD_HandleTypeDef *pdev, uint8_t lun, uint8_t * hmsc->bot_data[len] = MSC_Mode_Sense10_data[len]; } + // set bit 7 of the device configuration byte to indicate write protection + if (((USBD_StorageTypeDef *)pdev->pMSC_UserData)->IsWriteProtected(lun) != 0) { + hmsc->bot_data[3] = hmsc->bot_data[3] | (1 << 7); + } + return 0; }