Enabling 4kb sector erase and smaller erasable filesizes on winbond chips #67
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This feature takes advantage of winbond's 4kb sector-erase feature to enable smaller erasable filesizes.
I noticed that I couldn't save more than 16 erasable files to my winbond w25q80, and did some investigating into this library's size allocation. I discovered that it assumes all chips use 256kb erase blocks, so I added a feature detection flag for winbond chips and auto-sizing function for erasable files smaller than 256kb. (Right now this auto-size feature uses powers of two but could potentially work in 4kb blocks instead.)
This is tested in hardware on the w25q80 and seems to work fine! So far as I can tell from reading datasheets all winbond serial flash uses 4kb erase sectors, but I am not super-familiar with their product lines so would appreciate a double-check.
The erase function looks quite different but is substantially the same, and should accommodate alternate erase sector sizes if other manufacturers use them.