Merge pull request #297 from UweBonnes/write_size

target: Fix calculation of erase size.
This commit is contained in:
Gareth McMullin 2017-10-06 19:40:02 +13:00 committed by GitHub
commit 231d42d581
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;