Replaced messy AVR8 target config approach with new Avr8TargetConfig object
This commit is contained in:
@@ -53,14 +53,10 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
using Bloom::Targets::TargetRegisterType;
|
||||
using Bloom::Targets::TargetRegisters;
|
||||
|
||||
void EdbgAvr8Interface::configure(const TargetConfig& targetConfig) {
|
||||
this->configVariant = this->resolveConfigVariant().value_or(Avr8ConfigVariant::NONE);
|
||||
void EdbgAvr8Interface::configure(const Targets::Microchip::Avr::Avr8Bit::Avr8TargetConfig& targetConfig) {
|
||||
this->targetConfig = targetConfig;
|
||||
|
||||
if (targetConfig.jsonObject.contains("disableDebugWirePreDisconnect")) {
|
||||
this->disableDebugWireOnDeactivate = targetConfig.jsonObject.find(
|
||||
"disableDebugWirePreDisconnect"
|
||||
)->toBool();
|
||||
}
|
||||
this->configVariant = this->resolveConfigVariant().value_or(Avr8ConfigVariant::NONE);
|
||||
}
|
||||
|
||||
void EdbgAvr8Interface::setTargetParameters(const Avr8Bit::TargetParameters& config) {
|
||||
@@ -158,7 +154,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
|
||||
this->setParameter(
|
||||
Avr8EdbgParameters::PHYSICAL_INTERFACE,
|
||||
getAvr8PhysicalInterfaceToIdMapping().at(this->physicalInterface)
|
||||
getAvr8PhysicalInterfaceToIdMapping().at(this->targetConfig->physicalInterface)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -225,7 +221,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
this->activatePhysical();
|
||||
|
||||
} catch (const Avr8CommandFailure& activationException) {
|
||||
if (this->physicalInterface == PhysicalInterface::DEBUG_WIRE
|
||||
if (this->targetConfig->physicalInterface == PhysicalInterface::DEBUG_WIRE
|
||||
&& activationException.code == Avr8CommandFailureCode::DEBUGWIRE_PHYSICAL_ERROR
|
||||
) {
|
||||
throw DebugWirePhysicalInterfaceError(
|
||||
@@ -246,7 +242,10 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
|
||||
void EdbgAvr8Interface::deactivate() {
|
||||
if (this->targetAttached) {
|
||||
if (this->physicalInterface == PhysicalInterface::DEBUG_WIRE && this->disableDebugWireOnDeactivate) {
|
||||
if (
|
||||
this->targetConfig->physicalInterface == PhysicalInterface::DEBUG_WIRE
|
||||
&& this->targetConfig->disableDebugWireOnDeactivate
|
||||
) {
|
||||
try {
|
||||
this->disableDebugWire();
|
||||
Logger::warning(
|
||||
@@ -336,7 +335,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
throw Avr8CommandFailure("AVR8 Get device ID command failed", response);
|
||||
}
|
||||
|
||||
return response.extractSignature(this->physicalInterface);
|
||||
return response.extractSignature(this->targetConfig->physicalInterface);
|
||||
}
|
||||
|
||||
void EdbgAvr8Interface::setBreakpoint(std::uint32_t address) {
|
||||
|
||||
@@ -81,11 +81,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
*
|
||||
* @param targetConfig
|
||||
*/
|
||||
void configure(const TargetConfig& targetConfig) override;
|
||||
|
||||
void setPhysicalInterface(Targets::Microchip::Avr::Avr8Bit::PhysicalInterface physicalInterface) override {
|
||||
this->physicalInterface = physicalInterface;
|
||||
}
|
||||
void configure(const Targets::Microchip::Avr::Avr8Bit::Avr8TargetConfig& targetConfig) override;
|
||||
|
||||
/**
|
||||
* Configures the target family. For some physical interfaces, the target family is required in order
|
||||
@@ -263,6 +259,11 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
*/
|
||||
EdbgInterface& edbgInterface;
|
||||
|
||||
/**
|
||||
* Project's AVR8 target configuration.
|
||||
*/
|
||||
std::optional<Targets::Microchip::Avr::Avr8Bit::Avr8TargetConfig> targetConfig;
|
||||
|
||||
/**
|
||||
* The target family is taken into account when configuring the AVR8 Generic protocol on the EDBG device.
|
||||
*
|
||||
@@ -284,13 +285,6 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
*/
|
||||
Avr8ConfigVariant configVariant = Avr8ConfigVariant::NONE;
|
||||
|
||||
/**
|
||||
* Currently, the AVR8 Generic protocol supports 4 physical interfaces: debugWire, JTAG, PDI and UPDI.
|
||||
* The desired physical interface must be selected by setting the "AVR8_PHY_PHYSICAL" parameter.
|
||||
*/
|
||||
Targets::Microchip::Avr::Avr8Bit::PhysicalInterface physicalInterface =
|
||||
Targets::Microchip::Avr::Avr8Bit::PhysicalInterface::DEBUG_WIRE;
|
||||
|
||||
/**
|
||||
* EDBG-based debug tools require target specific parameters such as memory locations, page sizes and
|
||||
* register addresses. It is the AVR8 target's responsibility to obtain the required information and pass it
|
||||
@@ -332,24 +326,6 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
*/
|
||||
bool targetAttached = false;
|
||||
|
||||
/**
|
||||
* Because the debugWire module requires control of the reset pin on the target, enabling this module will
|
||||
* effectively mean losing control of the reset pin. This means users won't be able to use other
|
||||
* interfaces that require access to the reset pin, such as ISP, until the debugWire module is disabled.
|
||||
*
|
||||
* The AVR8 Generic protocol provides a function for temporarily disabling the debugWire module on the target.
|
||||
* This doesn't change the DWEN fuse and its affect is only temporary - the debugWire module will be
|
||||
* reactivated upon the user cycling the power to the target.
|
||||
*
|
||||
* Bloom is able to temporarily disable the debugWire module, automatically, upon deactivating of the
|
||||
* target (which usually occurs after a debug session has ended). This allows users to program the target via
|
||||
* ISP, after they've finished a debug session. After programming the target, the user will need to cycle the
|
||||
* target power before Bloom can gain access for another debug session.
|
||||
*
|
||||
* See disableDebugWire() method below.
|
||||
*/
|
||||
bool disableDebugWireOnDeactivate = false;
|
||||
|
||||
/**
|
||||
* This mapping allows us to determine which config variant to select, based on the target family and the
|
||||
* selected physical interface.
|
||||
@@ -415,8 +391,8 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
auto configVariantsByPhysicalInterface = configVariantsByFamily
|
||||
.at(this->family.value());
|
||||
|
||||
if (configVariantsByPhysicalInterface.contains(this->physicalInterface)) {
|
||||
return configVariantsByPhysicalInterface.at(this->physicalInterface);
|
||||
if (configVariantsByPhysicalInterface.contains(this->targetConfig->physicalInterface)) {
|
||||
return configVariantsByPhysicalInterface.at(this->targetConfig->physicalInterface);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -441,8 +417,8 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
{PhysicalInterface::UPDI, Avr8ConfigVariant::UPDI},
|
||||
};
|
||||
|
||||
if (physicalInterfacesToConfigVariants.contains(this->physicalInterface)) {
|
||||
return physicalInterfacesToConfigVariants.at(this->physicalInterface);
|
||||
if (physicalInterfacesToConfigVariants.contains(this->targetConfig->physicalInterface)) {
|
||||
return physicalInterfacesToConfigVariants.at(this->targetConfig->physicalInterface);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include <cstdint>
|
||||
#include <set>
|
||||
|
||||
#include "src/Targets/Microchip/AVR/AVR8/Avr8TargetConfig.hpp"
|
||||
|
||||
#include "src/Targets/Microchip/AVR/TargetSignature.hpp"
|
||||
#include "src/Targets/Microchip/AVR/AVR8/Family.hpp"
|
||||
#include "src/Targets/Microchip/AVR/AVR8/PhysicalInterface.hpp"
|
||||
@@ -11,7 +13,6 @@
|
||||
#include "src/Targets/TargetState.hpp"
|
||||
#include "src/Targets/TargetRegister.hpp"
|
||||
#include "src/Targets/TargetMemory.hpp"
|
||||
#include "src/ProjectConfig.hpp"
|
||||
|
||||
namespace Bloom::DebugToolDrivers::TargetInterfaces::Microchip::Avr::Avr8
|
||||
{
|
||||
@@ -42,12 +43,9 @@ namespace Bloom::DebugToolDrivers::TargetInterfaces::Microchip::Avr::Avr8
|
||||
* Configures the interface. Any debug tool -> target interface specific configuration should take
|
||||
* place here.
|
||||
*
|
||||
* For example, the EdbgAvr8Interface implementation configures the physical interface and config
|
||||
* variant here.
|
||||
*
|
||||
* @param targetConfig
|
||||
*/
|
||||
virtual void configure(const TargetConfig& targetConfig) = 0;
|
||||
virtual void configure(const Targets::Microchip::Avr::Avr8Bit::Avr8TargetConfig& targetConfig) = 0;
|
||||
|
||||
/**
|
||||
* Sets the target family, independent of other configuration.
|
||||
@@ -56,13 +54,6 @@ namespace Bloom::DebugToolDrivers::TargetInterfaces::Microchip::Avr::Avr8
|
||||
*/
|
||||
virtual void setFamily(Targets::Microchip::Avr::Avr8Bit::Family family) = 0;
|
||||
|
||||
/**
|
||||
* Sets the selected physical interface.
|
||||
*
|
||||
* @param physicalInterface
|
||||
*/
|
||||
virtual void setPhysicalInterface(Targets::Microchip::Avr::Avr8Bit::PhysicalInterface physicalInterface) = 0;
|
||||
|
||||
/**
|
||||
* Should accept Avr8 target parameters for configuration of the interface.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user