-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
USB MSC: Fix SCIS mode sense write protection bit #9572
USB MSC: Fix SCIS mode sense write protection bit #9572
Conversation
Is this only applied to Flash or generically to MSC? btw. regardless, on F4, MSC flash devices are mounted (write protected, after write sense fails) without this PR. |
@stronnag it only sets the write protect flag if the |
Thanks for the clarification. This also needs to be applied to F4 / F7 in that case. |
@mluessi , can you please rebase this to |
@stronnag sounds good, I will add F4 and F7 and change the target branch |
26d0981
to
465304f
Compare
@stronnag done :) |
tested by the author on H7 and by me on F4. |
The USB MSC / SCSI layer currently doesn't set the write protect bit in the SCSI ModeSense response. Due to this, the Emulated FAT file system used for the internal flash doesn't get mounted read-only. When mounting the drive on Linux, the host attempts to write to the drive (I assume for the access time) , which fails and then the mounting doesn't succeed.
This fix sets the relevant bit in the SCSI ModeSense responses. The host doesn't attempt to write to the drive and the mounting works as expected.
This is only for H7 targets. The fix also should be added to F7 etc.
Fixes #9160
Before:
[1191094.145018] scsi 3:0:0:0: Direct-Access INAV FC Onboard Flash PQ: 0 ANSI: 2
[1191094.145670] sd 3:0:0:0: [sdc] 527470 512-byte logical blocks: (270 MB/258 MiB)
[1191094.145815] sd 3:0:0:0: [sdc] Write Protect is off
[1191094.145817] sd 3:0:0:0: [sdc] Mode Sense: 00 00 00 00
With this fix:
[19418.047443] scsi 4:0:0:0: Direct-Access INAV FC Onboard Flash PQ: 0 ANSI: 2
[19418.048021] sd 4:0:0:0: [sdd] 527470 512-byte logical blocks: (270 MB/258 MiB)
[19418.048224] sd 4:0:0:0: [sdd] Write Protect is on
[19418.048229] sd 4:0:0:0: [sdd] Mode Sense: 00 00 80 00