From f4474557d03581a1df5cbab9deff48799b32ddfb Mon Sep 17 00:00:00 2001 From: Richard Eoin Meadows Date: Fri, 22 Aug 2014 22:15:20 +0100 Subject: SAM D20 MBIST shouldn't fail silently --- src/samd20.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/samd20.c b/src/samd20.c index bad52b9..2a9fc67 100644 --- a/src/samd20.c +++ b/src/samd20.c @@ -124,7 +124,9 @@ static const char samd20_xml_memory_map[] = "" #define SAMD20_CTRL_CHIP_ERASE (1 << 4) #define SAMD20_CTRL_MBIST (1 << 3) #define SAMD20_CTRL_CRC (1 << 2) +#define SAMD20_STATUSA_PERR (1 << 12) #define SAMD20_STATUSA_FAIL (1 << 11) +#define SAMD20_STATUSA_BERR (1 << 10) #define SAMD20_STATUSA_CRSTEXT (1 << 9) #define SAMD20_STATUSA_DONE (1 << 8) @@ -605,12 +607,20 @@ static bool samd20_cmd_mbist(target *t) adiv5_ap_mem_write(ap, SAMD20_DSU_CTRLSTAT, SAMD20_CTRL_MBIST); /* 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("MBIST not run due to protection error.\n") + return true; + } + /* Test the fail bit in Status A */ - if (adiv5_ap_mem_read(ap, SAMD20_DSU_CTRLSTAT) & SAMD20_STATUSA_FAIL) { + if (status & SAMD20_STATUSA_FAIL) { gdb_outf("MBIST Fail @ 0x%08x\n", adiv5_ap_mem_read(ap, SAMD20_DSU_ADDRESS)); } else { -- cgit v1.2.3