From 7112f90e70e6ca0d0cc8101ec6443a2760c57625 Mon Sep 17 00:00:00 2001 From: Nav Date: Sun, 2 May 2021 15:46:18 +0100 Subject: [PATCH] Disabling breakAfterAttach function for JTAG sessions --- .../EDBG/AVR/EdbgAvr8Interface.cpp | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) 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 0cee410e..a9b6e419 100644 --- a/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.cpp +++ b/src/DebugToolDrivers/Protocols/CMSIS-DAP/VendorSpecific/EDBG/AVR/EdbgAvr8Interface.cpp @@ -367,7 +367,17 @@ void EdbgAvr8Interface::deactivatePhysical() { } void EdbgAvr8Interface::attach() { - auto commandFrame = CommandFrames::Avr8Generic::Attach(true); + /* + * When attaching an ATmega target that is connected via JTAG, we must not set the breakAfterAttach flag, as this + * results in a timeout. + * + * However, in this case the attach command seems to _sometimes_ halt the target anyway, regardless of the + * value of the breakAfterAttach flag. So we still expect a stop event to be received shortly after issuing + * the attach command. + */ + auto commandFrame = CommandFrames::Avr8Generic::Attach( + this->configVariant != Avr8ConfigVariant::MEGAJTAG + ); auto response = this->edbgInterface.sendAvrCommandFrameAndWaitForResponseFrame(commandFrame); if (response.getResponseId() == Avr8ResponseId::FAILED) { @@ -376,8 +386,13 @@ void EdbgAvr8Interface::attach() { this->targetAttached = true; - // Wait for stopped event - this->waitForStoppedEvent(); + try { + // Wait for stopped event + this->waitForStoppedEvent(); + + } catch (const Exception& exception) { + Logger::error("Execution on AVR8 target could not be halted post attach - " + exception.getMessage()); + } } void EdbgAvr8Interface::detach() {