From bf8d59644aeff69394029533c7b3b26afcf50742 Mon Sep 17 00:00:00 2001 From: Nav Date: Mon, 12 Dec 2022 01:14:56 +0000 Subject: [PATCH] Convert XMEGA addresses to relative form, in EDBG driver --- .../EDBG/AVR/EdbgAvr8Interface.cpp | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.cpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.cpp index 1d7904dc..b9013200 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.cpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.cpp @@ -657,6 +657,11 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr startAddress -= bootSectionStartAddress; } else { + /* + * When using the APPL_FLASH memory type, the address should be relative to the start of the + * application section. + */ + startAddress -= this->targetParameters.appSectionStartAddress.value(); avr8MemoryType = Avr8MemoryType::APPL_FLASH; } } @@ -667,6 +672,11 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr avr8MemoryType = (this->configVariant == Avr8ConfigVariant::MEGAJTAG && this->programmingModeEnabled) ? Avr8MemoryType::EEPROM_PAGE : Avr8MemoryType::EEPROM; + + if (this->configVariant == Avr8ConfigVariant::XMEGA) { + // EEPROM addresses should be in relative form, for XMEGA (PDI) targets + startAddress -= this->targetParameters.eepromStartAddress.value(); + } } default: { break; @@ -728,6 +738,11 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr startAddress -= bootSectionStartAddress; } else { + /* + * When using the APPL_FLASH memory type, the address should be relative to the start of the + * application section. + */ + startAddress -= this->targetParameters.appSectionStartAddress.value(); avr8MemoryType = Avr8MemoryType::APPL_FLASH; } } @@ -738,6 +753,11 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr this->configVariant == Avr8ConfigVariant::XMEGA || this->configVariant == Avr8ConfigVariant::UPDI ? Avr8MemoryType::EEPROM_ATOMIC : Avr8MemoryType::EEPROM; + + if (this->configVariant == Avr8ConfigVariant::XMEGA) { + // EEPROM addresses should be in relative form, for XMEGA (PDI) targets + startAddress -= this->targetParameters.eepromStartAddress.value(); + } } default: { break;