From d7d1f71aacf0d66eb7cd12c9153d865520f3ea8d Mon Sep 17 00:00:00 2001 From: Nav Date: Wed, 19 Feb 2025 00:18:19 +0000 Subject: [PATCH] Corrected potential issue with delta programming on some AVR8 debugWIRE targets --- .../Microchip/Protocols/Edbg/Avr/Avr8Generic.hpp | 1 + .../Protocols/Edbg/Avr/EdbgAvr8Interface.cpp | 6 ++++++ .../Avr8Generic/DebugWireJtagParameters.cpp | 11 ++++++++--- .../Avr8Generic/DebugWireJtagParameters.hpp | 1 + 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/DebugToolDrivers/Microchip/Protocols/Edbg/Avr/Avr8Generic.hpp b/src/DebugToolDrivers/Microchip/Protocols/Edbg/Avr/Avr8Generic.hpp index ec293e70..6cfd9008 100644 --- a/src/DebugToolDrivers/Microchip/Protocols/Edbg/Avr/Avr8Generic.hpp +++ b/src/DebugToolDrivers/Microchip/Protocols/Edbg/Avr/Avr8Generic.hpp @@ -36,6 +36,7 @@ namespace DebugToolDrivers::Microchip::Protocols::Edbg::Avr static constexpr Avr8EdbgParameter DEVICE_FLASH_PAGE_SIZE = {0x02, 0x00}; static constexpr Avr8EdbgParameter DEVICE_FLASH_SIZE = {0x02, 0x02}; static constexpr Avr8EdbgParameter DEVICE_OCD_REVISION = {0x02, 0x13}; + static constexpr Avr8EdbgParameter DEVICE_PAGE_BUFFERS_PER_FLASH_BLOCK = {0x02, 0x14}; static constexpr Avr8EdbgParameter DEVICE_OCD_DATA_REGISTER = {0x02, 0x18}; static constexpr Avr8EdbgParameter DEVICE_SPMCR_REGISTER = {0x02, 0x1D}; static constexpr Avr8EdbgParameter DEVICE_OSCCAL_ADDR = {0x02, 0x1E}; diff --git a/src/DebugToolDrivers/Microchip/Protocols/Edbg/Avr/EdbgAvr8Interface.cpp b/src/DebugToolDrivers/Microchip/Protocols/Edbg/Avr/EdbgAvr8Interface.cpp index f6266dae..458464df 100644 --- a/src/DebugToolDrivers/Microchip/Protocols/Edbg/Avr/EdbgAvr8Interface.cpp +++ b/src/DebugToolDrivers/Microchip/Protocols/Edbg/Avr/EdbgAvr8Interface.cpp @@ -999,6 +999,12 @@ namespace DebugToolDrivers::Microchip::Protocols::Edbg::Avr Logger::debug("Setting OCD_REVISION AVR8 device parameter"); this->setParameter(Avr8EdbgParameters::DEVICE_OCD_REVISION, parameters.ocdRevision); + Logger::debug("Setting DEVICE_PAGE_BUFFERS_PER_FLASH_BLOCK AVR8 device parameter"); + this->setParameter( + Avr8EdbgParameters::DEVICE_PAGE_BUFFERS_PER_FLASH_BLOCK, + parameters.buffersPerFlashPage.value_or(0x01) + ); + Logger::debug("Setting OCD_DATA_REGISTER AVR8 device parameter"); this->setParameter(Avr8EdbgParameters::DEVICE_OCD_DATA_REGISTER, parameters.ocdDataRegisterAddress); diff --git a/src/DebugToolDrivers/Microchip/Protocols/Edbg/Avr/Parameters/Avr8Generic/DebugWireJtagParameters.cpp b/src/DebugToolDrivers/Microchip/Protocols/Edbg/Avr/Parameters/Avr8Generic/DebugWireJtagParameters.cpp index 31096c11..5ea60793 100644 --- a/src/DebugToolDrivers/Microchip/Protocols/Edbg/Avr/Parameters/Avr8Generic/DebugWireJtagParameters.cpp +++ b/src/DebugToolDrivers/Microchip/Protocols/Edbg/Avr/Parameters/Avr8Generic/DebugWireJtagParameters.cpp @@ -22,9 +22,9 @@ namespace DebugToolDrivers::Microchip::Protocols::Edbg::Avr::Parameters::Avr8Gen "boot_section_options.boot_section_1" ); if (firstBootSectionOptionGroup.has_value()) { - this->bootSectionStartWordAddress = static_cast( - StringService::toUint32(firstBootSectionOptionGroup->get().getProperty("start_address").value) / 2 - ); + this->bootSectionStartWordAddress = StringService::toUint32( + firstBootSectionOptionGroup->get().getProperty("start_address").value + ) / 2; } this->ramStartAddress = static_cast(ramMemorySegment.startAddress); @@ -35,6 +35,11 @@ namespace DebugToolDrivers::Microchip::Protocols::Edbg::Avr::Parameters::Avr8Gen this->ocdRevision = StringService::toUint8(ocdPropertyGroup.getProperty("ocd_revision").value); this->ocdDataRegisterAddress = StringService::toUint8(ocdPropertyGroup.getProperty("ocd_datareg").value); + const auto buffersPerFlashPageProperty = ocdPropertyGroup.tryGetProperty("buffers_per_flash_page"); + if (buffersPerFlashPageProperty.has_value()) { + this->buffersPerFlashPage = StringService::toUint8(buffersPerFlashPageProperty->get().value); + } + const auto eepromPeripheralDescriptor = targetDescriptionFile.getTargetPeripheralDescriptor("eeprom"); const auto& eepromRegisterGroupDescriptor = eepromPeripheralDescriptor.getRegisterGroupDescriptor("eeprom"); diff --git a/src/DebugToolDrivers/Microchip/Protocols/Edbg/Avr/Parameters/Avr8Generic/DebugWireJtagParameters.hpp b/src/DebugToolDrivers/Microchip/Protocols/Edbg/Avr/Parameters/Avr8Generic/DebugWireJtagParameters.hpp index 6169cdbb..7aa5116a 100644 --- a/src/DebugToolDrivers/Microchip/Protocols/Edbg/Avr/Parameters/Avr8Generic/DebugWireJtagParameters.hpp +++ b/src/DebugToolDrivers/Microchip/Protocols/Edbg/Avr/Parameters/Avr8Generic/DebugWireJtagParameters.hpp @@ -23,6 +23,7 @@ namespace DebugToolDrivers::Microchip::Protocols::Edbg::Avr::Parameters::Avr8Gen std::uint8_t eepromPageSize; std::uint8_t ocdRevision; std::uint8_t ocdDataRegisterAddress; + std::optional buffersPerFlashPage; std::uint8_t eearAddressHigh; std::uint8_t eearAddressLow; std::uint8_t eedrAddress;