Merge pull request #21 from sifive/read_memory_retry

Read memory retry
This commit is contained in:
Palmer Dabbelt 2017-03-22 18:00:44 -07:00 committed by GitHub
commit 84fa7aa916
1 changed files with 72 additions and 63 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();
@ -1891,11 +1892,19 @@ static int read_memory(struct target *target, uint32_t address,
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;
}