From 1e68da229bbab58314b7a2b3d80adbf9a63dc89f Mon Sep 17 00:00:00 2001 From: stefanrueger Date: Wed, 22 Jul 2026 08:30:09 +0200 Subject: [PATCH] Fix prog_enabled clearance prog_enabled should only be cleared once there is evidence that leave programming has actually worked. --- src/jtagmkII.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/jtagmkII.c b/src/jtagmkII.c index e17af32a..3c079692 100644 --- a/src/jtagmkII.c +++ b/src/jtagmkII.c @@ -1093,8 +1093,6 @@ static int jtagmkII_program_disable(const PROGRAMMER *pgm) { c = resp[0]; mmt_free(resp); if(c != RSP_OK) { - my.recently_written = 0; - my.prog_enabled = 0; /* * The JTAG ICE mkII couples leaving progmode with re-attaching the * on-chip debug system; on a part with the OCDEN fuse unprogrammed that @@ -1103,6 +1101,8 @@ static int jtagmkII_program_disable(const PROGRAMMER *pgm) { * is only an error if the reset fails too. */ if(jtagmkII_reset(pgm, 0x01) >= 0) { + my.recently_written = 0; + my.prog_enabled = 0; pmsg_notice("leave progmode declined by ICE (%s), target reset and running; " "this is expected when the OCDEN fuse is unprogrammed\n", jtagmkII_get_rc(pgm, c)); return 0;