From 9eb07f258e7ae8c4a38b349481d27b0207c35100 Mon Sep 17 00:00:00 2001 From: Tim Newsome Date: Fri, 21 Oct 2022 09:16:54 -0700 Subject: [PATCH] target/riscv: Correctly set target->state in deassert_reset (#750) * target/riscv: Correctly set target->state in deassert_reset This bug didn't lead to problems, but it would with some upcoming changes. Change-Id: I552acbae9977150c4c9e573f8852033bc80fcebb Signed-off-by: Tim Newsome * Keep debug_reason in sync with state Co-authored-by: Jan Matyas <50193733+JanMatCodasip@users.noreply.github.com> Signed-off-by: Tim Newsome Signed-off-by: Tim Newsome Co-authored-by: Jan Matyas <50193733+JanMatCodasip@users.noreply.github.com> --- src/target/riscv/riscv-013.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/target/riscv/riscv-013.c b/src/target/riscv/riscv-013.c index bc5b262ca..bcd694a1b 100644 --- a/src/target/riscv/riscv-013.c +++ b/src/target/riscv/riscv-013.c @@ -2452,8 +2452,13 @@ static int deassert_reset(struct target *target) return ERROR_FAIL; } } - target->state = TARGET_HALTED; - target->debug_reason = DBG_REASON_DBGRQ; + if (target->reset_halt) { + target->state = TARGET_HALTED; + target->debug_reason = DBG_REASON_DBGRQ; + } else { + target->state = TARGET_RUNNING; + target->debug_reason = DBG_REASON_NOTHALTED; + } if (get_field(dmstatus, DM_DMSTATUS_ALLHAVERESET)) { /* Ack reset. */