found USB MSC library bug
in “usbd_msc_scsi.c” at function “SCSI_ModeSense6”/* Check If media is write-protected */
if (((USBD_StorageTypeDef *)pdev->pUserData[pdev->classId])->IsWriteProtected(lun) != 0)
{
MSC_Mode_Sense6_data[2] |= (0x1U << 7); /* Set the WP (write protection) bit */
}
else
{
MSC_Mode_Sense10_data[2] &= ~(0x1U << 7); /* Clear the WP (write protection) bit */
}
is writing to the wrong place !!!
Change it to:MSC_Mode_Sense6_data[2] &= ~(0x1U << 7); /* Clear the WP (write protection) bit */
Note:
The wrong write mainly cause the write protection to stay on if its once set and never be able to unset without reseting the scsi device.
Took me days to track down this bug !!
best regards,
Labmaster
