Made physical interface enum more generic (moved out of AVR8-specific context)
This commit is contained in:
@@ -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"
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -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>(
|
||||
|
||||
@@ -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},
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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"},
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
namespace Targets::Microchip::Avr::Avr8Bit
|
||||
{
|
||||
enum class PhysicalInterface: std::uint8_t
|
||||
{
|
||||
ISP,
|
||||
JTAG,
|
||||
DEBUG_WIRE,
|
||||
PDI,
|
||||
UPDI,
|
||||
};
|
||||
|
||||
/**
|
||||
* Returns a mapping of physical interfaces to their marketing name.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
std::map<PhysicalInterface, std::string> getPhysicalInterfaceNames();
|
||||
}
|
||||
@@ -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())
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user