Lots of tidying
This commit is contained in:
@@ -477,14 +477,13 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
const auto startAddress = descriptor.startAddress.value();
|
||||
const auto endAddress = startAddress + (descriptor.size - 1);
|
||||
|
||||
if (!addressRangeByType.contains(descriptor.type)) {
|
||||
auto addressRange = AddressRange();
|
||||
addressRange.first = startAddress;
|
||||
addressRange.second = endAddress;
|
||||
addressRangeByType[descriptor.type] = addressRange;
|
||||
const auto addressRangeit = addressRangeByType.find(descriptor.type);
|
||||
|
||||
if (addressRangeit == addressRangeByType.end()) {
|
||||
addressRangeByType[descriptor.type] = AddressRange(startAddress, endAddress);
|
||||
|
||||
} else {
|
||||
auto& addressRange = addressRangeByType[descriptor.type];
|
||||
auto& addressRange = addressRangeit->second;
|
||||
|
||||
if (startAddress < addressRange.first) {
|
||||
addressRange.first = startAddress;
|
||||
@@ -869,14 +868,17 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
|
||||
std::optional<Avr8ConfigVariant> EdbgAvr8Interface::resolveConfigVariant() {
|
||||
if (this->family.has_value()) {
|
||||
auto configVariantsByFamily = EdbgAvr8Interface::getConfigVariantsByFamilyAndPhysicalInterface();
|
||||
const auto configVariantsByFamily = EdbgAvr8Interface::getConfigVariantsByFamilyAndPhysicalInterface();
|
||||
const auto configVariantsByPhysicalInterfaceIt = configVariantsByFamily.find(*(this->family));
|
||||
|
||||
if (configVariantsByFamily.contains(this->family.value())) {
|
||||
auto configVariantsByPhysicalInterface = configVariantsByFamily
|
||||
.at(this->family.value());
|
||||
if (configVariantsByPhysicalInterfaceIt != configVariantsByFamily.end()) {
|
||||
const auto& configVariantsByPhysicalInterface = configVariantsByPhysicalInterfaceIt->second;
|
||||
const auto configVariantIt = configVariantsByPhysicalInterface.find(
|
||||
this->targetConfig->physicalInterface
|
||||
);
|
||||
|
||||
if (configVariantsByPhysicalInterface.contains(this->targetConfig->physicalInterface)) {
|
||||
return configVariantsByPhysicalInterface.at(this->targetConfig->physicalInterface);
|
||||
if (configVariantIt != configVariantsByPhysicalInterface.end()) {
|
||||
return configVariantIt->second;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -894,14 +896,15 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
* variant. Users are required to specify the exact target name in their config, when using the JTAG
|
||||
* physical interface. That way, this->family will be set by the time resolveConfigVariant() is called.
|
||||
*/
|
||||
static std::map<PhysicalInterface, Avr8ConfigVariant> physicalInterfacesToConfigVariants = {
|
||||
static const std::map<PhysicalInterface, Avr8ConfigVariant> physicalInterfacesToConfigVariants = {
|
||||
{PhysicalInterface::DEBUG_WIRE, Avr8ConfigVariant::DEBUG_WIRE},
|
||||
{PhysicalInterface::PDI, Avr8ConfigVariant::XMEGA},
|
||||
{PhysicalInterface::UPDI, Avr8ConfigVariant::UPDI},
|
||||
};
|
||||
const auto configVariantIt = physicalInterfacesToConfigVariants.find(this->targetConfig->physicalInterface);
|
||||
|
||||
if (physicalInterfacesToConfigVariants.contains(this->targetConfig->physicalInterface)) {
|
||||
return physicalInterfacesToConfigVariants.at(this->targetConfig->physicalInterface);
|
||||
if (configVariantIt != physicalInterfacesToConfigVariants.end()) {
|
||||
return configVariantIt->second;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -74,20 +74,28 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||
explicit Avr8CommandFailure(
|
||||
const std::string& message,
|
||||
const ResponseFrames::Avr8Generic::Avr8GenericResponseFrame& responseFrame
|
||||
): TargetOperationFailure(message) {
|
||||
)
|
||||
: TargetOperationFailure(message)
|
||||
{
|
||||
this->message = message;
|
||||
|
||||
if (
|
||||
responseFrame.payload.size() == 3
|
||||
&& this->failureCodeToDescription.contains(static_cast<Avr8CommandFailureCode>(responseFrame.payload[2]))
|
||||
) {
|
||||
this->code = static_cast<Avr8CommandFailureCode>(responseFrame.payload[2]);
|
||||
this->message += " - Failure reason: " + this->failureCodeToDescription.at(*(this->code));
|
||||
if (responseFrame.payload.size() == 3) {
|
||||
/*
|
||||
* The response includes a failure code - lookup the corresponding description and append it to the
|
||||
* exception message.
|
||||
*/
|
||||
const auto failureCode = static_cast<Avr8CommandFailureCode>(responseFrame.payload[2]);
|
||||
const auto failureCodeDescriptionIt = this->failureCodeToDescription.find(failureCode);
|
||||
|
||||
if (failureCodeDescriptionIt != this->failureCodeToDescription.end()) {
|
||||
this->code = failureCode;
|
||||
this->message += " - Failure reason: " + failureCodeDescriptionIt->second;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
static inline auto failureCodeToDescription = std::map<Avr8CommandFailureCode, std::string>({
|
||||
static const inline auto failureCodeToDescription = std::map<Avr8CommandFailureCode, std::string>({
|
||||
{Avr8CommandFailureCode::DEBUGWIRE_PHYSICAL_ERROR, "debugWIRE physical error"},
|
||||
{Avr8CommandFailureCode::JTAGM_FAILED_TO_INITIALISE, "JTAGM failed to initialise"},
|
||||
{Avr8CommandFailureCode::UNKNOWN_JTAG_ERROR, "JTAGM did something strange"},
|
||||
|
||||
Reference in New Issue
Block a user