Am Samstag, den 16.01.2010, 21:16 -0800 schrieb Sean Nelson:
+int write_28f00x(struct flashchip *flash, uint8_t *buf) +{
- int i, j, blocknum;
- chipaddr bios = flash->virtual_memory;
- int blockoffset = 0;
- uint8_t *tmpbuf = malloc(flash->page_size);
- struct eraseblock * blocks = flash->block_erasers[0].eraseblocks;
- if (!tmpbuf) {
printf("Could not allocate memory!\n");
exit(1);
- }
- printf("Programming block: \n");
- blocknum = 0;
- for (i = 0; blocks[i].size != 0; i++) {
for(j = 0; j< blocks[i].count; j++) {
printf("\b\b\b\b\b\b\b\b\b\b\b\b\b\b"
"\b\b\b\b\b\b\b\b\b\b\b\b\b");
printf("%04d at address: 0x%08x", blocknum,
blockoffset);
/* Auto Skip Blocks, which already contain the
* desired data Faster, because we only write, what
* has changed More secure, because blocks, which
* are excluded (with the exclude or layout feature)
* or not erased and rewritten; their data is
* retained also in sudden power off situations
*/
chip_readn(tmpbuf, bios + blockoffset, blocks[i].size);
if (!memcmp((void *)(buf + blockoffset), tmpbuf,
blocks[i].size)) {
printf("SKIPPED\n");
continue;
}
/* erase block by block and write block by block;
this is the most secure way */
if (erase_82802ab_block(flash, blockoffset,
blocks[i].size)) {
fprintf(stderr, "ERASE FAILED!\n");
return -1;
}
write_page_82802ab(bios, buf + blockoffset,
bios + blockoffset, blocks[i].size);
blockoffset += blocks[i].size;
blocknum++;
}
- }
- printf("\n");
- free(tmpbuf);
- return 0;
+}
It's great that you used block_erasers for the chip definition, but I don't understand the reason for write_28f00x. It looks exactly the same as write_82802 except for using erase blocks segments. i28f00x.c is completely unnecessary and extraneous in my opinion.
write_82802ab only works if all erase blocks are of the same size, namely the page_size specified in the chip. The 28f00x chips have erase blocks of different sizes, the 82802A/B don't.
Regards, Michael Karcher