Hi,
flashrom hasn't seen any major design changes in the last few months and most chips still perform whole-chip erase instead of sector-based erase.
I'd like to introduce a function which takes a range and rounds the start and the end of the range to the nearest block boundary. void roundup(struct flashchip *flash, int *startpos, int *endpos);
Take an example 256 kByte flash chip with the following sector layout: 0x00000-0x0ffff 64kB block 0x10000-0x1ffff 64kB block 0x20000-0x2ffff 64kB block 0x30000-0x37fff 32kB block 0x38000-0x3bfff 16kB block 0x3c000-0x3dfff 8kB block 0x3e000-0x3efff 4kB block 0x3f000-0x3ffff 4kB block
startpos=0x38123; endpos=0x3e005; roundup(flash, &startpos, &endpos); //results follow: //startpos=0x38000; //endpos=0x3efff;
That way, it is easily possible to check whether a given range can be handled by sector-based erase and write. You can use that result to tell the user that a range outside the intended range will get flashed. It is also possible to refuse flashing in that case.
Since the function will be generic and take a struct flashchip, there's no need to store a pointer to it with each chip and you can call the generic one from anywhere.
What do you think?
Regards, Carl-Daniel