target: Fix calculation of erase size.

This commit is contained in:
Uwe Bonnes 2017-10-05 22:07:23 +02:00
parent 5950d8f56c
commit 120a2d9378
1 changed files with 2 additions and 1 deletions

View File

@ -199,7 +199,8 @@ int target_flash_erase(target *t, target_addr addr, size_t len)
int ret = 0;
while (len) {
struct target_flash *f = flash_for_addr(t, addr);
size_t tmplen = MIN(len, f->length - (addr % f->length));
size_t tmptarget = MIN(addr + len, f->start + f->length);
size_t tmplen = tmptarget - addr;
ret |= f->erase(f, addr, tmplen);
addr += tmplen;
len -= tmplen;