Skip to content
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

Bug report - can't erase last sector of flash #194

Open
jpmeijers opened this issue Dec 3, 2019 · 0 comments · May be fixed by #195
Open

Bug report - can't erase last sector of flash #194

jpmeijers opened this issue Dec 3, 2019 · 0 comments · May be fixed by #195
Assignees
Labels
possible bug Possibly a bug. Needs verification before moving to *bug* status.

Comments

@jpmeijers
Copy link

if (_submittedAddress + size >= _chip.capacity) {

This should read:
if (_submittedAddress + size > _chip.capacity) {

Say we have a chip with capacity 12 bytes. We want to erase the last quarter of the flash. So we erase from address 9 and we erase 3 bytes. So we erase bytes 9, 10 and 11. Using the above formula one would get that 9 + 3 >= 12 will be true, and prevent us from erasing. The problem is one should add size-1 to the address to get the last address. And the last address may not be equal to the capacity of the chip. The last addressable byte is capacity-1. So in other words a valid addressing is where address + (size-1) <= (capacity-1). Or in other words address + size <= capacity. So the invalid case is therefore where address + size > capacity.

@jpmeijers jpmeijers added the possible bug Possibly a bug. Needs verification before moving to *bug* status. label Dec 3, 2019
jpmeijers added a commit to jpmeijers/SPIMemory that referenced this issue Dec 3, 2019
@jpmeijers jpmeijers linked a pull request Dec 3, 2019 that will close this issue
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
possible bug Possibly a bug. Needs verification before moving to *bug* status.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants