Decoupled AVR8 physical interface enum from EDBG protocol code
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include "src/Targets/Microchip/AVR/AVR8/PhysicalInterface.hpp"
|
||||||
|
|
||||||
namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||||
{
|
{
|
||||||
struct Avr8EdbgParameter
|
struct Avr8EdbgParameter
|
||||||
@@ -76,14 +78,16 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
|||||||
DEBUGGING = 0x02,
|
DEBUGGING = 0x02,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class Avr8PhysicalInterface: unsigned char
|
static inline auto getAvr8PhysicalInterfaceToIdMapping() {
|
||||||
{
|
using Targets::Microchip::Avr::Avr8Bit::PhysicalInterface;
|
||||||
NONE = 0x00,
|
|
||||||
JTAG = 0x04,
|
return std::map<PhysicalInterface, unsigned char>({
|
||||||
DEBUG_WIRE = 0x05,
|
{PhysicalInterface::DEBUG_WIRE, 0x05},
|
||||||
PDI = 0x06,
|
{PhysicalInterface::PDI, 0x06},
|
||||||
PDI_1W = 0x08,
|
{PhysicalInterface::JTAG, 0x04},
|
||||||
};
|
{PhysicalInterface::UPDI, 0x08},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
enum class Avr8MemoryType: unsigned char
|
enum class Avr8MemoryType: unsigned char
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ std::vector<unsigned char> EdbgAvr8Interface::getParameter(const Avr8EdbgParamet
|
|||||||
void EdbgAvr8Interface::configure(const TargetConfig& targetConfig) {
|
void EdbgAvr8Interface::configure(const TargetConfig& targetConfig) {
|
||||||
auto physicalInterface = targetConfig.jsonObject.find("physicalInterface")->toString().toLower().toStdString();
|
auto physicalInterface = targetConfig.jsonObject.find("physicalInterface")->toString().toLower().toStdString();
|
||||||
|
|
||||||
auto availablePhysicalInterfaces = EdbgAvr8Interface::physicalInterfacesByName;
|
auto availablePhysicalInterfaces = this->getPhysicalInterfacesByName();
|
||||||
|
|
||||||
if (physicalInterface.empty()
|
if (physicalInterface.empty()
|
||||||
|| availablePhysicalInterfaces.find(physicalInterface) == availablePhysicalInterfaces.end()
|
|| availablePhysicalInterfaces.find(physicalInterface) == availablePhysicalInterfaces.end()
|
||||||
@@ -79,13 +79,13 @@ void EdbgAvr8Interface::configure(const TargetConfig& targetConfig) {
|
|||||||
|
|
||||||
auto selectedPhysicalInterface = availablePhysicalInterfaces.find(physicalInterface)->second;
|
auto selectedPhysicalInterface = availablePhysicalInterfaces.find(physicalInterface)->second;
|
||||||
|
|
||||||
if (selectedPhysicalInterface == Avr8PhysicalInterface::DEBUG_WIRE) {
|
if (selectedPhysicalInterface == PhysicalInterface::DEBUG_WIRE) {
|
||||||
Logger::warning("AVR8 debugWire interface selected - the DWEN fuse will need to be enabled");
|
Logger::warning("AVR8 debugWire interface selected - the DWEN fuse will need to be enabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
this->physicalInterface = selectedPhysicalInterface;
|
this->physicalInterface = selectedPhysicalInterface;
|
||||||
|
|
||||||
if (this->physicalInterface == Avr8PhysicalInterface::JTAG && !this->family.has_value()) {
|
if (this->physicalInterface == PhysicalInterface::JTAG && !this->family.has_value()) {
|
||||||
throw InvalidConfig("Cannot use JTAG physical interface with ambiguous target name - please specify the"
|
throw InvalidConfig("Cannot use JTAG physical interface with ambiguous target name - please specify the"
|
||||||
" exact name of the target in your configuration file. See https://bloom.oscillate.io/docs/supported-targets");
|
" exact name of the target in your configuration file. See https://bloom.oscillate.io/docs/supported-targets");
|
||||||
}
|
}
|
||||||
@@ -327,7 +327,7 @@ void EdbgAvr8Interface::init() {
|
|||||||
|
|
||||||
this->setParameter(
|
this->setParameter(
|
||||||
Avr8EdbgParameters::PHYSICAL_INTERFACE,
|
Avr8EdbgParameters::PHYSICAL_INTERFACE,
|
||||||
static_cast<unsigned char>(this->physicalInterface)
|
getAvr8PhysicalInterfaceToIdMapping().at(this->physicalInterface)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -438,7 +438,7 @@ void EdbgAvr8Interface::activate() {
|
|||||||
|
|
||||||
void EdbgAvr8Interface::deactivate() {
|
void EdbgAvr8Interface::deactivate() {
|
||||||
if (this->targetAttached) {
|
if (this->targetAttached) {
|
||||||
if (this->physicalInterface == Avr8PhysicalInterface::DEBUG_WIRE && this->disableDebugWireOnDeactivate) {
|
if (this->physicalInterface == PhysicalInterface::DEBUG_WIRE && this->disableDebugWireOnDeactivate) {
|
||||||
try {
|
try {
|
||||||
this->disableDebugWire();
|
this->disableDebugWire();
|
||||||
Logger::warning("Successfully disabled debugWire on the AVR8 target - this is only temporary - "
|
Logger::warning("Successfully disabled debugWire on the AVR8 target - this is only temporary - "
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
#include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/EdbgInterface.hpp"
|
#include "src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/EdbgInterface.hpp"
|
||||||
#include "src/Targets/Microchip/AVR/Target.hpp"
|
#include "src/Targets/Microchip/AVR/Target.hpp"
|
||||||
#include "src/Targets/Microchip/AVR/AVR8/Family.hpp"
|
#include "src/Targets/Microchip/AVR/AVR8/Family.hpp"
|
||||||
|
#include "src/Targets/Microchip/AVR/AVR8/PhysicalInterface.hpp"
|
||||||
|
|
||||||
namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
||||||
{
|
{
|
||||||
@@ -66,7 +67,8 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
|||||||
* Currently, the AVR8 Generic protocol supports 4 physical interfaces: debugWire, JTAG, PDI and UPDI.
|
* 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.
|
* The desired physical interface must be selected by setting the "AVR8_PHY_PHYSICAL" parameter.
|
||||||
*/
|
*/
|
||||||
Avr8PhysicalInterface physicalInterface = Avr8PhysicalInterface::NONE;
|
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
|
* EDBG-based debug tools require target specific parameters such as memory locations, page sizes and
|
||||||
@@ -123,11 +125,15 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
|||||||
* Users are required to set their desired physical interface in their Bloom configuration. This would take
|
* Users are required to set their desired physical interface in their Bloom configuration. This would take
|
||||||
* the form of a string, so we map the available options to the appropriate enums.
|
* the form of a string, so we map the available options to the appropriate enums.
|
||||||
*/
|
*/
|
||||||
static inline std::map<std::string, Avr8PhysicalInterface> physicalInterfacesByName = {
|
static inline auto getPhysicalInterfacesByName() {
|
||||||
{"debugwire", Avr8PhysicalInterface::DEBUG_WIRE},
|
using Targets::Microchip::Avr::Avr8Bit::PhysicalInterface;
|
||||||
{"pdi", Avr8PhysicalInterface::PDI},
|
|
||||||
{"jtag", Avr8PhysicalInterface::JTAG},
|
return std::map<std::string, PhysicalInterface>({
|
||||||
// {"updi", Avr8PhysicalInterface::PDI_1W}, // Disabled for now - will add support later
|
{"debugwire", PhysicalInterface::DEBUG_WIRE},
|
||||||
|
{"pdi", PhysicalInterface::PDI},
|
||||||
|
{"jtag", PhysicalInterface::JTAG},
|
||||||
|
{"updi", PhysicalInterface::UPDI},
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -136,44 +142,45 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
|||||||
*/
|
*/
|
||||||
static inline auto getConfigVariantsByFamilyAndPhysicalInterface() {
|
static inline auto getConfigVariantsByFamilyAndPhysicalInterface() {
|
||||||
using Targets::Microchip::Avr::Avr8Bit::Family;
|
using Targets::Microchip::Avr::Avr8Bit::Family;
|
||||||
return std::map<Family, std::map<Avr8PhysicalInterface, Avr8ConfigVariant>>({
|
using Targets::Microchip::Avr::Avr8Bit::PhysicalInterface;
|
||||||
|
return std::map<Family, std::map<PhysicalInterface, Avr8ConfigVariant>>({
|
||||||
{
|
{
|
||||||
Family::MEGA,
|
Family::MEGA,
|
||||||
{
|
{
|
||||||
{Avr8PhysicalInterface::JTAG, Avr8ConfigVariant::MEGAJTAG},
|
{PhysicalInterface::JTAG, Avr8ConfigVariant::MEGAJTAG},
|
||||||
{Avr8PhysicalInterface::DEBUG_WIRE, Avr8ConfigVariant::DEBUG_WIRE},
|
{PhysicalInterface::DEBUG_WIRE, Avr8ConfigVariant::DEBUG_WIRE},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Family::TINY,
|
Family::TINY,
|
||||||
{
|
{
|
||||||
{Avr8PhysicalInterface::JTAG, Avr8ConfigVariant::MEGAJTAG},
|
{PhysicalInterface::JTAG, Avr8ConfigVariant::MEGAJTAG},
|
||||||
{Avr8PhysicalInterface::DEBUG_WIRE, Avr8ConfigVariant::DEBUG_WIRE},
|
{PhysicalInterface::DEBUG_WIRE, Avr8ConfigVariant::DEBUG_WIRE},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Family::XMEGA,
|
Family::XMEGA,
|
||||||
{
|
{
|
||||||
{Avr8PhysicalInterface::JTAG, Avr8ConfigVariant::XMEGA},
|
{PhysicalInterface::JTAG, Avr8ConfigVariant::XMEGA},
|
||||||
{Avr8PhysicalInterface::PDI, Avr8ConfigVariant::XMEGA},
|
{PhysicalInterface::PDI, Avr8ConfigVariant::XMEGA},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Family::DA,
|
Family::DA,
|
||||||
{
|
{
|
||||||
{Avr8PhysicalInterface::PDI_1W, Avr8ConfigVariant::UPDI},
|
{PhysicalInterface::UPDI, Avr8ConfigVariant::UPDI},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Family::DB,
|
Family::DB,
|
||||||
{
|
{
|
||||||
{Avr8PhysicalInterface::PDI_1W, Avr8ConfigVariant::UPDI},
|
{PhysicalInterface::UPDI, Avr8ConfigVariant::UPDI},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
Family::DD,
|
Family::DD,
|
||||||
{
|
{
|
||||||
{Avr8PhysicalInterface::PDI_1W, Avr8ConfigVariant::UPDI},
|
{PhysicalInterface::UPDI, Avr8ConfigVariant::UPDI},
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -211,10 +218,11 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
|||||||
* variant. Users are required to specify the exact target name in their config, when using the JTAG
|
* 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.
|
* physical interface. That way, this->family will be set by the time resolveConfigVariant() is called.
|
||||||
*/
|
*/
|
||||||
static std::map<Avr8PhysicalInterface, Avr8ConfigVariant> physicalInterfacesToConfigVariants = {
|
using Targets::Microchip::Avr::Avr8Bit::PhysicalInterface;
|
||||||
{Avr8PhysicalInterface::DEBUG_WIRE, Avr8ConfigVariant::DEBUG_WIRE},
|
static std::map<PhysicalInterface, Avr8ConfigVariant> physicalInterfacesToConfigVariants = {
|
||||||
{Avr8PhysicalInterface::PDI, Avr8ConfigVariant::XMEGA},
|
{PhysicalInterface::DEBUG_WIRE, Avr8ConfigVariant::DEBUG_WIRE},
|
||||||
{Avr8PhysicalInterface::PDI_1W, Avr8ConfigVariant::UPDI},
|
{PhysicalInterface::PDI, Avr8ConfigVariant::XMEGA},
|
||||||
|
{PhysicalInterface::UPDI, Avr8ConfigVariant::UPDI},
|
||||||
};
|
};
|
||||||
|
|
||||||
if (physicalInterfacesToConfigVariants.contains(this->physicalInterface)) {
|
if (physicalInterfacesToConfigVariants.contains(this->physicalInterface)) {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "Avr8GenericResponseFrame.hpp"
|
#include "Avr8GenericResponseFrame.hpp"
|
||||||
#include "src/Targets/Microchip/AVR/Target.hpp"
|
#include "src/Targets/Microchip/AVR/AVR8/PhysicalInterface.hpp"
|
||||||
|
|
||||||
namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrames::Avr8Generic
|
namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrames::Avr8Generic
|
||||||
{
|
{
|
||||||
@@ -11,25 +11,28 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr::ResponseFrame
|
|||||||
GetDeviceId() = default;
|
GetDeviceId() = default;
|
||||||
explicit GetDeviceId(const std::vector<AvrResponse>& AvrResponses): Avr8GenericResponseFrame(AvrResponses) {}
|
explicit GetDeviceId(const std::vector<AvrResponse>& AvrResponses): Avr8GenericResponseFrame(AvrResponses) {}
|
||||||
|
|
||||||
Targets::Microchip::Avr::TargetSignature extractSignature(Avr8PhysicalInterface physicalInterface) {
|
Targets::Microchip::Avr::TargetSignature extractSignature(
|
||||||
|
Targets::Microchip::Avr::Avr8Bit::PhysicalInterface physicalInterface
|
||||||
|
) {
|
||||||
|
using Targets::Microchip::Avr::Avr8Bit::PhysicalInterface;
|
||||||
auto payloadData = this->getPayloadData();
|
auto payloadData = this->getPayloadData();
|
||||||
|
|
||||||
switch (physicalInterface) {
|
switch (physicalInterface) {
|
||||||
case Avr8PhysicalInterface::DEBUG_WIRE: {
|
case PhysicalInterface::DEBUG_WIRE: {
|
||||||
/*
|
/*
|
||||||
* When using the DebugWire physical interface, the get device ID command will return
|
* When using the DebugWire physical interface, the get device ID command will return
|
||||||
* four bytes, where the first can be ignored.
|
* four bytes, where the first can be ignored.
|
||||||
*/
|
*/
|
||||||
return Targets::Microchip::Avr::TargetSignature(payloadData[1], payloadData[2], payloadData[3]);
|
return Targets::Microchip::Avr::TargetSignature(payloadData[1], payloadData[2], payloadData[3]);
|
||||||
}
|
}
|
||||||
case Avr8PhysicalInterface::PDI:
|
case PhysicalInterface::PDI:
|
||||||
case Avr8PhysicalInterface::PDI_1W: {
|
case PhysicalInterface::UPDI: {
|
||||||
/*
|
/*
|
||||||
* When using the PDI physical interface, the signature is returned in LSB format.
|
* When using the PDI physical interface, the signature is returned in LSB format.
|
||||||
*/
|
*/
|
||||||
return Targets::Microchip::Avr::TargetSignature(payloadData[3], payloadData[2], payloadData[1]);
|
return Targets::Microchip::Avr::TargetSignature(payloadData[3], payloadData[2], payloadData[1]);
|
||||||
}
|
}
|
||||||
case Avr8PhysicalInterface::JTAG: {
|
case PhysicalInterface::JTAG: {
|
||||||
/*
|
/*
|
||||||
* When using the JTAG interface, the get device ID command returns a 32 bit JTAG ID. This takes
|
* When using the JTAG interface, the get device ID command returns a 32 bit JTAG ID. This takes
|
||||||
* the following form:
|
* the following form:
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include "Avr8.hpp"
|
#include "Avr8.hpp"
|
||||||
#include "PadDescriptor.hpp"
|
#include "PadDescriptor.hpp"
|
||||||
|
#include "PhysicalInterface.hpp"
|
||||||
#include "src/Logger/Logger.hpp"
|
#include "src/Logger/Logger.hpp"
|
||||||
#include "src/Exceptions/InvalidConfig.hpp"
|
#include "src/Exceptions/InvalidConfig.hpp"
|
||||||
#include "src/Targets/TargetRegister.hpp"
|
#include "src/Targets/TargetRegister.hpp"
|
||||||
|
|||||||
12
src/Targets/Microchip/AVR/AVR8/PhysicalInterface.hpp
Normal file
12
src/Targets/Microchip/AVR/AVR8/PhysicalInterface.hpp
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
namespace Bloom::Targets::Microchip::Avr::Avr8Bit
|
||||||
|
{
|
||||||
|
enum class PhysicalInterface: int
|
||||||
|
{
|
||||||
|
JTAG,
|
||||||
|
DEBUG_WIRE,
|
||||||
|
PDI,
|
||||||
|
UPDI,
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user