This is a theoretical bug, I haven't verified whether it exists in practice...
If flashmem is started at an address not aligned with an erase block boundary, it may fail to erase the next block _before_ programming.
The current algorithm is as follows: flashmem determines the current block to be programmed from the address and unlocks/erases it. Then, it reads up to BSIZE (4096) bytes from the input file and writes/programs them to the flash device. If the current block ended somewhere between start and start+BSIZE, the next block would be programmed before it's erased (and then maybe erased in the next step, forgetting the just programmed data)
Idea: in flashmem.c:find_block(), also determine the end address of the current block and limit the BSIZE for fread accordingly.
Logged In: YES
user_id=478715
Originator: YES
Idea implemented in #917