Perform an entire chip erase for UPDI targets, in preparation for programming

This commit is contained in:
Nav
2022-06-04 15:18:53 +01:00
parent 1c92a02950
commit 8061a349fc
5 changed files with 55 additions and 39 deletions

View File

@@ -720,16 +720,18 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
return this->writeMemory(avr8MemoryType, startAddress, buffer);
}
void EdbgAvr8Interface::eraseProgramMemorySection(ProgramMemorySection section) {
if (this->configVariant != Avr8ConfigVariant::XMEGA) {
throw Exception("AVR8 erase command not supported for non-XMEGA config variants.");
void EdbgAvr8Interface::eraseProgramMemory(std::optional<Avr8Bit::ProgramMemorySection> section) {
if (this->configVariant == Avr8ConfigVariant::DEBUG_WIRE) {
throw Exception("AVR8 erase command not supported for debugWire config variant.");
}
auto response = this->edbgInterface.sendAvrCommandFrameAndWaitForResponseFrame(
EraseMemory(
section == ProgramMemorySection::BOOT
? Avr8EraseMemoryMode::BOOT_SECTION
: Avr8EraseMemoryMode::APPLICATION_SECTION
section.has_value()
? section == ProgramMemorySection::BOOT
? Avr8EraseMemoryMode::BOOT_SECTION
: Avr8EraseMemoryMode::APPLICATION_SECTION
: Avr8EraseMemoryMode::CHIP
)
);

View File

@@ -243,11 +243,13 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr
) override;
/**
* Issues the "Erase" command to erase a particular section of program memory.
* Issues the "Erase" command to erase a particular section of program memory, or the entire chip.
*
* @param section
*/
void eraseProgramMemorySection(Targets::Microchip::Avr::Avr8Bit::ProgramMemorySection section) override;
void eraseProgramMemory(
std::optional<Targets::Microchip::Avr::Avr8Bit::ProgramMemorySection> section = std::nullopt
) override;
/**
* Returns the current state of the target.