lmi: Added progress dots for mass erase to stop GDB timing out

This commit is contained in:
dragonmux 2022-07-12 21:04:21 -04:00 committed by Piotr Esden-Tempski
parent d64992ade8
commit 6d7c6c5daf
1 changed files with 11 additions and 10 deletions

View File

@ -113,31 +113,32 @@ bool lmi_probe(target *t)
return false; return false;
} }
static int lmi_flash_erase(struct target_flash *f, target_addr addr, size_t len) static int lmi_flash_erase(struct target_flash *f, target_addr addr, const size_t len)
{ {
target *t = f->t; target *t = f->t;
target_check_error(t); target_check_error(t);
while (len) { const bool full_erase = addr == f->start && len == f->length;
platform_timeout timeout;
platform_timeout_set(&timeout, 500);
for (size_t erased = 0; erased < len; erased += BLOCK_SIZE) {
target_mem_write32(t, LMI_FLASH_FMA, addr); target_mem_write32(t, LMI_FLASH_FMA, addr);
target_mem_write32(t, LMI_FLASH_FMC, LMI_FLASH_FMC_WRKEY | LMI_FLASH_FMC_ERASE); target_mem_write32(t, LMI_FLASH_FMC, LMI_FLASH_FMC_WRKEY | LMI_FLASH_FMC_ERASE);
while (target_mem_read32(t, LMI_FLASH_FMC) & LMI_FLASH_FMC_ERASE) while (target_mem_read32(t, LMI_FLASH_FMC) & LMI_FLASH_FMC_ERASE) {
continue; if (full_erase)
target_print_progress(&timeout);
}
if (target_check_error(t)) if (target_check_error(t))
return -1; return -1;
if (len > BLOCK_SIZE)
len -= BLOCK_SIZE;
else
len = 0;
addr += BLOCK_SIZE; addr += BLOCK_SIZE;
} }
return 0; return 0;
} }
static int lmi_flash_write(struct target_flash *f, static int lmi_flash_write(struct target_flash *f, target_addr dest, const void *src, size_t len)
target_addr dest, const void *src, size_t len)
{ {
target *t = f->t; target *t = f->t;
target_check_error(t); target_check_error(t);