fix verify in linux tool

This commit is contained in:
Olaf Rempel 2010-10-17 18:22:38 +02:00
parent 6244c44e65
commit a857b3906e
2 changed files with 9 additions and 10 deletions

View File

@ -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;

View File

@ -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)