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 1d5eb1cd..9bffb3a1 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.cpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.cpp @@ -570,6 +570,13 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr std::uint32_t bytes, const std::set& excludedAddressRanges ) { + if ( + this->programmingModeEnabled + && (memoryType == TargetMemoryType::RAM || memoryType == TargetMemoryType::EEPROM) + ) { + throw Exception("Cannot access RAM or EEPROM when programming mode is enabled"); + } + auto avr8MemoryType = Avr8MemoryType::SRAM; switch (memoryType) { @@ -581,14 +588,14 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr if (this->configVariant == Avr8ConfigVariant::DEBUG_WIRE) { avr8MemoryType = Avr8MemoryType::FLASH_PAGE; + } else if (this->configVariant == Avr8ConfigVariant::MEGAJTAG) { + avr8MemoryType = this->programmingModeEnabled ? Avr8MemoryType::FLASH_PAGE : Avr8MemoryType::SPM; + } else if ( this->configVariant == Avr8ConfigVariant::XMEGA || this->configVariant == Avr8ConfigVariant::UPDI ) { avr8MemoryType = Avr8MemoryType::APPL_FLASH; - - } else { - avr8MemoryType = Avr8MemoryType::SPM; } break; }