diff --git a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/Avr8Generic.hpp b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/Avr8Generic.hpp index 232f9c84..7a124660 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/Avr8Generic.hpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/Avr8Generic.hpp @@ -19,6 +19,8 @@ namespace Bloom::DebugToolDrivers::Protocols::CmsisDap::Edbg::Avr constexpr static Avr8EdbgParameter PHYSICAL_INTERFACE {0x01, 0x00}; constexpr static Avr8EdbgParameter DW_CLOCK_DIVISION_FACTOR {0x01, 0x10}; constexpr static Avr8EdbgParameter XMEGA_PDI_CLOCK {0x01, 0x31}; + constexpr static Avr8EdbgParameter MEGA_DEBUG_CLOCK {0x01, 0x21}; + constexpr static Avr8EdbgParameter JTAG_DAISY_CHAIN_SETTINGS {0x01, 0x01}; // debugWire and JTAG parameters constexpr static Avr8EdbgParameter DEVICE_BOOT_START_ADDR {0x02, 0x0A}; 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 c8047103..0cee410e 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.cpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.cpp @@ -84,11 +84,6 @@ void EdbgAvr8Interface::configure(const TargetConfig& targetConfig) { this->physicalInterface = selectedPhysicalInterface; this->configVariant = availableConfigVariants.find(selectedPhysicalInterface)->second; - - if (this->configVariant == Avr8ConfigVariant::XMEGA) { - // Default PDI clock to 4MHz - this->setParameter(Avr8EdbgParameters::XMEGA_PDI_CLOCK, static_cast(0x0FA0)); - } } void EdbgAvr8Interface::setTargetParameters(const Avr8Bit::TargetParameters& config) { @@ -288,6 +283,19 @@ void EdbgAvr8Interface::setTargetParameters(const Avr8Bit::TargetParameters& con } void EdbgAvr8Interface::init() { + if (this->configVariant == Avr8ConfigVariant::XMEGA) { + // Default PDI clock to 4MHz + // TODO: Make this adjustable via a target config parameter + this->setParameter(Avr8EdbgParameters::XMEGA_PDI_CLOCK, static_cast(0x0FA0)); + } + + if (this->configVariant == Avr8ConfigVariant::MEGAJTAG) { + // Default clock value for mega debugging is 2KHz + // TODO: Make this adjustable via a target config parameter + this->setParameter(Avr8EdbgParameters::MEGA_DEBUG_CLOCK, static_cast(0x00C8)); + this->setParameter(Avr8EdbgParameters::JTAG_DAISY_CHAIN_SETTINGS, static_cast(0)); + } + this->setParameter( Avr8EdbgParameters::CONFIG_VARIANT, static_cast(this->configVariant)