From ee36ee5ab5780ab4af932c8f8a8c54fb2dc2826f Mon Sep 17 00:00:00 2001
From: joerg_wunsch <joerg_wunsch@81a1dc3b-b13d-400b-aceb-764788c761c2>
Date: Thu, 7 Sep 2006 20:42:01 +0000
Subject: [PATCH] Describe how to disable the DWEN fuse.

git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@651 81a1dc3b-b13d-400b-aceb-764788c761c2
---
 ChangeLog        |  5 +++++
 avrdude.1        | 26 ++++++++++++++++++++++++-
 doc/avrdude.texi | 50 ++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 80 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index bd66ec65..8c68ff58 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2006-09-07 Joerg Wunsch <j@uriah.heep.sax.de>
+
+	* avrdude.1: Describe how to disable the DWEN fuse.
+	* doc/avrdude.texi: (Ditto.)
+
 2006-09-07 Joerg Wunsch <j@uriah.heep.sax.de>
 
 	* jtagmkII.c: Translate numerical response codes to strings.
diff --git a/avrdude.1 b/avrdude.1
index 00eb920b..26fb9493 100644
--- a/avrdude.1
+++ b/avrdude.1
@@ -676,7 +676,31 @@ library
 Schematic of programming hardware
 .El
 .\" .Sh EXAMPLES
-.\" .Sh DIAGNOSTICS
+.Sh DIAGNOSTICS
+.Bd -literal
+avrdude: jtagmkII_setparm(): bad response to set parameter command: RSP_FAILED
+avrdude: jtagmkII_getsync(): ISP activation failed, trying debugWire
+avrdude: Target prepared for ISP, signed off.
+avrdude: Please restart avrdude without power-cycling the target.
+.Ed
+.Pp
+If the target AVR has been set up for debugWire mode (i. e. the
+.Em DWEN
+fuse is programmed), normal ISP connection attempts will fail as
+the
+.Em /RESET
+pin is not available.
+When using the JTAG ICE mkII in ISP mode, the message shown indicates
+that
+.Nm
+has guessed this condition, and tried to initiate a debugWire reset
+to the target.
+When successful, this will leave the target AVR in a state where it
+can respond to normal ISP communication again (until the next power
+cycle).
+Typically, the same command is going to be retried again immediately
+afterwards, and will then succeed connecting to the target using
+normal ISP communication.
 .Sh SEE ALSO
 .Xr avr-objcopy 1 ,
 .Xr ppi 4 ,
diff --git a/doc/avrdude.texi b/doc/avrdude.texi
index 01b3f8a6..192c5ce3 100644
--- a/doc/avrdude.texi
+++ b/doc/avrdude.texi
@@ -1938,6 +1938,56 @@ In order to successfully program the EEPROM that way, a prior chip
 erase (with the EESAVE fuse unprogrammed) is required.
 This also applies to the STK500 in high-voltage programming mode.
 
+@item
+Problem: How do I turn off the @var{DWEN} fuse?
+
+Solution: If the @var{DWEN} (debugWire enable) fuse is activated,
+the @var{/RESET} pin is not functional anymore, so normal ISP
+communication cannot be established.
+There are two options to deactivate that fuse again: high-voltage
+programming, or getting the JTAG ICE mkII talk debugWire, and
+prepare the target AVR to accept normal ISP communication again.
+
+The first option requires a programmer that is capable of high-voltage
+programming (either serial or parallel, depending on the AVR device),
+for example the STK500.  In high-voltage programming mode, the
+@var{/RESET} pin is activated initially using a 12 V pulse (thus the
+name @emph{high voltage}), so the target AVR can subsequently be
+reprogrammed, and the @var{DWEN} fuse can be cleared.  Typically, this
+operation cannot be performed while the AVR is located in the target
+circuit though.
+
+The second option requires a JTAG ICE mkII that can talk the debugWire
+protocol.  The ICE needs to be connected to the target using the
+JTAG-to-ISP adapter, so the JTAG ICE mkII can be used as a debugWire
+initiator as well as an ISP programmer.  AVRDUDE will then be activated
+using the @var{jtag2isp} programmer type.  The initial ISP
+communication attempt will fail, but AVRDUDE then tries to iniate a
+debugWire reset.  When successful, this will leave the target AVR in a
+state where it can accept standard ISP communication.  The ICE is then
+signed off (which will make it signing off from the USB as well), so
+AVRDUDE has to be called again afterwards.  This time, standard ISP
+communication can work, so the @var{DWEN} fuse can be cleared.
+
+The pin mapping for the JTAG-to-ISP adapter is:
+
+@table @code
+@item JTAG pin
+ISP pin
+@item 1
+@code{3}
+@item 2
+@code{6}
+@item 3
+@code{1}
+@item 4
+@code{2}
+@item 6
+@code{5}
+@item 9
+@code{4}
+@end table
+
 
 @end itemize