target/riscv-013: clear sticky error when DMI operation fails

When a DMI operation does not succeed (either because of a timeout
or an error), the specification says that the error in the `op`
field is sticky and needs to cleared by writing `dmireset` in `dtmcs`.
This is already done for timeouts in increase_dmi_busy_delay
but not for errors.

Change-Id: I7c5f27a5cf145511a1a8b64a45a586521e1cbe41
Signed-off-by: Amaury Pouly <amaury.pouly@lowrisc.org>
Reviewed-on: https://review.openocd.org/c/openocd/+/7688
Tested-by: jenkins
Reviewed-by: Tim Newsome <tim@sifive.com>
Reviewed-by: Jan Matyas <jan.matyas@codasip.com>
This commit is contained in:
Amaury Pouly 2023-05-17 12:09:32 +01:00 committed by Tomas Vanek
parent 4defa3b1e3
commit 5924d9f30c
1 changed files with 2 additions and 0 deletions

View File

@ -598,6 +598,7 @@ static int dmi_op_timeout(struct target *target, uint32_t *data_in,
break;
} else {
LOG_ERROR("failed %s at 0x%x, status=%d", op_name, address, status);
dtmcontrol_scan(target, DTM_DTMCS_DMIRESET);
return ERROR_FAIL;
}
if (time(NULL) - start > timeout_sec)
@ -630,6 +631,7 @@ static int dmi_op_timeout(struct target *target, uint32_t *data_in,
LOG_ERROR("Failed %s (NOP) at 0x%x; status=%d", op_name, address,
status);
}
dtmcontrol_scan(target, DTM_DTMCS_DMIRESET);
return ERROR_FAIL;
}
if (time(NULL) - start > timeout_sec)