diff --git a/linux/twb.c b/linux/twb.c index 2b68df9..f149fd2 100644 --- a/linux/twb.c +++ b/linux/twb.c @@ -267,14 +267,13 @@ int twb_write(struct twiboot *twb, struct databuf *dbuf, int memtype) int twb_verify(struct twiboot *twb, struct databuf *dbuf, int memtype) { int pos = 0; - int size = (memtype == MEMTYPE_FLASH) ? twb->flashsize : twb->eepromsize; uint8_t comp[READ_BLOCK_SIZE]; - while (pos < size) { + while (pos < dbuf->length) { if (twb->progress_cb) - twb->progress_cb(twb->progress_msg, pos, size); + twb->progress_cb(twb->progress_msg, pos, dbuf->length); - int len = MIN(READ_BLOCK_SIZE, size - pos); + int len = MIN(READ_BLOCK_SIZE, dbuf->length - pos); if (twb_read_memory(twb, comp, len, memtype, pos)) { if (twb->progress_cb) twb->progress_cb(twb->progress_msg, -1, -1); @@ -294,7 +293,7 @@ int twb_verify(struct twiboot *twb, struct databuf *dbuf, int memtype) } if (twb->progress_cb) - twb->progress_cb(twb->progress_msg, pos, size); + twb->progress_cb(twb->progress_msg, pos, dbuf->length); dbuf->length = pos; return 0; diff --git a/linux/twiboot.c b/linux/twiboot.c index 0a22b1e..75adc34 100644 --- a/linux/twiboot.c +++ b/linux/twiboot.c @@ -99,7 +99,7 @@ static void progress_cb(const char *msg, int pos, int size) for (i = 0; i < sizeof(stars); i++) stars[i] = ((pos * 100 / size) >= (i * 100 / sizeof(stars))) ? '*' : ' '; - printf("%-14s: [%s] (%d)\r", msg, stars, pos); + printf("%-15s: [%s] (%d)\r", msg, stars, pos); } if (pos == size) @@ -218,10 +218,10 @@ int main(int argc, char *argv[]) } if (!abort) { - printf("device : %-16s (address: 0x%02x)\n", twb.device, twb.address); - printf("version : %-16s (sig: 0x%02x 0x%02x 0x%02x => %s)\n", twb.version, twb.signature[0], twb.signature[1], twb.signature[2], check_signature(twb.signature)); - printf("flash size : 0x%04x (0x%02x bytes/page)\n", twb.flashsize, twb.pagesize); - printf("eeprom size : 0x%04x\n", twb.eepromsize); + printf("device : %-16s (address: 0x%02x)\n", twb.device, twb.address); + printf("version : %-16s (sig: 0x%02x 0x%02x 0x%02x => %s)\n", twb.version, twb.signature[0], twb.signature[1], twb.signature[2], check_signature(twb.signature)); + printf("flash size : 0x%04x (0x%02x bytes/page)\n", twb.flashsize, twb.pagesize); + printf("eeprom size : 0x%04x\n", twb.eepromsize); if (progress) { setbuf(stdout, NULL);