diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.cpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.cpp index 85ab3b3f..dc0d5c3b 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.cpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.cpp @@ -1027,6 +1027,10 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr throw DeviceInitializationFailure("Missing required parameter: NVM_BASE"); } + if (!this->targetParameters.mcuModuleBaseAddress.has_value()) { + throw DeviceInitializationFailure("Missing required parameter: SIGNATURE_OFFSET (MCU module base address)"); + } + Logger::debug("Setting APPL_BASE_ADDR AVR8 parameter"); this->setParameter( Avr8EdbgParameters::DEVICE_XMEGA_APPL_BASE_ADDR, @@ -1110,6 +1114,11 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr Avr8EdbgParameters::DEVICE_XMEGA_NVM_BASE, this->targetParameters.nvmModuleBaseAddress.value() ); + + Logger::debug("Setting SIGNATURE_OFFSET AVR8 parameter"); + this->setParameter( + Avr8EdbgParameters::DEVICE_XMEGA_SIGNATURE_OFFSET, + this->targetParameters.mcuModuleBaseAddress.value() ); } diff --git a/src/Targets/Microchip/AVR/AVR8/TargetDescription/TargetDescriptionFile.cpp b/src/Targets/Microchip/AVR/AVR8/TargetDescription/TargetDescriptionFile.cpp index 3561975f..74f80ea8 100644 --- a/src/Targets/Microchip/AVR/AVR8/TargetDescription/TargetDescriptionFile.cpp +++ b/src/Targets/Microchip/AVR/AVR8/TargetDescription/TargetDescriptionFile.cpp @@ -1230,6 +1230,18 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit::TargetDescription } } } + + if (peripheralModules.contains("mcu")) { + const auto& mcuModule = peripheralModules.at("mcu"); + + if (mcuModule.instancesMappedByName.contains("mcu")) { + const auto& mcuInstance = mcuModule.instancesMappedByName.at("mcu"); + + if (mcuInstance.registerGroupsMappedByName.contains("mcu")) { + targetParameters.mcuModuleBaseAddress = mcuInstance.registerGroupsMappedByName.at("mcu").offset; + } + } + } } } diff --git a/src/Targets/Microchip/AVR/AVR8/TargetParameters.hpp b/src/Targets/Microchip/AVR/AVR8/TargetParameters.hpp index 3c60444e..1dec1819 100644 --- a/src/Targets/Microchip/AVR/AVR8/TargetParameters.hpp +++ b/src/Targets/Microchip/AVR/AVR8/TargetParameters.hpp @@ -53,6 +53,7 @@ namespace Bloom::Targets::Microchip::Avr::Avr8Bit std::optional userSignaturesPdiOffset; std::optional productSignaturesPdiOffset; std::optional nvmModuleBaseAddress; + std::optional mcuModuleBaseAddress; // UPDI specific target params std::optional ocdModuleAddress;