riscv: Retry failed memory reads

This commit is contained in:
Megan Wachs 2017-03-22 17:51:46 -07:00
parent 98420e377a
commit c61b3efe9a
1 changed files with 72 additions and 62 deletions

View File

@ -1830,6 +1830,7 @@ static int read_memory(struct target *target, uint32_t address,
{
select_dmi(target);
while (1) {
abstract_write_register(target, S0, xlen(target), address);
program_t *program = program_new();
@ -1888,13 +1889,22 @@ static int read_memory(struct target *target, uint32_t address,
return ERROR_FAIL;
}
}
dmi_write(target, DMI_ABSTRACTAUTO, 0);
dmi_write(target, DMI_ABSTRACTCS, DMI_ABSTRACTCS_CMDERR);
abstractcs = dmi_read(target, DMI_ABSTRACTCS);
if (get_field(abstractcs, DMI_ABSTRACTCS_CMDERR)) {
// TODO: retry with more delay?
unsigned cmderr = get_field(abstractcs, DMI_ABSTRACTCS_CMDERR);
if (cmderr == CMDERR_BUSY) {
dmi_write(target, DMI_ABSTRACTCS, 0);
increase_ac_busy_delay(target);
} else if (cmderr) {
LOG_ERROR("cmderr=%d", get_field(abstractcs, DMI_ABSTRACTCS_CMDERR));
return ERROR_FAIL;
} else {
return ERROR_OK;
}
}
// Should not get here.
assert(0);
return ERROR_OK;
}