-
Notifications
You must be signed in to change notification settings - Fork 137
Description
Line 57 in 1f1e4de
| 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.