diff --git a/src/DebugServer/Gdb/GdbRspDebugServer.hpp b/src/DebugServer/Gdb/GdbRspDebugServer.hpp index d002fa6a..c9e144b4 100644 --- a/src/DebugServer/Gdb/GdbRspDebugServer.hpp +++ b/src/DebugServer/Gdb/GdbRspDebugServer.hpp @@ -217,7 +217,6 @@ namespace DebugServer::Gdb ); this->targetControllerService.stopTargetExecution(); - this->targetControllerService.resetTarget(); } const auto commandPacketVariant = this->waitForCommandPacket(); diff --git a/src/DebugToolDrivers/Microchip/Protocols/EDBG/AVR/EdbgAvr8Interface.cpp b/src/DebugToolDrivers/Microchip/Protocols/EDBG/AVR/EdbgAvr8Interface.cpp index 458ab1f6..5f2ebfd8 100644 --- a/src/DebugToolDrivers/Microchip/Protocols/EDBG/AVR/EdbgAvr8Interface.cpp +++ b/src/DebugToolDrivers/Microchip/Protocols/EDBG/AVR/EdbgAvr8Interface.cpp @@ -119,6 +119,11 @@ namespace DebugToolDrivers::Microchip::Protocols::Edbg::Avr this->setParameter(Avr8EdbgParameters::JTAG_DAISY_CHAIN_SETTINGS, std::uint32_t{0}); } + this->setParameter( + Avr8EdbgParameters::RUN_TIMERS_WHILST_STOPPED, + static_cast(this->session.targetConfig.stopAllTimers ? 0 : 1) + ); + this->setParameter( Avr8EdbgParameters::CONFIG_VARIANT, static_cast(this->session.configVariant) diff --git a/src/ProjectConfig.cpp b/src/ProjectConfig.cpp index 1d67af77..f3ded5e5 100644 --- a/src/ProjectConfig.cpp +++ b/src/ProjectConfig.cpp @@ -194,6 +194,10 @@ TargetConfig::TargetConfig(const YAML::Node& targetNode) { this->physicalInterface = physicalInterfaceIt->second; + if (targetNode["resume_on_startup"]) { + this->resumeOnStartup = targetNode["resume_on_startup"].as(this->resumeOnStartup); + } + if (targetNode["variantName"]) { Logger::warning( "The 'variantName' target configuration parameter was removed in v2.0.0. Please use the " diff --git a/src/ProjectConfig.hpp b/src/ProjectConfig.hpp index d825416d..5c497bff 100644 --- a/src/ProjectConfig.hpp +++ b/src/ProjectConfig.hpp @@ -52,6 +52,11 @@ struct TargetConfig */ Targets::TargetPhysicalInterface physicalInterface; + /** + * Determines whether Bloom will resume target execution after activation. + */ + bool resumeOnStartup = false; + /** * Determines whether Bloom will make use of the target's hardware breakpoint resources (if available). */ diff --git a/src/TargetController/TargetControllerComponent.cpp b/src/TargetController/TargetControllerComponent.cpp index 4f20c686..2303b0f2 100644 --- a/src/TargetController/TargetControllerComponent.cpp +++ b/src/TargetController/TargetControllerComponent.cpp @@ -15,6 +15,8 @@ #include "src/Services/StringService.hpp" #include "src/Logger/Logger.hpp" +#include "Exceptions/TargetOperationFailure.hpp" + #include "src/Exceptions/FatalErrorException.hpp" #include "src/Exceptions/InvalidConfig.hpp" @@ -584,6 +586,18 @@ namespace TargetController } else { Logger::warning("Hardware breakpoints have been disabled"); } + + if ( + this->targetState->executionState == TargetExecutionState::STOPPED + && this->environmentConfig.targetConfig.resumeOnStartup + ) { + try { + this->resumeTarget(); + + } catch (const Exceptions::TargetOperationFailure& exception) { + Logger::error("Failed to resume target execution on startup - error: " + exception.getMessage()); + } + } } void TargetControllerComponent::releaseHardware() { @@ -628,11 +642,11 @@ namespace TargetController TargetControllerComponent::notifier.notify(); } - void TargetControllerComponent::refreshExecutionState(bool forceRefresh) { + void TargetControllerComponent::refreshExecutionState(bool forceUpdate) { auto newState = *(this->targetState); newState.executionState = this->target->getExecutionState(); - if (!forceRefresh && newState.executionState == this->targetState->executionState) { + if (!forceUpdate && newState.executionState == this->targetState->executionState) { return; } diff --git a/src/TargetController/TargetControllerComponent.hpp b/src/TargetController/TargetControllerComponent.hpp index 66610b9f..30996c74 100644 --- a/src/TargetController/TargetControllerComponent.hpp +++ b/src/TargetController/TargetControllerComponent.hpp @@ -272,7 +272,7 @@ namespace TargetController void startAtomicSession(); void endActiveAtomicSession(); - void refreshExecutionState(bool forceRefresh = false); + void refreshExecutionState(bool forceUpdate = false); void updateTargetState(const Targets::TargetState& newState); void stopTarget(); diff --git a/src/Targets/Microchip/AVR8/Avr8.cpp b/src/Targets/Microchip/AVR8/Avr8.cpp index 8f32c9e5..55704797 100644 --- a/src/Targets/Microchip/AVR8/Avr8.cpp +++ b/src/Targets/Microchip/AVR8/Avr8.cpp @@ -209,20 +209,23 @@ namespace Targets::Microchip::Avr8 this->activated = true; - /* - * Validate the target signature. - * - * The signature obtained from the device should match what we loaded from the target description file. - */ - const auto targetSignature = this->avr8DebugInterface->getDeviceId(); + if (this->targetConfig.signatureValidation) { + /* + * Validate the target signature. + * + * The signature obtained from the device should match what we loaded from the target description file. + */ + const auto targetSignature = this->avr8DebugInterface->getDeviceId(); - if (targetSignature != this->signature) { - throw Exception{ - "Failed to validate connected target - target signature mismatch.\nThe target signature" - " (\"" + targetSignature.toHex() + "\") does not match the AVR8 target description signature (\"" - + this->signature.toHex() + "\"). This will likely be due to an incorrect target name in the " - + "configuration file (bloom.yaml)." - }; + if (targetSignature != this->signature) { + throw Exception{ + "Failed to validate connected target - target signature mismatch.\nThe target signature" + " (\"" + targetSignature.toHex() + + "\") does not match the AVR8 target description signature (\"" + + this->signature.toHex() + "\"). This will likely be due to an incorrect target name in the " + + "configuration file (bloom.yaml)." + }; + } } } diff --git a/src/Targets/Microchip/AVR8/Avr8TargetConfig.cpp b/src/Targets/Microchip/AVR8/Avr8TargetConfig.cpp index 52d25c9d..f4441fe9 100644 --- a/src/Targets/Microchip/AVR8/Avr8TargetConfig.cpp +++ b/src/Targets/Microchip/AVR8/Avr8TargetConfig.cpp @@ -38,5 +38,13 @@ namespace Targets::Microchip::Avr8 if (targetNode["preserve_eeprom"]) { this->preserveEeprom = targetNode["preserve_eeprom"].as(this->preserveEeprom); } + + if (targetNode["signature_validation"]) { + this->signatureValidation = targetNode["signature_validation"].as(this->signatureValidation); + } + + if (targetNode["stop_all_timers"]) { + this->stopAllTimers = targetNode["stop_all_timers"].as(this->stopAllTimers); + } } } diff --git a/src/Targets/Microchip/AVR8/Avr8TargetConfig.hpp b/src/Targets/Microchip/AVR8/Avr8TargetConfig.hpp index d3f99b3d..364cf662 100644 --- a/src/Targets/Microchip/AVR8/Avr8TargetConfig.hpp +++ b/src/Targets/Microchip/AVR8/Avr8TargetConfig.hpp @@ -79,6 +79,17 @@ namespace Targets::Microchip::Avr8 */ bool preserveEeprom = true; + /** + * Determines whether Bloom will check for an AVR signature mismatch between the signature in the TDF and the + * connected target signature. + */ + bool signatureValidation = true; + + /** + * Determines whether Bloom will stop all timer peripherals on the target, when target execution is stopped. + */ + bool stopAllTimers = true; + explicit Avr8TargetConfig(const TargetConfig& targetConfig); }; } diff --git a/src/Targets/RiscV/RiscV.cpp b/src/Targets/RiscV/RiscV.cpp index 9c9754fb..9f33e46a 100644 --- a/src/Targets/RiscV/RiscV.cpp +++ b/src/Targets/RiscV/RiscV.cpp @@ -51,6 +51,8 @@ namespace Targets::RiscV void RiscV::activate() { this->riscVDebugInterface->activate(); + this->stop(); + this->reset(); } void RiscV::deactivate() { diff --git a/src/Targets/Target.hpp b/src/Targets/Target.hpp index 10287868..620655fa 100644 --- a/src/Targets/Target.hpp +++ b/src/Targets/Target.hpp @@ -53,8 +53,8 @@ namespace Targets virtual void setDebugTool(DebugTool* debugTool) = 0; /** - * This function should attempt to establish a connection with the target, and put it in a state where - * debugging can be performed. + * This function should attempt to establish a connection with the target, halt execution, and put it in a + * state where debugging can be performed. * * If an exception is thrown from this function, the TargetController will treat it as a fatal error, and thus * will shutdown, along with the rest of Bloom.