2 ms·
Hey! Author here :) This is a very good question, and you're right that I should've expanded on my rationale as this is not standard practice at all. There are
by __cuervo 6y ago
Hey! Author here :) This is a very good question, and you're right that I should've expanded on my rationale as this is not standard practice at all.
There are some particularities of the data we're writing that make this case more common than usual, and in any case the time spent in the bit masking routine is negligible compared to the flash erase time, so it works out well (keep in mind that the `all()` consumer will short-circuit as soon as two bits differ, so in the general case it's cheap, and in the erased case it isn't too different from verifying every byte is 0xFF). We're also really, really strongly optimizing for flash life above speed, as this code is meant to run very rarely for FOTA upgrades.
For a general purpose storage flash driver, I'd definitely erase every sector.