Corrected bug in EDBG driver memory access routines. It was incorrectly using the FUSES memory type when in debug mode (that memory type isn't available in debug mode, only program mode. Was causing a target reset).

This commit is contained in:
Nav
2024-11-06 19:46:27 +00:00
parent 24b41ca420
commit 285fc41c23
3 changed files with 30 additions and 2 deletions

View File

@@ -720,7 +720,20 @@ namespace DebugToolDrivers::Microchip::Protocols::Edbg::Avr
return this->readMemory(Avr8MemoryType::EEPROM, startAddress, bytes, excludedAddresses); return this->readMemory(Avr8MemoryType::EEPROM, startAddress, bytes, excludedAddresses);
} }
if (memorySegmentDescriptor.type == TargetMemorySegmentType::FUSES) { if (
memorySegmentDescriptor.type == TargetMemorySegmentType::FUSES
&& this->programmingModeEnabled
&& this->session.configVariant != Avr8ConfigVariant::DEBUG_WIRE
) {
if (this->session.configVariant == Avr8ConfigVariant::XMEGA) {
return this->readMemory(
Avr8MemoryType::FUSES,
startAddress - this->session.fuseMemorySegment.startAddress,
bytes,
excludedAddresses
);
}
return this->readMemory(Avr8MemoryType::FUSES, startAddress, bytes, excludedAddresses); return this->readMemory(Avr8MemoryType::FUSES, startAddress, bytes, excludedAddresses);
} }
@@ -790,7 +803,20 @@ namespace DebugToolDrivers::Microchip::Protocols::Edbg::Avr
return this->writeMemory(Avr8MemoryType::EEPROM, startAddress, buffer); return this->writeMemory(Avr8MemoryType::EEPROM, startAddress, buffer);
} }
if (memorySegmentDescriptor.type == TargetMemorySegmentType::FUSES) { if (
memorySegmentDescriptor.type == TargetMemorySegmentType::FUSES
&& this->programmingModeEnabled
&& this->session.configVariant != Avr8ConfigVariant::DEBUG_WIRE
) {
if (this->session.configVariant == Avr8ConfigVariant::XMEGA) {
// Fuse addresses should be in relative form, for XMEGA (PDI) targets
return this->writeMemory(
Avr8MemoryType::FUSES,
startAddress - this->session.fuseMemorySegment.startAddress,
buffer
);
}
return this->writeMemory(Avr8MemoryType::FUSES, startAddress, buffer); return this->writeMemory(Avr8MemoryType::FUSES, startAddress, buffer);
} }

View File

@@ -22,6 +22,7 @@ namespace DebugToolDrivers::Microchip::Protocols::Edbg::Avr
, ramMemorySegment(this->targetDescriptionFile.getRamMemorySegment()) , ramMemorySegment(this->targetDescriptionFile.getRamMemorySegment())
, eepromMemorySegment(this->targetDescriptionFile.getEepromMemorySegment()) , eepromMemorySegment(this->targetDescriptionFile.getEepromMemorySegment())
, ioMemorySegment(this->targetDescriptionFile.getIoMemorySegment()) , ioMemorySegment(this->targetDescriptionFile.getIoMemorySegment())
, fuseMemorySegment(this->targetDescriptionFile.getFuseMemorySegment())
, signatureMemorySegment(this->targetDescriptionFile.getSignatureMemorySegment()) , signatureMemorySegment(this->targetDescriptionFile.getSignatureMemorySegment())
, programAppSection(this->programMemorySegment.tryGetSection("app_section")) , programAppSection(this->programMemorySegment.tryGetSection("app_section"))
, programBootSection(this->programMemorySegment.tryGetSection("boot_section")) , programBootSection(this->programMemorySegment.tryGetSection("boot_section"))

View File

@@ -47,6 +47,7 @@ namespace DebugToolDrivers::Microchip::Protocols::Edbg::Avr
const Targets::TargetDescription::MemorySegment& ramMemorySegment; const Targets::TargetDescription::MemorySegment& ramMemorySegment;
const Targets::TargetDescription::MemorySegment& eepromMemorySegment; const Targets::TargetDescription::MemorySegment& eepromMemorySegment;
const Targets::TargetDescription::MemorySegment& ioMemorySegment; const Targets::TargetDescription::MemorySegment& ioMemorySegment;
const Targets::TargetDescription::MemorySegment& fuseMemorySegment;
const Targets::TargetDescription::MemorySegment& signatureMemorySegment; const Targets::TargetDescription::MemorySegment& signatureMemorySegment;
const std::optional< const std::optional<