Made physical interface enum more generic (moved out of AVR8-specific context)

This commit is contained in:
Nav
2024-02-15 21:24:41 +00:00
parent f33b4d8c70
commit 7e9e28286f
20 changed files with 156 additions and 160 deletions

View File

@@ -2,7 +2,7 @@
#include <map>
#include "src/Targets/Microchip/AVR/AVR8/PhysicalInterface.hpp"
#include "src/Targets/TargetPhysicalInterface.hpp"
namespace DebugToolDrivers::Microchip::Protocols::Edbg::Avr
{
@@ -103,14 +103,14 @@ namespace DebugToolDrivers::Microchip::Protocols::Edbg::Avr
DEBUGGING = 0x02,
};
static inline auto getAvr8PhysicalInterfaceToIdMapping() {
using Targets::Microchip::Avr::Avr8Bit::PhysicalInterface;
static inline auto getPhysicalInterfaceToAvr8IdMapping() {
using Targets::TargetPhysicalInterface;
return std::map<PhysicalInterface, unsigned char>({
{PhysicalInterface::DEBUG_WIRE, 0x05},
{PhysicalInterface::PDI, 0x06},
{PhysicalInterface::JTAG, 0x04},
{PhysicalInterface::UPDI, 0x08},
return std::map<TargetPhysicalInterface, unsigned char>({
{TargetPhysicalInterface::DEBUG_WIRE, 0x05},
{TargetPhysicalInterface::PDI, 0x06},
{TargetPhysicalInterface::JTAG, 0x04},
{TargetPhysicalInterface::UPDI, 0x08},
});
}

View File

@@ -76,6 +76,7 @@ namespace DebugToolDrivers::Microchip::Protocols::Edbg::Avr
using CommandFrames::Avr8Generic::DisableDebugWire;
using Targets::TargetState;
using Targets::TargetPhysicalInterface;
using Targets::TargetMemoryType;
using Targets::TargetMemoryBuffer;
using Targets::TargetMemoryAddress;
@@ -135,7 +136,7 @@ namespace DebugToolDrivers::Microchip::Protocols::Edbg::Avr
this->setParameter(
Avr8EdbgParameters::PHYSICAL_INTERFACE,
getAvr8PhysicalInterfaceToIdMapping().at(this->targetConfig.physicalInterface)
getPhysicalInterfaceToAvr8IdMapping().at(this->targetConfig.physicalInterface)
);
this->setTargetParameters();
@@ -227,7 +228,7 @@ namespace DebugToolDrivers::Microchip::Protocols::Edbg::Avr
} catch (const Avr8CommandFailure& activationException) {
if (
this->targetConfig.physicalInterface == PhysicalInterface::DEBUG_WIRE
this->targetConfig.physicalInterface == TargetPhysicalInterface::DEBUG_WIRE
&& (
activationException.code == Avr8CommandFailureCode::DEBUGWIRE_PHYSICAL_ERROR
|| activationException.code == Avr8CommandFailureCode::FAILED_TO_ENABLE_OCD
@@ -252,7 +253,7 @@ namespace DebugToolDrivers::Microchip::Protocols::Edbg::Avr
void EdbgAvr8Interface::deactivate() {
if (this->targetAttached) {
if (
this->targetConfig.physicalInterface == PhysicalInterface::DEBUG_WIRE
this->targetConfig.physicalInterface == TargetPhysicalInterface::DEBUG_WIRE
&& this->targetConfig.disableDebugWireOnDeactivate
) {
try {
@@ -947,54 +948,54 @@ namespace DebugToolDrivers::Microchip::Protocols::Edbg::Avr
}
}
std::map<Family, std::map<PhysicalInterface, Avr8ConfigVariant>>
std::map<Family, std::map<TargetPhysicalInterface, Avr8ConfigVariant>>
EdbgAvr8Interface::getConfigVariantsByFamilyAndPhysicalInterface() {
return std::map<Family, std::map<PhysicalInterface, Avr8ConfigVariant>>({
return std::map<Family, std::map<TargetPhysicalInterface, Avr8ConfigVariant>>({
{
Family::MEGA,
{
{PhysicalInterface::JTAG, Avr8ConfigVariant::MEGAJTAG},
{PhysicalInterface::DEBUG_WIRE, Avr8ConfigVariant::DEBUG_WIRE},
{PhysicalInterface::UPDI, Avr8ConfigVariant::UPDI},
{TargetPhysicalInterface::JTAG, Avr8ConfigVariant::MEGAJTAG},
{TargetPhysicalInterface::DEBUG_WIRE, Avr8ConfigVariant::DEBUG_WIRE},
{TargetPhysicalInterface::UPDI, Avr8ConfigVariant::UPDI},
}
},
{
Family::TINY,
{
{PhysicalInterface::JTAG, Avr8ConfigVariant::MEGAJTAG},
{PhysicalInterface::DEBUG_WIRE, Avr8ConfigVariant::DEBUG_WIRE},
{PhysicalInterface::UPDI, Avr8ConfigVariant::UPDI},
{TargetPhysicalInterface::JTAG, Avr8ConfigVariant::MEGAJTAG},
{TargetPhysicalInterface::DEBUG_WIRE, Avr8ConfigVariant::DEBUG_WIRE},
{TargetPhysicalInterface::UPDI, Avr8ConfigVariant::UPDI},
}
},
{
Family::XMEGA,
{
{PhysicalInterface::JTAG, Avr8ConfigVariant::XMEGA},
{PhysicalInterface::PDI, Avr8ConfigVariant::XMEGA},
{TargetPhysicalInterface::JTAG, Avr8ConfigVariant::XMEGA},
{TargetPhysicalInterface::PDI, Avr8ConfigVariant::XMEGA},
}
},
{
Family::DA,
{
{PhysicalInterface::UPDI, Avr8ConfigVariant::UPDI},
{TargetPhysicalInterface::UPDI, Avr8ConfigVariant::UPDI},
}
},
{
Family::DB,
{
{PhysicalInterface::UPDI, Avr8ConfigVariant::UPDI},
{TargetPhysicalInterface::UPDI, Avr8ConfigVariant::UPDI},
}
},
{
Family::DD,
{
{PhysicalInterface::UPDI, Avr8ConfigVariant::UPDI},
{TargetPhysicalInterface::UPDI, Avr8ConfigVariant::UPDI},
}
},
{
Family::EA,
{
{PhysicalInterface::UPDI, Avr8ConfigVariant::UPDI},
{TargetPhysicalInterface::UPDI, Avr8ConfigVariant::UPDI},
}
},
});
@@ -1002,7 +1003,7 @@ namespace DebugToolDrivers::Microchip::Protocols::Edbg::Avr
Avr8ConfigVariant EdbgAvr8Interface::resolveConfigVariant(
Targets::Microchip::Avr::Avr8Bit::Family targetFamily,
Targets::Microchip::Avr::Avr8Bit::PhysicalInterface physicalInterface
TargetPhysicalInterface physicalInterface
) {
const auto configVariantsByFamily = EdbgAvr8Interface::getConfigVariantsByFamilyAndPhysicalInterface();
const auto configVariantsByPhysicalInterfaceIt = configVariantsByFamily.find(targetFamily);

View File

@@ -11,10 +11,10 @@
#include "Avr8Generic.hpp"
#include "src/Targets/TargetPhysicalInterface.hpp"
#include "src/Targets/TargetMemory.hpp"
#include "src/Targets/TargetRegister.hpp"
#include "src/Targets/Microchip/AVR/AVR8/Family.hpp"
#include "src/Targets/Microchip/AVR/AVR8/PhysicalInterface.hpp"
#include "src/Targets/Microchip/AVR/AVR8/TargetParameters.hpp"
namespace DebugToolDrivers::Microchip::Protocols::Edbg::Avr
@@ -384,7 +384,7 @@ namespace DebugToolDrivers::Microchip::Protocols::Edbg::Avr
*/
static std::map<
Targets::Microchip::Avr::Avr8Bit::Family,
std::map<Targets::Microchip::Avr::Avr8Bit::PhysicalInterface, Avr8ConfigVariant>
std::map<Targets::TargetPhysicalInterface, Avr8ConfigVariant>
> getConfigVariantsByFamilyAndPhysicalInterface();
/**
@@ -394,7 +394,7 @@ namespace DebugToolDrivers::Microchip::Protocols::Edbg::Avr
*/
static Avr8ConfigVariant resolveConfigVariant(
Targets::Microchip::Avr::Avr8Bit::Family targetFamily,
Targets::Microchip::Avr::Avr8Bit::PhysicalInterface physicalInterface
Targets::TargetPhysicalInterface physicalInterface
);
/**

View File

@@ -7,27 +7,27 @@ namespace DebugToolDrivers::Microchip::Protocols::Edbg::Avr::ResponseFrames::Avr
{}
Targets::Microchip::Avr::TargetSignature GetDeviceId::extractSignature(
Targets::Microchip::Avr::Avr8Bit::PhysicalInterface physicalInterface
Targets::TargetPhysicalInterface physicalInterface
) const {
using Targets::Microchip::Avr::Avr8Bit::PhysicalInterface;
using Targets::TargetPhysicalInterface;
const auto payloadData = this->getPayloadData();
switch (physicalInterface) {
case PhysicalInterface::DEBUG_WIRE: {
case TargetPhysicalInterface::DEBUG_WIRE: {
/*
* When using the DebugWire physical interface, the get device ID command will return
* four bytes, where the first can be ignored.
*/
return Targets::Microchip::Avr::TargetSignature(payloadData[1], payloadData[2], payloadData[3]);
}
case PhysicalInterface::PDI:
case PhysicalInterface::UPDI: {
case TargetPhysicalInterface::PDI:
case TargetPhysicalInterface::UPDI: {
/*
* When using the PDI physical interface, the signature is returned in LSB format.
*/
return Targets::Microchip::Avr::TargetSignature(payloadData[3], payloadData[2], payloadData[1]);
}
case PhysicalInterface::JTAG: {
case TargetPhysicalInterface::JTAG: {
/*
* When using the JTAG interface, the get device ID command returns a 32 bit JTAG ID. This takes
* the following form:

View File

@@ -3,7 +3,7 @@
#include "Avr8GenericResponseFrame.hpp"
#include "src/Targets/Microchip/AVR/TargetSignature.hpp"
#include "src/Targets/Microchip/AVR/AVR8/PhysicalInterface.hpp"
#include "src/Targets/TargetPhysicalInterface.hpp"
namespace DebugToolDrivers::Microchip::Protocols::Edbg::Avr::ResponseFrames::Avr8Generic
{
@@ -13,7 +13,7 @@ namespace DebugToolDrivers::Microchip::Protocols::Edbg::Avr::ResponseFrames::Avr
explicit GetDeviceId(const std::vector<AvrResponse>& AvrResponses);
Targets::Microchip::Avr::TargetSignature extractSignature(
Targets::Microchip::Avr::Avr8Bit::PhysicalInterface physicalInterface
Targets::TargetPhysicalInterface physicalInterface
) const;
};
}

View File

@@ -8,7 +8,6 @@
#include "src/Targets/Microchip/AVR/TargetSignature.hpp"
#include "src/Targets/Microchip/AVR/AVR8/Family.hpp"
#include "src/Targets/Microchip/AVR/AVR8/PhysicalInterface.hpp"
#include "src/Targets/Microchip/AVR/AVR8/ProgramMemorySection.hpp"
#include "src/Targets/Microchip/AVR/AVR8/TargetParameters.hpp"

View File

@@ -153,6 +153,8 @@ EnvironmentConfig::EnvironmentConfig(std::string name, const YAML::Node& environ
}
TargetConfig::TargetConfig(const YAML::Node& targetNode) {
using Targets::TargetPhysicalInterface;
if (!targetNode.IsMap()) {
throw Exceptions::InvalidConfig(
"Invalid target configuration provided - node must take the form of a YAML mapping."
@@ -165,6 +167,31 @@ TargetConfig::TargetConfig(const YAML::Node& targetNode) {
this->name = StringService::asciiToLower(targetNode["name"].as<std::string>());
static auto physicalInterfacesByConfigName = std::map<std::string, TargetPhysicalInterface>({
{"debugwire", TargetPhysicalInterface::DEBUG_WIRE}, // Deprecated - left here for backwards compatibility
{"debug-wire", TargetPhysicalInterface::DEBUG_WIRE},
{"pdi", TargetPhysicalInterface::PDI},
{"jtag", TargetPhysicalInterface::JTAG},
{"updi", TargetPhysicalInterface::UPDI},
});
if (!targetNode["physicalInterface"]) {
throw Exceptions::InvalidConfig("No physical interface specified.");
}
const auto physicalInterfaceName = StringService::asciiToLower(targetNode["physicalInterface"].as<std::string>());
const auto physicalInterfaceIt = physicalInterfacesByConfigName.find(physicalInterfaceName);
if (physicalInterfaceIt == physicalInterfacesByConfigName.end()) {
throw Exceptions::InvalidConfig(
"Invalid physical interface provided (\"" + physicalInterfaceName + "\") for target. "
"See " + Services::PathService::homeDomainName() + "/docs/configuration/target-physical-interfaces "
"for valid physical interface configuration values."
);
}
this->physicalInterface = physicalInterfaceIt->second;
if (targetNode["variantName"]) {
this->variantName = StringService::asciiToLower(targetNode["variantName"].as<std::string>());
}

View File

@@ -6,6 +6,8 @@
#include <optional>
#include <yaml-cpp/yaml.h>
#include "src/Targets/TargetPhysicalInterface.hpp"
/*
* Currently, all user configuration is stored in a YAML file (bloom.yaml), in the user's project directory.
*
@@ -44,6 +46,12 @@ struct TargetConfig
*/
std::string name;
/**
* The physical interface is the interface used for communication between the debug tool and the connected
* target.
*/
Targets::TargetPhysicalInterface physicalInterface;
/**
* The name of the selected target variant.
*

View File

@@ -4,9 +4,9 @@ target_sources(
${CMAKE_CURRENT_SOURCE_DIR}/TargetDescription/TargetDescriptionFile.cpp
${CMAKE_CURRENT_SOURCE_DIR}/TargetRegister.cpp
${CMAKE_CURRENT_SOURCE_DIR}/TargetMemoryCache.cpp
${CMAKE_CURRENT_SOURCE_DIR}/TargetPhysicalInterface.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Microchip/AVR/AVR8/Avr8.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Microchip/AVR/AVR8/Avr8TargetConfig.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Microchip/AVR/AVR8/PhysicalInterface.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Microchip/AVR/AVR8/TargetDescription/TargetDescriptionFile.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Microchip/AVR/AVR8/OpcodeDecoder/Decoder.cpp
${CMAKE_CURRENT_SOURCE_DIR}/RiscV/RiscV.cpp

View File

@@ -25,7 +25,7 @@ namespace Targets::Microchip::Avr::Avr8Bit
, name(this->targetDescriptionFile.getTargetName())
, family(this->targetDescriptionFile.getAvrFamily())
, targetParameters(this->targetDescriptionFile.getTargetParameters())
, supportedPhysicalInterfaces(this->targetDescriptionFile.getSupportedPhysicalInterfaces())
, physicalInterfaces(this->targetDescriptionFile.getPhysicalInterfaces())
, padDescriptorsByName(this->targetDescriptionFile.getPadDescriptorsMappedByName())
, targetVariantsById(this->targetDescriptionFile.getVariantsMappedById())
, stackPointerRegisterDescriptor(
@@ -54,24 +54,24 @@ namespace Targets::Microchip::Avr::Avr8Bit
)
, fuseEnableStrategy(this->targetDescriptionFile.getFuseEnableStrategy().value_or(FuseEnableStrategy::CLEAR))
{
if (!this->supportedPhysicalInterfaces.contains(this->targetConfig.physicalInterface)) {
if (!this->physicalInterfaces.contains(this->targetConfig.physicalInterface)) {
/*
* The user has selected a physical interface that does not appear to be supported by the selected
* target.
*
* Bloom's target description files provide a list of supported physical interfaces for each target
* (which is how this->supportedPhysicalInterfaces is populated), but it's possible that this list may
* (which is how this->physicalInterfaces is populated), but it's possible that this list may
* be wrong/incomplete. For this reason, we don't throw an exception here. Instead, we just present the
* user with a warning and a list of physical interfaces known to be supported by their selected target.
*/
const auto physicalInterfaceNames = getPhysicalInterfaceNames();
const auto supportedPhysicalInterfaceList = std::accumulate(
this->supportedPhysicalInterfaces.begin(),
this->supportedPhysicalInterfaces.end(),
this->physicalInterfaces.begin(),
this->physicalInterfaces.end(),
std::string(),
[&physicalInterfaceNames] (const std::string& string, PhysicalInterface physicalInterface) {
if (physicalInterface == PhysicalInterface::ISP) {
[&physicalInterfaceNames] (const std::string& string, TargetPhysicalInterface physicalInterface) {
if (physicalInterface == TargetPhysicalInterface::ISP) {
/*
* Don't include the ISP interface in the list of supported interfaces, as doing so may
* mislead the user into thinking the ISP interface can be used for debugging operations.
@@ -88,15 +88,13 @@ namespace Targets::Microchip::Avr::Avr8Bit
+ physicalInterfaceNames.at(this->targetConfig.physicalInterface) + "). Target activation "
"will likely fail. The target supports the following physical interfaces: \n"
+ supportedPhysicalInterfaceList + "\n\nFor physical interface configuration values, see "
+ Services::PathService::homeDomainName() + "/docs/configuration/avr8-physical-interfaces. \n\n"
+ "If this information is incorrect, please report this to Bloom developers via "
+ Services::PathService::homeDomainName() + "/report-issue.\n"
+ Services::PathService::homeDomainName() + "/docs/configuration/target-physical-interfaces."
);
}
if (
this->targetConfig.manageOcdenFuseBit
&& this->targetConfig.physicalInterface != PhysicalInterface::JTAG
&& this->targetConfig.physicalInterface != TargetPhysicalInterface::JTAG
) {
Logger::warning(
"The 'manageOcdenFuseBit' parameter only applies to JTAG targets. It will be ignored in this session."
@@ -136,7 +134,7 @@ namespace Targets::Microchip::Avr::Avr8Bit
if (
this->targetConfig.manageDwenFuseBit
&& this->avrIspInterface == nullptr
&& this->targetConfig.physicalInterface == PhysicalInterface::DEBUG_WIRE
&& this->targetConfig.physicalInterface == TargetPhysicalInterface::DEBUG_WIRE
) {
Logger::warning(
"The connected debug tool (or associated driver) does not provide any ISP interface. "
@@ -210,7 +208,7 @@ namespace Targets::Microchip::Avr::Avr8Bit
}
if (
this->targetConfig.physicalInterface == PhysicalInterface::JTAG
this->targetConfig.physicalInterface == TargetPhysicalInterface::JTAG
&& this->targetConfig.manageOcdenFuseBit
) {
Logger::debug("Attempting OCDEN fuse bit management");
@@ -248,7 +246,7 @@ namespace Targets::Microchip::Avr::Avr8Bit
this->clearAllBreakpoints();
if (
this->targetConfig.physicalInterface == PhysicalInterface::JTAG
this->targetConfig.physicalInterface == TargetPhysicalInterface::JTAG
&& this->targetConfig.manageOcdenFuseBit
) {
Logger::debug("Attempting OCDEN fuse bit management");
@@ -357,7 +355,7 @@ namespace Targets::Microchip::Avr::Avr8Bit
void Avr8::eraseMemory(TargetMemoryType memoryType) {
if (memoryType == TargetMemoryType::FLASH) {
if (this->targetConfig.physicalInterface == PhysicalInterface::DEBUG_WIRE) {
if (this->targetConfig.physicalInterface == TargetPhysicalInterface::DEBUG_WIRE) {
// debugWire targets do not need to be erased
return;
}
@@ -374,8 +372,8 @@ namespace Targets::Microchip::Avr::Avr8Bit
* the chip erase. The fuse will be restored to its original value at the end of the programming session.
*/
if (
this->targetConfig.physicalInterface == PhysicalInterface::JTAG
|| this->targetConfig.physicalInterface == PhysicalInterface::UPDI
this->targetConfig.physicalInterface == TargetPhysicalInterface::JTAG
|| this->targetConfig.physicalInterface == TargetPhysicalInterface::UPDI
) {
if (this->targetConfig.preserveEeprom) {
Logger::debug("Inspecting EESAVE fuse bit");
@@ -705,15 +703,15 @@ namespace Targets::Microchip::Avr::Avr8Bit
auto maxHardwareBreakpoints = static_cast<std::uint16_t>(0);
switch (this->targetConfig.physicalInterface) {
case PhysicalInterface::JTAG: {
case TargetPhysicalInterface::JTAG: {
maxHardwareBreakpoints = this->family == Family::XMEGA ? 2 : 3;
break;
}
case PhysicalInterface::PDI: {
case TargetPhysicalInterface::PDI: {
maxHardwareBreakpoints = 2;
break;
}
case PhysicalInterface::UPDI: {
case TargetPhysicalInterface::UPDI: {
maxHardwareBreakpoints = 1;
break;
}
@@ -763,7 +761,7 @@ namespace Targets::Microchip::Avr::Avr8Bit
);
}
if (!this->supportedPhysicalInterfaces.contains(PhysicalInterface::DEBUG_WIRE)) {
if (!this->physicalInterfaces.contains(TargetPhysicalInterface::DEBUG_WIRE)) {
throw Exception(
"Target does not support debugWire physical interface - check target configuration or "
"report this issue via " + Services::PathService::homeDomainName() + "/report-issue"
@@ -932,7 +930,7 @@ namespace Targets::Microchip::Avr::Avr8Bit
using Services::PathService;
using Services::StringService;
if (!this->supportedPhysicalInterfaces.contains(PhysicalInterface::JTAG)) {
if (!this->physicalInterfaces.contains(TargetPhysicalInterface::JTAG)) {
throw Exception(
"Target does not support JTAG physical interface - check target configuration or "
"report this issue via " + PathService::homeDomainName() + "/report-issue"

View File

@@ -18,6 +18,7 @@
#include "ProgrammingSession.hpp"
#include "src/Targets/Microchip/AVR/Fuse.hpp"
#include "src/Targets/TargetPhysicalInterface.hpp"
#include "src/Targets/TargetRegister.hpp"
#include "src/Targets/TargetBreakpoint.hpp"
@@ -119,7 +120,7 @@ namespace Targets::Microchip::Avr::Avr8Bit
TargetParameters targetParameters;
std::set<PhysicalInterface> supportedPhysicalInterfaces;
std::set<Targets::TargetPhysicalInterface> physicalInterfaces;
std::map<std::string, PadDescriptor> padDescriptorsByName;
std::map<int, TargetVariant> targetVariantsById;

View File

@@ -14,25 +14,6 @@ namespace Targets::Microchip::Avr::Avr8Bit
const auto& targetNode = targetConfig.targetNode;
if (!targetNode["physicalInterface"]) {
throw InvalidConfig("Missing physical interface config parameter for AVR8 target.");
}
const auto physicalInterfaceName = Services::StringService::asciiToLower(targetNode["physicalInterface"].as<std::string>());
const auto physicalInterfaceIt = Avr8TargetConfig::debugPhysicalInterfacesByConfigName.find(
physicalInterfaceName
);
if (physicalInterfaceIt == Avr8TargetConfig::debugPhysicalInterfacesByConfigName.end()) {
throw InvalidConfig(
"Invalid physical interface provided (\"" + physicalInterfaceName + "\") for AVR8 target. "
"See " + Services::PathService::homeDomainName() + "/docs/configuration/avr8-physical-interfaces for valid physical "
"interface configuration values."
);
}
this->physicalInterface = physicalInterfaceIt->second;
// The 'manageDwenFuseBit' param used to be 'updateDwenFuseBit' - we still support the old, for now.
if (targetNode["updateDwenFuseBit"]) {
this->manageDwenFuseBit = targetNode["updateDwenFuseBit"].as<bool>(

View File

@@ -6,8 +6,6 @@
#include "src/ProjectConfig.hpp"
#include "PhysicalInterface.hpp"
namespace Targets::Microchip::Avr::Avr8Bit
{
/**
@@ -16,12 +14,6 @@ namespace Targets::Microchip::Avr::Avr8Bit
struct Avr8TargetConfig: public TargetConfig
{
public:
/**
* The physical interface is the interface used for communication between the debug tool and the connected
* target.
*/
PhysicalInterface physicalInterface = PhysicalInterface::DEBUG_WIRE;
/**
* 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
@@ -99,14 +91,5 @@ namespace Targets::Microchip::Avr::Avr8Bit
bool reserveSteppingBreakpoint = true;
explicit Avr8TargetConfig(const TargetConfig& targetConfig);
private:
static inline auto debugPhysicalInterfacesByConfigName = std::map<std::string, PhysicalInterface>({
{"debugwire", PhysicalInterface::DEBUG_WIRE}, // Deprecated - left here for backwards compatibility
{"debug-wire", PhysicalInterface::DEBUG_WIRE},
{"pdi", PhysicalInterface::PDI},
{"jtag", PhysicalInterface::JTAG},
{"updi", PhysicalInterface::UPDI},
});
};
}

View File

@@ -1,14 +0,0 @@
#include "PhysicalInterface.hpp"
namespace Targets::Microchip::Avr::Avr8Bit
{
std::map<PhysicalInterface, std::string> getPhysicalInterfaceNames() {
return std::map<PhysicalInterface, std::string>({
{PhysicalInterface::ISP, "ISP"},
{PhysicalInterface::DEBUG_WIRE, "debugWire"},
{PhysicalInterface::PDI, "PDI"},
{PhysicalInterface::JTAG, "JTAG"},
{PhysicalInterface::UPDI, "UPDI"},
});
}
}

View File

@@ -21,7 +21,6 @@ namespace Targets::Microchip::Avr::Avr8Bit::TargetDescription
TargetDescriptionFile::TargetDescriptionFile(const std::string& xmlFilePath)
: Targets::TargetDescription::TargetDescriptionFile(xmlFilePath)
{
this->loadSupportedPhysicalInterfaces();
this->loadPadDescriptors();
this->loadTargetVariants();
this->loadTargetRegisterDescriptors();
@@ -162,22 +161,22 @@ namespace Targets::Microchip::Avr::Avr8Bit::TargetDescription
}
}
const auto& supportedPhysicalInterfaces = this->getSupportedPhysicalInterfaces();
if (
supportedPhysicalInterfaces.contains(PhysicalInterface::DEBUG_WIRE)
|| supportedPhysicalInterfaces.contains(PhysicalInterface::JTAG)
) {
this->loadDebugWireAndJtagTargetParameters(targetParameters);
}
if (supportedPhysicalInterfaces.contains(PhysicalInterface::PDI)) {
this->loadPdiTargetParameters(targetParameters);
}
if (supportedPhysicalInterfaces.contains(PhysicalInterface::UPDI)) {
this->loadUpdiTargetParameters(targetParameters);
}
// const auto& supportedPhysicalInterfaces = this->getSupportedPhysicalInterfaces();
//
// if (
// supportedPhysicalInterfaces.contains(PhysicalInterface::DEBUG_WIRE)
// || supportedPhysicalInterfaces.contains(PhysicalInterface::JTAG)
// ) {
// this->loadDebugWireAndJtagTargetParameters(targetParameters);
// }
//
// if (supportedPhysicalInterfaces.contains(PhysicalInterface::PDI)) {
// this->loadPdiTargetParameters(targetParameters);
// }
//
// if (supportedPhysicalInterfaces.contains(PhysicalInterface::UPDI)) {
// this->loadUpdiTargetParameters(targetParameters);
// }
return targetParameters;
}
@@ -327,23 +326,6 @@ namespace Targets::Microchip::Avr::Avr8Bit::TargetDescription
return this->getFuseBitsDescriptorByName("eesave");
}
void TargetDescriptionFile::loadSupportedPhysicalInterfaces() {
auto interfaceNamesToInterfaces = std::map<std::string, PhysicalInterface>({
{"updi", PhysicalInterface::UPDI},
{"debugwire", PhysicalInterface::DEBUG_WIRE},
{"jtag", PhysicalInterface::JTAG},
{"pdi", PhysicalInterface::PDI},
{"isp", PhysicalInterface::ISP},
});
for (const auto& [interfaceName, interface]: this->interfacesByName) {
const auto interfaceIt = interfaceNamesToInterfaces.find(interfaceName);
if (interfaceIt != interfaceNamesToInterfaces.end()) {
this->supportedPhysicalInterfaces.insert(interfaceIt->second);
}
}
}
void TargetDescriptionFile::loadPadDescriptors() {
const auto portModuleIt = this->modulesMappedByName.find("port");
const auto portModule = (portModuleIt != this->modulesMappedByName.end())

View File

@@ -13,7 +13,6 @@
#include "src/Targets/Microchip/AVR/Fuse.hpp"
#include "src/Targets/Microchip/AVR/AVR8/Family.hpp"
#include "src/Targets/Microchip/AVR/AVR8/PhysicalInterface.hpp"
#include "src/Targets/Microchip/AVR/AVR8/TargetParameters.hpp"
#include "src/Targets/Microchip/AVR/AVR8/PadDescriptor.hpp"
@@ -122,15 +121,6 @@ namespace Targets::Microchip::Avr::Avr8Bit::TargetDescription
*/
[[nodiscard]] std::optional<FuseBitsDescriptor> getEesaveFuseBitsDescriptor() const;
/**
* Returns a set of all supported physical interfaces for debugging.
*
* @return
*/
[[nodiscard]] const auto& getSupportedPhysicalInterfaces() const {
return this->supportedPhysicalInterfaces;
}
/**
* Returns a mapping of all pad descriptors extracted from TDF, mapped by name.
*
@@ -184,7 +174,6 @@ namespace Targets::Microchip::Avr::Avr8Bit::TargetDescription
};
std::string avrFamilyName;
std::set<PhysicalInterface> supportedPhysicalInterfaces;
std::map<std::string, PadDescriptor> padDescriptorsByName;
std::map<int, TargetVariant> targetVariantsById;

View File

@@ -97,6 +97,30 @@ namespace Targets::TargetDescription
return addressSpace->get();
}
std::set<TargetPhysicalInterface> TargetDescriptionFile::getPhysicalInterfaces() const {
static const auto physicalInterfacesByName = BiMap<std::string, TargetPhysicalInterface>({
{"updi", TargetPhysicalInterface::UPDI},
{"debugwire", TargetPhysicalInterface::DEBUG_WIRE},
{"jtag", TargetPhysicalInterface::JTAG},
{"pdi", TargetPhysicalInterface::PDI},
{"isp", TargetPhysicalInterface::ISP},
});
auto output = std::set<TargetPhysicalInterface>();
for (const auto& physicalInterface : this->physicalInterfaces) {
const auto interface = physicalInterfacesByName.valueAt(
StringService::asciiToLower(physicalInterface.name)
);
if (interface.has_value()) {
output.insert(*interface);
}
}
return output;
}
void TargetDescriptionFile::init(const std::string& xmlFilePath) {
auto file = QFile(QString::fromStdString(xmlFilePath));
if (!file.exists()) {

View File

@@ -20,6 +20,7 @@
#include "Pinout.hpp"
#include "src/Targets/TargetFamily.hpp"
#include "src/Targets/TargetPhysicalInterface.hpp"
#include GENERATED_TDF_MAPPING_PATH
@@ -99,6 +100,8 @@ namespace Targets::TargetDescription
) const;
[[nodiscard]] const AddressSpace& getAddressSpace(std::string_view key) const;
[[nodiscard]] std::set<Targets::TargetPhysicalInterface> getPhysicalInterfaces() const;
protected:
std::map<std::string, std::string> deviceAttributesByName;
std::map<std::string, AddressSpace, std::less<void>> addressSpacesByKey;

View File

@@ -0,0 +1,14 @@
#include "TargetPhysicalInterface.hpp"
namespace Targets
{
std::map<TargetPhysicalInterface, std::string> getPhysicalInterfaceNames() {
return std::map<TargetPhysicalInterface, std::string>({
{TargetPhysicalInterface::ISP, "ISP"},
{TargetPhysicalInterface::DEBUG_WIRE, "debugWire"},
{TargetPhysicalInterface::PDI, "PDI"},
{TargetPhysicalInterface::JTAG, "JTAG"},
{TargetPhysicalInterface::UPDI, "UPDI"},
});
}
}

View File

@@ -4,9 +4,9 @@
#include <map>
#include <string>
namespace Targets::Microchip::Avr::Avr8Bit
namespace Targets
{
enum class PhysicalInterface: std::uint8_t
enum class TargetPhysicalInterface: std::uint8_t
{
ISP,
JTAG,
@@ -20,5 +20,5 @@ namespace Targets::Microchip::Avr::Avr8Bit
*
* @return
*/
std::map<PhysicalInterface, std::string> getPhysicalInterfaceNames();
std::map<TargetPhysicalInterface, std::string> getPhysicalInterfaceNames();
}