From 5904611928565c135887f851dd7a101358e79fd9 Mon Sep 17 00:00:00 2001 From: MCUdude Date: Sun, 17 Jul 2022 12:51:43 +0200 Subject: [PATCH 1/2] Apply jtagmki patch provided in #443 --- src/jtagmkI.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/jtagmkI.c b/src/jtagmkI.c index 7a97217b..43141263 100644 --- a/src/jtagmkI.c +++ b/src/jtagmkI.c @@ -1058,7 +1058,7 @@ static int jtagmkI_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, { unsigned char cmd[6], datacmd[1 * 2 + 1]; unsigned char resp[1], writedata; - int len, need_progmode = 1; + int len, need_progmode = 1, need_dummy_read = 0; avrdude_message(MSG_NOTICE2, "%s: jtagmkI_write_byte(.., %s, 0x%lx, ...)\n", progname, mem->desc, addr); @@ -1075,17 +1075,22 @@ static int jtagmkI_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, PDATA(pgm)->eeprom_pageaddr = (unsigned long)-1L; } else if (strcmp(mem->desc, "lfuse") == 0) { cmd[1] = MTYPE_FUSE_BITS; + need_dummy_read = 1; addr = 0; } else if (strcmp(mem->desc, "hfuse") == 0) { cmd[1] = MTYPE_FUSE_BITS; + need_dummy_read = 1; addr = 1; } else if (strcmp(mem->desc, "efuse") == 0) { cmd[1] = MTYPE_FUSE_BITS; + need_dummy_read = 1; addr = 2; } else if (strcmp(mem->desc, "lock") == 0) { cmd[1] = MTYPE_LOCK_BITS; + need_dummy_read = 1; } else if (strcmp(mem->desc, "calibration") == 0) { cmd[1] = MTYPE_OSCCAL_BYTE; + need_dummy_read = 1; } else if (strcmp(mem->desc, "signature") == 0) { cmd[1] = MTYPE_SIGN_JTAG; } @@ -1154,6 +1159,8 @@ static int jtagmkI_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, avrdude_message(MSG_NOTICE2, "OK\n"); } + if(need_dummy_read) + jtagmkI_recv(pgm, resp, 1); return 0; } From bfdad78fcba338d0d8815cd98672ab2bb4558662 Mon Sep 17 00:00:00 2001 From: MCUdude Date: Tue, 19 Jul 2022 23:44:22 +0200 Subject: [PATCH 2/2] Add EEPROM dummy read --- src/jtagmkI.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/jtagmkI.c b/src/jtagmkI.c index 43141263..e5d3d5d8 100644 --- a/src/jtagmkI.c +++ b/src/jtagmkI.c @@ -1072,6 +1072,7 @@ static int jtagmkI_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, } else if (strcmp(mem->desc, "eeprom") == 0) { cmd[1] = MTYPE_EEPROM; need_progmode = 0; + need_dummy_read = 1; PDATA(pgm)->eeprom_pageaddr = (unsigned long)-1L; } else if (strcmp(mem->desc, "lfuse") == 0) { cmd[1] = MTYPE_FUSE_BITS;