aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRichard Eoin Meadows2014-08-22 22:15:20 +0100
committerGareth McMullin2014-09-03 21:17:48 +1200
commitf4474557d03581a1df5cbab9deff48799b32ddfb (patch)
treeb754b2f79421257eb15f32e158eac5dc83b345ef /src
parent39a0b064afd6e7fdc89d2d5c3a7e1b6f4c94b320 (diff)
SAM D20 MBIST shouldn't fail silently
Diffstat (limited to 'src')
-rw-r--r--src/samd20.c14
1 files changed, 12 insertions, 2 deletions
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[] = "<?xml version=\"1.0\"?>"
#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 {