From 3b60c3aa421e2cf6d0ddf0f1296346424f4d7725 Mon Sep 17 00:00:00 2001 From: Tim Newsome Date: Fri, 27 May 2016 09:49:42 -0700 Subject: [PATCH] Fix bug when waiting for debugint to clear. --- src/target/riscv/riscv.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/target/riscv/riscv.c b/src/target/riscv/riscv.c index 23f2b4673..90280b4df 100644 --- a/src/target/riscv/riscv.c +++ b/src/target/riscv/riscv.c @@ -321,6 +321,10 @@ static int wait_for_state(struct target *target, enum target_state state) static int wait_for_debugint_clear(struct target *target) { time_t start = time(NULL); + // Throw away the results of the first read, since they'll contain the + // result of the read that happened just before debugint was set. (Assuming + // the last scan before calling this function was one that sets debugint.) + read_bits(target); while (1) { bits_t bits = read_bits(target); if (!bits.interrupt) {