Skip to content

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

@jpmeijers

Description

@jpmeijers

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.

Metadata

Metadata

Assignees

Labels

possible bugPossibly a bug. Needs verification before moving to *bug* status.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions