diff --git a/src/Targets/Microchip/AVR/AVR8/Avr8.cpp b/src/Targets/Microchip/AVR/AVR8/Avr8.cpp index 92d3ec7b..bdea2c0c 100644 --- a/src/Targets/Microchip/AVR/AVR8/Avr8.cpp +++ b/src/Targets/Microchip/AVR/AVR8/Avr8.cpp @@ -374,6 +374,29 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit this->avr8DebugInterface->writeMemory(memoryType, startAddress, buffer); } + void Avr8::eraseMemory(TargetMemoryType memoryType) { + if (memoryType == TargetMemoryType::FLASH) { + return this->avr8DebugInterface->eraseProgramMemory(); + } + + /* + * Debug tools do not have to support the erasing of RAM or EEPROM memory. We just implement this as a + * write operation. + */ + this->writeMemory( + memoryType, + memoryType == TargetMemoryType::RAM + ? this->targetParameters->ramStartAddress.value() + : this->targetParameters->eepromStartAddress.value(), + TargetMemoryBuffer( + memoryType == TargetMemoryType::RAM + ? this->targetParameters->ramSize.value() + : this->targetParameters->eepromSize.value(), + 0xFF + ) + ); + } + TargetState Avr8::getState() { return this->avr8DebugInterface->getTargetState(); } diff --git a/src/Targets/Microchip/AVR/AVR8/Avr8.hpp b/src/Targets/Microchip/AVR/AVR8/Avr8.hpp index 71849b5a..d4052a31 100644 --- a/src/Targets/Microchip/AVR/AVR8/Avr8.hpp +++ b/src/Targets/Microchip/AVR/AVR8/Avr8.hpp @@ -111,6 +111,7 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit TargetMemoryAddress startAddress, const TargetMemoryBuffer& buffer ) override; + void eraseMemory(TargetMemoryType memoryType) override; TargetState getState() override; diff --git a/src/Targets/Target.hpp b/src/Targets/Target.hpp index 9d0c0c3c..fbffa49c 100644 --- a/src/Targets/Target.hpp +++ b/src/Targets/Target.hpp @@ -258,7 +258,18 @@ namespace Bloom::Targets * @param startAddress * @param buffer */ - virtual void writeMemory(TargetMemoryType memoryType, TargetMemoryAddress startAddress, const TargetMemoryBuffer& buffer) = 0; + virtual void writeMemory( + TargetMemoryType memoryType, + TargetMemoryAddress startAddress, + const TargetMemoryBuffer& buffer + ) = 0; + + /** + * Should erase the entire address range of a given memory type. + * + * @param memoryType + */ + virtual void eraseMemory(TargetMemoryType memoryType) = 0; /** * Should return the current state of the target.