Added EEPROM_PAGE EDBG memory type and aligned both EEPROM_PAGE and EEPROM_ATOMIC memory types

This commit is contained in:
Nav
2022-12-11 23:34:20 +00:00
parent a0421ce3ff
commit 131f1aa249
2 changed files with 32 additions and 7 deletions

View File

@@ -139,6 +139,12 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
*/
EEPROM_ATOMIC = 0xC4,
/**
* The EEPROM_PAGE memory type can be used to read and write to EEPROM whilst the target is in
* programming mode.
*/
EEPROM_PAGE = 0xB1,
/**
* The FLASH_PAGE memory type can be used to read and write full flash pages on the target.
*

View File

@@ -624,10 +624,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
TargetMemorySize bytes,
const std::set<Targets::TargetMemoryAddressRange>& excludedAddressRanges
) {
if (
this->programmingModeEnabled
&& (memoryType == TargetMemoryType::RAM || memoryType == TargetMemoryType::EEPROM)
) {
if (this->programmingModeEnabled && memoryType == TargetMemoryType::RAM) {
throw Exception("Cannot access RAM or EEPROM when programming mode is enabled");
}
@@ -666,7 +663,10 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
break;
}
case TargetMemoryType::EEPROM: {
avr8MemoryType = Avr8MemoryType::EEPROM;
// For JTAG targets, we must use the EEPROM_PAGE memory type when in programming mode.
avr8MemoryType = (this->configVariant == Avr8ConfigVariant::MEGAJTAG && this->programmingModeEnabled)
? Avr8MemoryType::EEPROM_PAGE
: Avr8MemoryType::EEPROM;
}
default: {
break;
@@ -1535,6 +1535,8 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|| memoryType == Avr8MemoryType::SPM
|| memoryType == Avr8MemoryType::APPL_FLASH
|| memoryType == Avr8MemoryType::BOOT_FLASH
|| memoryType == Avr8MemoryType::EEPROM_ATOMIC
|| memoryType == Avr8MemoryType::EEPROM_PAGE
;
}
@@ -1553,6 +1555,13 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
alignTo = this->targetParameters.flashPageSize.value();
}
if (
memoryType == Avr8MemoryType::EEPROM_ATOMIC
|| memoryType == Avr8MemoryType::EEPROM_PAGE
) {
alignTo = this->targetParameters.eepromPageSize.value();
}
if (this->maximumMemoryAccessSizePerRequest.has_value() && alignTo > this->maximumMemoryAccessSizePerRequest) {
throw Exception(
"Cannot align memory address - alignment size exceeds the maximum memory access size per request."
@@ -1583,6 +1592,13 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
alignTo = this->targetParameters.flashPageSize.value();
}
if (
memoryType == Avr8MemoryType::EEPROM_ATOMIC
|| memoryType == Avr8MemoryType::EEPROM_PAGE
) {
alignTo = this->targetParameters.eepromPageSize.value();
}
if ((bytes % alignTo) != 0) {
return static_cast<TargetMemorySize>(std::ceil(
static_cast<float>(bytes) / static_cast<float>(alignTo)
@@ -1603,8 +1619,11 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
return this->targetParameters.flashPageSize.value();
}
if (memoryType == Avr8MemoryType::EEPROM_ATOMIC) {
// This EEPROM memory type requires single page access.
if (
memoryType == Avr8MemoryType::EEPROM_ATOMIC
|| memoryType == Avr8MemoryType::EEPROM_PAGE
) {
// These EEPROM memory types requires single page access.
return this->targetParameters.eepromPageSize.value();
}