Added better feedback for samd erase failures

This commit is contained in:
Richard Meadows 2015-01-18 13:22:41 +00:00
parent a3ab9b24d1
commit 1c1312b467
1 changed files with 21 additions and 1 deletions

View File

@ -501,14 +501,34 @@ static bool samd20_cmd_erase_all(target *t)
{
ADIv5_AP_t *ap = adiv5_target_ap(t);
/* Clear the DSU status bits */
adiv5_ap_mem_write(ap, SAMD20_DSU_CTRLSTAT,
(SAMD20_STATUSA_DONE | SAMD20_STATUSA_PERR | SAMD20_STATUSA_FAIL));
/* Erase all */
adiv5_ap_mem_write(ap, SAMD20_DSU_CTRLSTAT, SAMD20_CTRL_CHIP_ERASE);
/* Poll for DSU Ready */
while ((adiv5_ap_mem_read(ap, SAMD20_DSU_CTRLSTAT) & SAMD20_STATUSA_DONE) == 0)
uint32_t status;
while (((status = adiv5_ap_mem_read(ap, SAMD20_DSU_CTRLSTAT)) &
(SAMD20_STATUSA_DONE | SAMD20_STATUSA_PERR | SAMD20_STATUSA_FAIL)) == 0)
if(target_check_error(t))
return false;
/* Test the protection error bit in Status A */
if (status & SAMD20_STATUSA_PERR) {
gdb_outf("Erase failed due to a protection error.\n");
return true;
}
/* Test the fail bit in Status A */
if (status & SAMD20_STATUSA_FAIL) {
gdb_outf("Erase failed.\n");
return true;
}
gdb_outf("Erase successful!\n");
return true;
}