Skip to main content
Visitor II
October 2, 2026
Question

found USB MSC library bug

  • October 2, 2026
  • 2 replies
  • 58 views

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
 

2 replies

Pavel A.
October 2, 2026
TDK
October 3, 2026

And was updated 6 months ago. No doubt you just need to update. Good spot, but it was already fixed it seems.

 

"If you feel a post has answered your question, please click ""Accept as Solution""."