OCDEN fuse bit management

This commit is contained in:
Nav
2023-05-07 16:49:45 +01:00
parent e2f202d5c9
commit 6ae1ef1be2
11 changed files with 253 additions and 19 deletions

View File

@@ -182,6 +182,13 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
* to access general purpose registers when other variants are in use.
*/
REGISTER_FILE = 0xB8,
/**
* The FUSES memory type can be used to read and write AVR fuses in programming mode.
*
* Not available for the debugWire config variant.
*/
FUSES = 0xB2,
};
enum class Avr8ResponseId: unsigned char

View File

@@ -305,10 +305,6 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
}
}
this->stop();
this->clearAllBreakpoints();
this->run();
this->detach();
}
@@ -664,6 +660,11 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
// EEPROM addresses should be in relative form, for XMEGA (PDI) targets
startAddress -= this->targetParameters.eepromStartAddress.value();
}
break;
}
case TargetMemoryType::FUSES: {
avr8MemoryType = Avr8MemoryType::FUSES;
break;
}
default: {
break;
@@ -759,6 +760,11 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
break;
}
}
break;
}
case TargetMemoryType::FUSES: {
avr8MemoryType = Avr8MemoryType::FUSES;
break;
}
default: {
break;
@@ -881,14 +887,6 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
}
this->programmingModeEnabled = false;
if (this->configVariant == Avr8ConfigVariant::MEGAJTAG) {
this->deactivatePhysical();
this->setTargetParameters(this->targetParameters);
this->targetAttached = false;
this->activate();
this->stop();
}
}
std::map<Family, std::map<PhysicalInterface, Avr8ConfigVariant>>
@@ -1687,6 +1685,12 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
TargetMemorySize bytes,
const std::set<TargetMemoryAddress>& excludedAddresses
) {
if (type == Avr8MemoryType::FUSES) {
if (this->configVariant == Avr8ConfigVariant::DEBUG_WIRE) {
throw Exception("Cannot access AVR fuses via the debugWire interface");
}
}
if (!excludedAddresses.empty() && (this->avoidMaskedMemoryRead || type != Avr8MemoryType::SRAM)) {
/*
* Driver-side masked memory read.
@@ -1805,6 +1809,12 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
TargetMemoryAddress startAddress,
const TargetMemoryBuffer& buffer
) {
if (type == Avr8MemoryType::FUSES) {
if (this->configVariant == Avr8ConfigVariant::DEBUG_WIRE) {
throw Exception("Cannot access AVR fuses via the debugWire interface");
}
}
const auto bytes = static_cast<TargetMemorySize>(buffer.size());
if (this->alignmentRequired(type)) {

View File

@@ -13,6 +13,14 @@ namespace Bloom::DebugToolDrivers::TargetInterfaces::Microchip::Avr
/**
* Many AVRs can be programmed via an SPI interface. Some debug tools provide access to this interface via the AVR
* In-System Programming (ISP) protocol.
*
* This interface class is incomplete - it only provides the ability to read the device ID and access AVR fuses and
* lockbit bytes (as that's all we need, for now).
*
* Currently, Bloom only uses the ISP interface for accessing fuses and lockbits on debugWire targets. We can't
* access fuses via the debugWire interface, so we have to use the ISP interface.
*
* @see Avr8::updateDwenFuseBit() for more.
*/
class AvrIspInterface
{