From 0b1b9e2034c4f8a298d5b6fa537a4d3d819bdf30 Mon Sep 17 00:00:00 2001 From: Tim Newsome Date: Thu, 25 Jun 2020 15:34:48 -0700 Subject: [PATCH 1/2] Accept dmstatus.version==3 (0.14) (#489) Fixes #485. Change-Id: I60b3d68827ca726558bc28035c0b74c5cf0d9754 --- src/target/riscv/riscv-013.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c index bbe77e938..9522e5e5a 100644 --- a/src/target/riscv/riscv-013.c +++ b/src/target/riscv/riscv-013.c @@ -686,8 +686,9 @@ int dmstatus_read_timeout(struct target *target, uint32_t *dmstatus, DMI_DMSTATUS, 0, timeout_sec, false, true); if (result != ERROR_OK) return result; - if (get_field(*dmstatus, DMI_DMSTATUS_VERSION) != 2) { - LOG_ERROR("OpenOCD only supports Debug Module version 2 (0.13), not " + int dmstatus_version = get_field(*dmstatus, DMI_DMSTATUS_VERSION); + if (dmstatus_version != 2 && dmstatus_version != 3) { + LOG_ERROR("OpenOCD only supports Debug Module version 2 (0.13) and 3 (0.14), not " "%d (dmstatus=0x%x). This error might be caused by a JTAG " "signal issue. Try reducing the JTAG clock speed.", get_field(*dmstatus, DMI_DMSTATUS_VERSION), *dmstatus); @@ -1613,7 +1614,8 @@ static int examine(struct target *target) 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) { + int dmstatus_version = get_field(dmstatus, DMI_DMSTATUS_VERSION); + if (dmstatus_version != 2 && dmstatus_version != 3) { /* Error was already printed out in dmstatus_read(). */ return ERROR_FAIL; } From f0151889f0f5a51e2555980d74e7a86d0b9aa849 Mon Sep 17 00:00:00 2001 From: Tim Newsome Date: Thu, 25 Jun 2020 17:33:56 -0700 Subject: [PATCH 2/2] Don't halt the algorith-running hart because another is halted. (#490) This logic is a little tortured, but it still passes the semihosting tests that were the cause for the recent rewrite. Change-Id: Ic6760bb068621ab2a49feb0cf3998fc6957b5cfc --- src/target/riscv/riscv.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/target/riscv/riscv.c b/src/target/riscv/riscv.c index 65b60cd90..8e7d5c7d3 100644 --- a/src/target/riscv/riscv.c +++ b/src/target/riscv/riscv.c @@ -2080,7 +2080,7 @@ int riscv_openocd_poll(struct target *target) } else if (target->smp) { unsigned halts_discovered = 0; unsigned total_targets = 0; - bool newly_halted[128] = {0}; + bool newly_halted[RISCV_MAX_HARTS] = {0}; unsigned should_remain_halted = 0; unsigned should_resume = 0; unsigned i = 0; @@ -2093,8 +2093,6 @@ int riscv_openocd_poll(struct target *target) enum riscv_poll_hart out = riscv_poll_hart(t, r->current_hartid); switch (out) { case RPH_NO_CHANGE: - if (t->state == TARGET_HALTED) - should_remain_halted++; break; case RPH_DISCOVERED_RUNNING: t->state = TARGET_RUNNING;