Catch errors when handling unexpected target resets in RiscV driver

This commit is contained in:
Nav
2025-01-27 23:57:35 +00:00
parent 25fd2a3a6a
commit 35e059c1bf

View File

@@ -179,19 +179,24 @@ namespace DebugToolDrivers::Protocols::RiscVDebugSpec
if (statusRegister.anyHaveReset) { if (statusRegister.anyHaveReset) {
Logger::warning("Reset detected at RISC-V hart " + std::to_string(this->selectedHartIndex)); Logger::warning("Reset detected at RISC-V hart " + std::to_string(this->selectedHartIndex));
if (statusRegister.anyRunning) { try {
this->stop(); if (statusRegister.anyRunning) {
} this->stop();
}
this->initDebugControlStatusRegister(); this->initDebugControlStatusRegister();
this->writeDebugModuleControlRegister(ControlRegister{ this->writeDebugModuleControlRegister(ControlRegister{
.debugModuleActive = true, .debugModuleActive = true,
.selectedHartIndex = this->selectedHartIndex, .selectedHartIndex = this->selectedHartIndex,
.acknowledgeHaveReset = true, .acknowledgeHaveReset = true,
}); });
if (statusRegister.anyRunning) { if (statusRegister.anyRunning) {
this->run(); this->run();
}
} catch (const Exceptions::TargetOperationFailure& exception) {
Logger::error("Failed to handle unexpected RISC-V hart reset - error: " + exception.getMessage());
} }
} }