diff options
author | Tim Newsome <tim@sifive.com> | 2017-09-21 14:53:12 -0700 |
---|---|---|
committer | Tim Newsome <tim@sifive.com> | 2017-09-21 14:53:12 -0700 |
commit | f0195868d3872d5acb4fbb834a4bbbcbd2d8281a (patch) | |
tree | 824518cf61756f5c99c1b21c84c771975931104d | |
parent | fe36097ff850f11e74af688bb5a853ede565f23b (diff) | |
download | riscv-openocd-f0195868d3872d5acb4fbb834a4bbbcbd2d8281a.zip riscv-openocd-f0195868d3872d5acb4fbb834a4bbbcbd2d8281a.tar.gz riscv-openocd-f0195868d3872d5acb4fbb834a4bbbcbd2d8281a.tar.bz2 |
Fall back on ndmreset if hartreset is unsupported.
-rw-r--r-- | src/target/riscv/riscv-013.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c index 1dd801d..9f2b9d5 100644 --- a/src/target/riscv/riscv-013.c +++ b/src/target/riscv/riscv-013.c @@ -1220,6 +1220,16 @@ static int assert_reset(struct target *target) target->reset_halt ? 1 : 0); control = set_field(control, DMI_DMCONTROL_HARTRESET, 1); dmi_write(target, DMI_DMCONTROL, control); + + // Read back to check if hartreset is supported. + uint32_t rb = dmi_read(target, DMI_DMCONTROL); + if (!get_field(rb, DMI_DMCONTROL_HARTRESET)) { + // Use ndmreset instead. That will reset the entire device, but + // that's probably what OpenOCD wants anyway. + control = set_field(control, DMI_DMCONTROL_HARTRESET, 0); + control = set_field(control, DMI_DMCONTROL_NDMRESET, 1); + dmi_write(target, DMI_DMCONTROL, control); + } } target->state = TARGET_RESET; |