-
Notifications
You must be signed in to change notification settings - Fork 258
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
Off-by-one error in spiFlash prevents writing to the last byte of the flash #172
Comments
For instance for the W25Q16 device we have:
So If you try to write in 0x200000, it's the first Byte of the block 32 (not allowed for W25Q16 but correct for W25Q32). This is why a -1 is used to convert capacity for upper address to check if address is not strictly greater than last Byte (it's a > not a =>. |
If I try and write a 0x10000 byte file (1 sector) to location 0x1F0000, then I'm writing all the way up to and including the last byte of the flash, but I am not writing past the last byte.
base_addr = 0x1F0000, len = 0x10000, nr_sector = 32 (0x1F0000 + 0x10000) > ((32 * 0x10000) - 1) Therefore I am prevented from writing the last sector. |
I'm dumb it's true! I've focalized my observation to the right side of the comparison but not to the left one. |
Thanks for accepting the issue - really appreciate this work. |
Done! I have to find a way to create unitest to check subtilities like this one! |
It's okay for you? |
Working well, thanks. |
openFPGALoader/src/spiFlash.cpp
Line 261 in 0283f18
There seems to be an off-by-one error on this line, which prevents writing to the very last byte of the flash.
The text was updated successfully, but these errors were encountered: