Added new exception class for debug wire physical interface errors - to be handled with a DWEN fuse check
This commit is contained in:
@@ -4,11 +4,13 @@
|
||||
#include <thread>
|
||||
#include <cmath>
|
||||
|
||||
#include "src/Logger/Logger.hpp"
|
||||
#include "src/Helpers/Paths.hpp"
|
||||
|
||||
#include "src/Exceptions/InvalidConfig.hpp"
|
||||
#include "src/TargetController/Exceptions/DeviceInitializationFailure.hpp"
|
||||
#include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/Exceptions/Avr8CommandFailure.hpp"
|
||||
#include "src/Logger/Logger.hpp"
|
||||
#include "src/Helpers/Paths.hpp"
|
||||
#include "src/Targets/Microchip/AVR/AVR8/Exceptions/DebugWirePhysicalInterfaceError.hpp"
|
||||
|
||||
// Command frames
|
||||
#include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/CommandFrames/AVR8Generic/SetParameter.hpp"
|
||||
@@ -219,7 +221,21 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
|
||||
void EdbgAvr8Interface::activate() {
|
||||
if (!this->physicalInterfaceActivated) {
|
||||
this->activatePhysical();
|
||||
try {
|
||||
this->activatePhysical();
|
||||
|
||||
} catch (const Avr8CommandFailure& activationException) {
|
||||
if (this->physicalInterface == PhysicalInterface::DEBUG_WIRE
|
||||
&& activationException.code == Avr8CommandFailureCode::DEBUGWIRE_PHYSICAL_ERROR
|
||||
) {
|
||||
throw DebugWirePhysicalInterfaceError(
|
||||
"Failed to activate the debugWire physical interface - check target connection. "
|
||||
"The target's DWEN fuse bit may need to be updated. See [TODO_ADD_LINK] for more information."
|
||||
);
|
||||
}
|
||||
|
||||
throw activationException;
|
||||
}
|
||||
}
|
||||
|
||||
if (!this->targetAttached) {
|
||||
|
||||
@@ -102,6 +102,10 @@ namespace Bloom::DebugToolDrivers::TargetInterfaces::Microchip::Avr::Avr8
|
||||
|
||||
/**
|
||||
* Should activate the physical interface between the debug tool and the AVR8 target.
|
||||
*
|
||||
* If the debugWire interface has been selected - this function should throw a DebugWirePhysicalInterfaceError
|
||||
* exception, in the event of a failure when activating the interface. The reason for this is to allow us the
|
||||
* chance to check the DWEN fuse bit, via an ISP interface. See Avr8::activate() for more.
|
||||
*/
|
||||
virtual void activate() = 0;
|
||||
|
||||
|
||||
@@ -8,6 +8,13 @@ namespace Bloom::Exceptions
|
||||
{
|
||||
public:
|
||||
explicit Exception(): std::runtime_error("") {}
|
||||
virtual ~Exception() = default;
|
||||
|
||||
Exception(const Exception& other) noexcept = default;
|
||||
Exception(Exception&& other) = default;
|
||||
|
||||
Exception& operator = (const Exception& other) = default;
|
||||
Exception& operator = (Exception&& other) = default;
|
||||
|
||||
explicit Exception(const std::string& message): std::runtime_error(message.c_str()), message(message) {}
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
#include "src/TargetController/Exceptions/TargetOperationFailure.hpp"
|
||||
|
||||
namespace Bloom::Exceptions
|
||||
{
|
||||
class DebugWirePhysicalInterfaceError: public TargetOperationFailure
|
||||
{
|
||||
public:
|
||||
explicit DebugWirePhysicalInterfaceError(const std::string& message): TargetOperationFailure(message) {
|
||||
this->message = message;
|
||||
}
|
||||
|
||||
explicit DebugWirePhysicalInterfaceError(const char* message): TargetOperationFailure(message) {
|
||||
this->message = std::string(message);
|
||||
}
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user