aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMegan Wachs <megan@sifive.com>2017-03-21 13:18:26 -0700
committerGitHub <noreply@github.com>2017-03-21 13:18:26 -0700
commitc09ccbcc7c6272db2703422beb78236d23ace41b (patch)
tree29f0d35a15131bb1d8177c71313198e24f9068e2
parentbb39d3b17e7f312c88ac43e0a563c782b134df5d (diff)
parenta70e6286200f33f842e14bc2fed027c7b268826c (diff)
downloadriscv-openocd-c09ccbcc7c6272db2703422beb78236d23ace41b.zip
riscv-openocd-c09ccbcc7c6272db2703422beb78236d23ace41b.tar.gz
riscv-openocd-c09ccbcc7c6272db2703422beb78236d23ace41b.tar.bz2
Merge pull request #20 from sifive/delay_after_autoexec
riscv-v13: wait for idle in read_memory
-rw-r--r--src/target/riscv/riscv-013.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c
index 774e6d3..6aac4fd 100644
--- a/src/target/riscv/riscv-013.c
+++ b/src/target/riscv/riscv-013.c
@@ -1865,7 +1865,7 @@ static int read_memory(struct target *target, uint32_t address,
return ERROR_FAIL;
}
dmi_write(target, DMI_ABSTRACTCS, DMI_ABSTRACTCS_AUTOEXEC0 | DMI_ABSTRACTCS_CMDERR);
-
+ uint32_t abstractcs;
for (uint32_t i = 0; i < count; i++) {
uint32_t value = dmi_read(target, DMI_DATA0);
switch (size) {
@@ -1885,9 +1885,16 @@ static int read_memory(struct target *target, uint32_t address,
default:
return ERROR_FAIL;
}
- }
+ // The above dmi_read started an abstract command. If we just
+ // immediately read here, we'll probably get a busy error. Wait for idle first,
+ // or otherwise take ac_command_busy into account (this defeats the purpose
+ // of autoexec, this whole code needs optimization).
+ if (wait_for_idle(target, &abstractcs) != ERROR_OK) {
+ return ERROR_FAIL;
+ }
+ }
dmi_write(target, DMI_ABSTRACTCS, DMI_ABSTRACTCS_CMDERR);
- uint32_t abstractcs = dmi_read(target, DMI_ABSTRACTCS);
+ abstractcs = dmi_read(target, DMI_ABSTRACTCS);
if (get_field(abstractcs, DMI_ABSTRACTCS_CMDERR)) {
// TODO: retry with more delay?
return ERROR_FAIL;