Perform an entire chip erase for UPDI targets, in preparation for programming
This commit is contained in:
@@ -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
|
||||
)
|
||||
);
|
||||
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
#include <cstdint>
|
||||
#include <set>
|
||||
#include <optional>
|
||||
|
||||
#include "src/Targets/Microchip/AVR/AVR8/Avr8TargetConfig.hpp"
|
||||
|
||||
@@ -196,11 +197,14 @@ namespace Bloom::DebugToolDrivers::TargetInterfaces::Microchip::Avr::Avr8
|
||||
) = 0;
|
||||
|
||||
/**
|
||||
* Should erase a particular program memory section.
|
||||
* Should erase the target's entire program memory, or a specific section where applicable.
|
||||
*
|
||||
* @param section
|
||||
* The section to erase, or std::nullopt to erase the entire program memory.
|
||||
*/
|
||||
virtual void eraseProgramMemorySection(Targets::Microchip::Avr::Avr8Bit::ProgramMemorySection section) = 0;
|
||||
virtual void eraseProgramMemory(
|
||||
std::optional<Targets::Microchip::Avr::Avr8Bit::ProgramMemorySection> section = std::nullopt
|
||||
) = 0;
|
||||
|
||||
/**
|
||||
* Should obtain the current target state.
|
||||
|
||||
Reference in New Issue
Block a user