-
Notifications
You must be signed in to change notification settings - Fork 2.1k
drivers/mtd_mci: fix sub-page writes & sector erase #17831
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
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If size
is for example 513 (is this allowed?), then pages
is 1, then we write one page (512), but would return 513.
Maybe it must be:
return min(size, pages * SD_HC_BLOCK_SIZE)
When doing sub-page writes, we would return a value that is larger than the amount of bytes written, causing an underflow in the MTD layer.
e6fb23d
to
2f7cf35
Compare
Good catch, thank you! |
I don´t have the hardware to verify but I went through some test cases in my head and I think it works:
|
Since I don´t have the hardware, I´ll ACK if you could post the results of above test cases (or similar if not appropriate). |
Unfortunately I don't have access to the hardware right now, I only noticed this when implementing the SD host controller for sam0 and using this as a template. I guess back then I only tested with FAT which does not require such 'advanced' features. |
Testing using
|
welp, looks like 4694c6c does not work as I had hoped. |
I reverted the top-most commit and now have this commit history:
The test output now is:
|
Arg looks like sector erase has always been broken then. |
Contribution description
Always return the original size in
_write_page
.Otherwise when doing sub-page writes, we would return a value that is larger than the amount of bytes written, causing an underflow in the MTD layer.
Testing procedure
Use the
write
command intests/mtd_raw
on a lpc23xx device with an SD card.Issues/PRs references