void verify_flash(ptentry *p, void *addr, unsigned len, int extra) { int offset = 0; void *buf = alloc(FLASH_PAGE_SIZE + extra); int verify_extra = extra; if(verify_extra > 4) verify_extra = 16; while(len > 0) { /* coverity[unchecked_value] */ flash_read_ext(p, extra, offset, buf, FLASH_PAGE_SIZE, 0); if(memcmp(addr, buf, FLASH_PAGE_SIZE + verify_extra)) { dprintf("verify failed at %x\n", offset); jtag_fail("verify failed"); return; } offset += FLASH_PAGE_SIZE; addr += FLASH_PAGE_SIZE; len -= FLASH_PAGE_SIZE; if(extra) { addr += extra; len -= extra; } } dprintf("verify done %d extra bytes\n", verify_extra); jtag_okay("verify done"); }
/* XXX */ void verify_flash(struct ptentry *p, void *addr, unsigned len, int extra) { uint32_t offset = 0; void *buf = malloc(FLASH_PAGE_SIZE + extra); int verify_extra = extra; if (verify_extra > 4) verify_extra = 16; while (len > 0) { flash_read_ext(p, extra, offset, buf, FLASH_PAGE_SIZE); if (memcmp(addr, buf, FLASH_PAGE_SIZE + verify_extra)) { dprintf(CRITICAL, "verify failed at 0x%08x\n", offset); jtag_fail("verify failed"); return; } offset += FLASH_PAGE_SIZE; addr += FLASH_PAGE_SIZE; len -= FLASH_PAGE_SIZE; if (extra) { addr += extra; len -= extra; } } dprintf(INFO, "verify done %d extra bytes\n", verify_extra); jtag_okay("verify done"); }
void handle_dump(const char *name, unsigned offset) { ptentry *p; if(tmpbuf == 0) { tmpbuf = alloc(4096); } dprintf("dump '%s' partition\n", name); p = flash_find_ptn(name); if(p == 0) { jtag_fail("partition not found"); return; } if(flash_init()) { jtag_fail("flash_init() failed"); return; } #if 0 /* XXX reimpl */ if(flash_read_page(p->start * 64, tmpbuf, tmpbuf + 2048)) { jtag_fail("flash_read() failed"); return; } #endif dprintf("page %d data:\n", p->start * 64); hexdump(tmpbuf, 256); dprintf("page %d extra:\n", p->start * 64); hexdump(tmpbuf, 16); jtag_okay("done"); }