From c792f92493bf7ee0d562e94f662037c8d432aa61 Mon Sep 17 00:00:00 2001 From: Nav Date: Sat, 2 Dec 2023 13:59:18 +0000 Subject: [PATCH] Corrected hart discovery bug --- src/Targets/RiscV/RiscV.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Targets/RiscV/RiscV.cpp b/src/Targets/RiscV/RiscV.cpp index 0da31ce0..fcb1f747 100644 --- a/src/Targets/RiscV/RiscV.cpp +++ b/src/Targets/RiscV/RiscV.cpp @@ -497,14 +497,14 @@ namespace Targets::RiscV controlRegister.selectedHartIndex = 0xFFFFF; this->writeDebugModuleControlRegister(controlRegister); - controlRegister = this->readDebugModuleControlRegister(); + const auto maxHartIndex = this->readDebugModuleControlRegister().selectedHartIndex; - for (DebugModule::HartIndex hartIndex = 0; hartIndex <= controlRegister.selectedHartIndex; ++hartIndex) { + for (DebugModule::HartIndex hartIndex = 0; hartIndex <= maxHartIndex; ++hartIndex) { /* * We can't just assume that everything between 0 and the maximum hart index are valid hart indices. We * have to test each index until we find one that is non-existent. */ - controlRegister = ControlRegister(); + auto controlRegister = ControlRegister(); controlRegister.debugModuleActive = true; controlRegister.selectedHartIndex = hartIndex;