From 07fcaa226bbf637c9e9415d43bdd311362a8bbdf Mon Sep 17 00:00:00 2001 From: Palmer Dabbelt Date: Wed, 30 May 2018 18:19:29 -0700 Subject: [PATCH] Keeep the RTOS hartid and the current hart in sync --- src/target/riscv/riscv.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/target/riscv/riscv.c b/src/target/riscv/riscv.c index f60e2433e..a6ae43d6b 100644 --- a/src/target/riscv/riscv.c +++ b/src/target/riscv/riscv.c @@ -759,9 +759,12 @@ static int old_or_new_riscv_resume( static int riscv_select_current_hart(struct target *target) { RISCV_INFO(r); - if (r->rtos_hartid != -1 && riscv_rtos_enabled(target)) + if (riscv_rtos_enabled(target)) { + if (r->rtos_hartid == -1) + r->rtos_hartid = target->rtos->current_threadid - 1; + return riscv_set_current_hartid(target, r->rtos_hartid); - else + } else return riscv_set_current_hartid(target, target->coreid); }