[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[avr-gcc-list] [PATCH] avarice: debugWire: JTAG ICE: Cannot synchonise
From: |
Shaun Jackman |
Subject: |
[avr-gcc-list] [PATCH] avarice: debugWire: JTAG ICE: Cannot synchonise |
Date: |
Sun, 8 Jul 2007 11:12:38 -0600 |
This bug is caused by using debugWire. It manifests itself using both the
JTAG ICE mkII and the AVR Dragon.
The attached patch fixes a clear bug in jtag2bp.cc.
The JTAG ICE mkII and Dragon do not respond correctly to the CMND_RESET
command while in debugWire mode. The command always times out the
first time sending it. When resending the command, sometimes the
debugger will ack (RSP_OK) the command, sometimes it will repeatedly
send EVT_BREAK responses instead, never acking the CMND_RESET command.
I opted to send CMND_FORCED_STOP and CMND_WRITE_PC(0) when using
debugWire instead of CMND_RESET. This solution seems to work, although
other equally valid solutions surely exist.
I'm able to debug using avarice with GDB and an AVR Dragon and
debugWire now! I haven't yet tested breakpoints...
Cheers,
Shaun
2007-07-08 Shaun Jackman <address@hidden>
* src/jtag2bp.cc (layoutBreakpoints) <useDebugWire>: Bug fix.
GDB continue command would hang when using debugWire.
* src/jtag2io.cc (recvFrame): Correctly report a timeout.
* src/jtag2run.cc (resetProgram): The JTAG ICE mkII and Dragon
do not respond correctly to the CMND_RESET command while in
debugWire mode. Send CMND_FORCED_STOP and CMND_WRITE_PC(0)
instead.
Index: src/jtag2bp.cc
===================================================================
RCS file: /cvsroot/avarice/avarice/src/jtag2bp.cc,v
retrieving revision 1.7
diff -u -p -r1.7 jtag2bp.cc
--- src/jtag2bp.cc 21 Feb 2007 20:57:47 -0000 1.7
+++ src/jtag2bp.cc 8 Jul 2007 16:50:54 -0000
@@ -401,7 +401,7 @@ bool jtag2::layoutBreakpoints(void)
if (useDebugWire)
{
int k;
- while (k < (MAX_BREAKPOINTS2 + 1))
+ for (k = 1; k < MAX_BREAKPOINTS2 + 1; k++)
{
remaining_bps[k] = false;
}
Index: src/jtag2io.cc
===================================================================
RCS file: /cvsroot/avarice/avarice/src/jtag2io.cc,v
retrieving revision 1.11
diff -u -p -r1.11 jtag2io.cc
--- src/jtag2io.cc 17 Feb 2007 22:41:46 -0000 1.11
+++ src/jtag2io.cc 8 Jul 2007 16:50:54 -0000
@@ -141,10 +141,12 @@ int jtag2::recvFrame(unsigned char *&msg
break;
} else {
rv = timeout_read(&c, 1, JTAG_RESPONSE_TIMEOUT);
- debugOut("recv: 0x%02x\n", c);
- if (rv == 0)
+ if (rv == 0) {
/* timeout */
+ debugOut("recv: timeout\n");
break;
+ }
+ debugOut("recv: 0x%02x\n", c);
}
checksum ^= c;
Index: src/jtag2run.cc
===================================================================
RCS file: /cvsroot/avarice/avarice/src/jtag2run.cc,v
retrieving revision 1.7
diff -u -p -r1.7 jtag2run.cc
--- src/jtag2run.cc 17 Feb 2007 22:41:46 -0000 1.7
+++ src/jtag2run.cc 8 Jul 2007 16:50:54 -0000
@@ -74,14 +74,21 @@ bool jtag2::setProgramCounter(unsigned l
bool jtag2::resetProgram(void)
{
- uchar cmd[2] = { CMND_RESET, 0x01 };
- uchar *resp;
- int respSize;
+ if (useDebugWire) {
+ /* The JTAG ICE mkII and Dragon do not respond correctly to
+ * the CMND_RESET command while in debugWire mode. */
+ return interruptProgram()
+ && setProgramCounter(0);
+ } else {
+ uchar cmd[2] = { CMND_RESET, 0x01 };
+ uchar *resp;
+ int respSize;
- bool rv = doJtagCommand(cmd, 2, resp, respSize);
- delete [] resp;
+ bool rv = doJtagCommand(cmd, 2, resp, respSize);
+ delete [] resp;
- return rv;
+ return rv;
+ }
}
bool jtag2::interruptProgram(void)
avarice-dw.diff
Description: Text document
- [avr-gcc-list] [PATCH] avarice: debugWire: JTAG ICE: Cannot synchonise,
Shaun Jackman <=