From ef3875a320aeba3e7d1b678ce18633d07151ae0c Mon Sep 17 00:00:00 2001 From: Tim Newsome Date: Wed, 15 Feb 2017 20:41:39 -0800 Subject: [PATCH] Check for errors after read/write. The code doesn't do anything intelligent if errors are found. But MemTestBlock now also passes. I'm not quite sure why. Change-Id: I8512f0a96db9e34d3db6a4a9bcef6e56f191d4c1 --- src/target/riscv/riscv-013.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c index 7861e662a..269568230 100644 --- a/src/target/riscv/riscv-013.c +++ b/src/target/riscv/riscv-013.c @@ -2353,8 +2353,12 @@ static int read_memory(struct target *target, uint32_t address, return ERROR_FAIL; } } - dmi_write(target, DMI_ABSTRACTCS, 0); - // TODO: Check for errors. + dmi_write(target, DMI_ABSTRACTCS, DMI_ABSTRACTCS_CMDERR); + uint32_t abstractcs = dmi_read(target, DMI_ABSTRACTCS); + if (get_field(abstractcs, DMI_ABSTRACTCS_CMDERR)) { + // TODO: retry with more delay? + return ERROR_FAIL; + } return ERROR_OK; } @@ -2413,8 +2417,12 @@ static int write_memory(struct target *target, uint32_t address, dmi_write(target, DMI_ABSTRACTCS, DMI_ABSTRACTCS_AUTOEXEC0); } } - dmi_write(target, DMI_ABSTRACTCS, 0); - // TODO: Check for errors. + dmi_write(target, DMI_ABSTRACTCS, DMI_ABSTRACTCS_CMDERR); + uint32_t abstractcs = dmi_read(target, DMI_ABSTRACTCS); + if (get_field(abstractcs, DMI_ABSTRACTCS_CMDERR)) { + // TODO: retry with more delay? + return ERROR_FAIL; + } return ERROR_OK; }