aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Newsome <tim@sifive.com>2019-01-22 12:48:47 -0800
committerTim Newsome <tim@sifive.com>2019-01-22 12:48:47 -0800
commit906635c4bda717884f87c0bd241f5c86a8238b41 (patch)
tree2dffda04e24d25a786b8ff4554618f836e390ab9
parent1599853032c0fd90a3d4cbd6eac1e6869ef750ec (diff)
downloadriscv-openocd-906635c4bda717884f87c0bd241f5c86a8238b41.zip
riscv-openocd-906635c4bda717884f87c0bd241f5c86a8238b41.tar.gz
riscv-openocd-906635c4bda717884f87c0bd241f5c86a8238b41.tar.bz2
Move version check until after dmactive=1.
This should allow OpenOCD to work with targets where version is not readable when dmactive=0, which is allowed by the spec.
-rw-r--r--src/target/riscv/riscv-013.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c
index 1ef7307..3611d48 100644
--- a/src/target/riscv/riscv-013.c
+++ b/src/target/riscv/riscv-013.c
@@ -1401,16 +1401,6 @@ static int examine(struct target *target)
info->abits = get_field(dtmcontrol, DTM_DTMCS_ABITS);
info->dtmcs_idle = get_field(dtmcontrol, DTM_DTMCS_IDLE);
- uint32_t dmstatus;
- if (dmstatus_read(target, &dmstatus, false) != ERROR_OK)
- return ERROR_FAIL;
- LOG_DEBUG("dmstatus: 0x%08x", dmstatus);
- if (get_field(dmstatus, DMI_DMSTATUS_VERSION) != 2) {
- LOG_ERROR("OpenOCD only supports Debug Module version 2, not %d "
- "(dmstatus=0x%x)", get_field(dmstatus, DMI_DMSTATUS_VERSION), dmstatus);
- return ERROR_FAIL;
- }
-
/* Reset the Debug Module. */
dm013_info_t *dm = get_dm(target);
if (!dm->was_reset) {
@@ -1431,6 +1421,16 @@ static int examine(struct target *target)
return ERROR_FAIL;
}
+ uint32_t dmstatus;
+ if (dmstatus_read(target, &dmstatus, false) != ERROR_OK)
+ return ERROR_FAIL;
+ LOG_DEBUG("dmstatus: 0x%08x", dmstatus);
+ if (get_field(dmstatus, DMI_DMSTATUS_VERSION) != 2) {
+ LOG_ERROR("OpenOCD only supports Debug Module version 2, not %d "
+ "(dmstatus=0x%x)", get_field(dmstatus, DMI_DMSTATUS_VERSION), dmstatus);
+ return ERROR_FAIL;
+ }
+
uint32_t hartsel =
(get_field(dmcontrol, DMI_DMCONTROL_HARTSELHI) <<
DMI_DMCONTROL_HARTSELLO_LENGTH) |