Aligning and paging flash memory access on XMEGA targets, in the EDBG driver - resolves a number of bugs and removes the concern of exceeding restrictions enforced by the EDBG tool.
This commit is contained in:
@@ -592,8 +592,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
|||||||
avr8MemoryType = this->programmingModeEnabled ? Avr8MemoryType::FLASH_PAGE : Avr8MemoryType::SPM;
|
avr8MemoryType = this->programmingModeEnabled ? Avr8MemoryType::FLASH_PAGE : Avr8MemoryType::SPM;
|
||||||
|
|
||||||
} else if (
|
} else if (
|
||||||
this->configVariant == Avr8ConfigVariant::XMEGA
|
this->configVariant == Avr8ConfigVariant::XMEGA || this->configVariant == Avr8ConfigVariant::UPDI
|
||||||
|| this->configVariant == Avr8ConfigVariant::UPDI
|
|
||||||
) {
|
) {
|
||||||
avr8MemoryType = Avr8MemoryType::APPL_FLASH;
|
avr8MemoryType = Avr8MemoryType::APPL_FLASH;
|
||||||
}
|
}
|
||||||
@@ -647,15 +646,12 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
|||||||
avr8MemoryType = Avr8MemoryType::FLASH_PAGE;
|
avr8MemoryType = Avr8MemoryType::FLASH_PAGE;
|
||||||
|
|
||||||
} else if (this->configVariant == Avr8ConfigVariant::MEGAJTAG) {
|
} else if (this->configVariant == Avr8ConfigVariant::MEGAJTAG) {
|
||||||
avr8MemoryType = Avr8MemoryType::FLASH_PAGE;
|
avr8MemoryType = this->programmingModeEnabled ? Avr8MemoryType::FLASH_PAGE : Avr8MemoryType::SPM;
|
||||||
// TODO: Enable programming mode
|
|
||||||
|
|
||||||
} else if (this->configVariant == Avr8ConfigVariant::XMEGA
|
} else if (
|
||||||
|| this->configVariant == Avr8ConfigVariant::UPDI) {
|
this->configVariant == Avr8ConfigVariant::XMEGA || this->configVariant == Avr8ConfigVariant::UPDI
|
||||||
|
) {
|
||||||
avr8MemoryType = Avr8MemoryType::APPL_FLASH;
|
avr8MemoryType = Avr8MemoryType::APPL_FLASH;
|
||||||
|
|
||||||
} else {
|
|
||||||
avr8MemoryType = Avr8MemoryType::SPM;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1348,7 +1344,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
|||||||
return
|
return
|
||||||
memoryType == Avr8MemoryType::FLASH_PAGE
|
memoryType == Avr8MemoryType::FLASH_PAGE
|
||||||
|| memoryType == Avr8MemoryType::SPM
|
|| memoryType == Avr8MemoryType::SPM
|
||||||
|| (memoryType == Avr8MemoryType::APPL_FLASH && this->configVariant == Avr8ConfigVariant::UPDI)
|
|| memoryType == Avr8MemoryType::APPL_FLASH
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1366,6 +1362,9 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
|||||||
if (this->configVariant == Avr8ConfigVariant::UPDI) {
|
if (this->configVariant == Avr8ConfigVariant::UPDI) {
|
||||||
// For UPDI sessions, memory access via the APPL_FLASH must be word aligned.
|
// For UPDI sessions, memory access via the APPL_FLASH must be word aligned.
|
||||||
alignTo = 2;
|
alignTo = 2;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
alignTo = this->targetParameters.flashPageSize.value();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1403,6 +1402,9 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
|||||||
if (this->configVariant == Avr8ConfigVariant::UPDI) {
|
if (this->configVariant == Avr8ConfigVariant::UPDI) {
|
||||||
// For UPDI sessions, memory access via the APPL_FLASH must be word aligned.
|
// For UPDI sessions, memory access via the APPL_FLASH must be word aligned.
|
||||||
alignTo = 2;
|
alignTo = 2;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
alignTo = this->targetParameters.flashPageSize.value();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1494,8 +1496,8 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == Avr8MemoryType::FLASH_PAGE) {
|
if (type == Avr8MemoryType::FLASH_PAGE || type == Avr8MemoryType::APPL_FLASH) {
|
||||||
// With the FLASH_PAGE memory type, we can only read one page at a time.
|
// With the FLASH_PAGE and APPL_FLASH memory types, we can only read one page at a time.
|
||||||
const auto pageSize = this->targetParameters.flashPageSize.value();
|
const auto pageSize = this->targetParameters.flashPageSize.value();
|
||||||
|
|
||||||
if (bytes > pageSize) {
|
if (bytes > pageSize) {
|
||||||
@@ -1545,7 +1547,7 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
|||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type != Avr8MemoryType::FLASH_PAGE && type != Avr8MemoryType::SPM) {
|
if (type != Avr8MemoryType::FLASH_PAGE && type != Avr8MemoryType::SPM && type != Avr8MemoryType::APPL_FLASH) {
|
||||||
/*
|
/*
|
||||||
* EDBG AVR8 debug tools behave in a really weird way when responding with more than two packets
|
* EDBG AVR8 debug tools behave in a really weird way when responding with more than two packets
|
||||||
* for a single read (non-flash) memory command. The data they return in this case appears to be of little
|
* for a single read (non-flash) memory command. The data they return in this case appears to be of little
|
||||||
@@ -1622,8 +1624,8 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == Avr8MemoryType::FLASH_PAGE) {
|
if (type == Avr8MemoryType::FLASH_PAGE || type == Avr8MemoryType::APPL_FLASH) {
|
||||||
// With the FLASH_PAGE memory type, we can only write one page at a time.
|
// With the FLASH_PAGE and APPL_FLASH memory type, we can only write one page at a time.
|
||||||
const auto pageSize = this->targetParameters.flashPageSize.value();
|
const auto pageSize = this->targetParameters.flashPageSize.value();
|
||||||
|
|
||||||
if (bytes > pageSize) {
|
if (bytes > pageSize) {
|
||||||
|
|||||||
Reference in New Issue
Block a user