From 033b2ed796ffbf8327ab51be0d6f528c83bbab1a Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Fri, 29 Apr 2022 00:37:28 +0100 Subject: [PATCH 01/14] Treat x bits in .conf SPI commands as 0 --- src/avrpart.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/avrpart.c b/src/avrpart.c index dc6def44..fdff0f78 100644 --- a/src/avrpart.c +++ b/src/avrpart.c @@ -82,11 +82,11 @@ int avr_set_bits(OPCODE * op, unsigned char * cmd) unsigned char mask; for (i=0; i<32; i++) { - if (op->bit[i].type == AVR_CMDBIT_VALUE) { + if (op->bit[i].type == AVR_CMDBIT_VALUE || op->bit[i].type == AVR_CMDBIT_IGNORE) { j = 3 - i / 8; bit = i % 8; mask = 1 << bit; - if (op->bit[i].value) + if (op->bit[i].value && op->bit[i].type == AVR_CMDBIT_VALUE) cmd[j] = cmd[j] | mask; else cmd[j] = cmd[j] & ~mask; From bdb4128de3f63a1fb4abc208ec9bfa90ef3dd676 Mon Sep 17 00:00:00 2001 From: MCUdude Date: Sun, 29 May 2022 13:12:50 +0200 Subject: [PATCH 02/14] Fix JTAG transaction close issue Fixes issue #366 --- src/jtagmkII.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/jtagmkII.c b/src/jtagmkII.c index fc06301c..b1024b53 100644 --- a/src/jtagmkII.c +++ b/src/jtagmkII.c @@ -1840,8 +1840,8 @@ void jtagmkII_close(PROGRAMMER * pgm) avrdude_message(MSG_NOTICE2, "%s: jtagmkII_close()\n", progname); - if (pgm->flag & PGM_FL_IS_PDI) { - /* When in PDI mode, restart target. */ + if (pgm->flag & (PGM_FL_IS_PDI | PGM_FL_IS_JTAG)) { + /* When in PDI or JTAG mode, restart target. */ buf[0] = CMND_GO; avrdude_message(MSG_NOTICE2, "%s: jtagmkII_close(): Sending GO command: ", progname); From bd8c17b35f772978dd12f866e4de569963f27162 Mon Sep 17 00:00:00 2001 From: prchal Date: Tue, 7 Jun 2022 11:50:03 +0200 Subject: [PATCH 03/14] adding support for all Linux baud rates v.2 If optiboot can work at higher bauds, why not avrdude. Versoin 2 of #985. Linux uses the old-style bitmapped version of the Bxxxx macros. --- src/ser_posix.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/ser_posix.c b/src/ser_posix.c index 2c5d45b5..53d8cd15 100644 --- a/src/ser_posix.c +++ b/src/ser_posix.c @@ -76,6 +76,45 @@ static struct baud_mapping baud_lookup_table [] = { #endif #ifdef B230400 { 230400, B230400 }, +#endif +#ifdef B250000 + { 250000, B250000 }, +#endif +#ifdef B460800 + { 460800, B460800 }, +#endif +#ifdef B500000 + { 500000, B500000 }, +#endif +#ifdef B576000 + { 576000, B576000 }, +#endif +#ifdef B921600 + { 921600, B921600 }, +#endif +#ifdef B1000000 + { 1000000, B1000000 }, +#endif +#ifdef B1152000 + { 1152000, B1152000 }, +#endif +#ifdef B1500000 + { 1500000, B1500000 }, +#endif +#ifdef B2000000 + { 2000000, B2000000 }, +#endif +#ifdef B2500000 + { 2500000, B2500000 }, +#endif +#ifdef B3000000 + { 3000000, B3000000 }, +#endif +#ifdef B3500000 + { 3500000, B3500000 }, +#endif +#ifdef B4000000 + { 4000000, B4000000 }, #endif { 0, 0 } /* Terminator. */ }; From 308263043087c15f58ebaa501bd8da69c9188b68 Mon Sep 17 00:00:00 2001 From: Joerg Wunsch Date: Wed, 15 Jun 2022 23:32:22 +0200 Subject: [PATCH 04/14] Replace internal knowledge in jtag3.c by a public API In certain situations (CRC failure, device locked), that JTAG3 read functions need to return an indication to the caller that it is OK to proceed, and allow erasing the device anyway. Historically, the JTAG3 code passed the respective protocol errors directly (and unexplained) up to the caller, leaving the decision to the caller how to handle the situation. Replace that by a more common return value API. New code should prefer this API instead of any hardcoded return values. --- src/avr.c | 12 ++++++------ src/jtag3.c | 31 +++++++++++++++++++++---------- src/jtag3_private.h | 1 + src/libavrdude.h | 10 ++++++++++ src/main.c | 5 ++--- 5 files changed, 40 insertions(+), 19 deletions(-) diff --git a/src/avr.c b/src/avr.c index d6e78bb5..a8945d86 100644 --- a/src/avr.c +++ b/src/avr.c @@ -439,16 +439,16 @@ int avr_read(PROGRAMMER * pgm, AVRPART * p, char * memtype, (vmem->tags[i] & TAG_ALLOCATED) != 0) { rc = pgm->read_byte(pgm, p, mem, i, mem->buf + i); - if (rc != 0) { + if (rc != LIBAVRDUDE_SUCCESS) { avrdude_message(MSG_INFO, "avr_read(): error reading address 0x%04lx\n", i); - if (rc == -1) { + if (rc == LIBAVRDUDE_GENERAL_FAILURE) { avrdude_message(MSG_INFO, " read operation not supported for memory \"%s\"\n", memtype); - return -2; + return LIBAVRDUDE_NOTSUPPORTED; } avrdude_message(MSG_INFO, " read operation failed for memory \"%s\"\n", memtype); - return rc; + return LIBAVRDUDE_SOFTFAIL; } } report_progress(i, mem->size, NULL); @@ -1035,14 +1035,14 @@ int avr_signature(PROGRAMMER * pgm, AVRPART * p) report_progress (0,1,"Reading"); rc = avr_read(pgm, p, "signature", 0); - if (rc < 0) { + if (rc < LIBAVRDUDE_SUCCESS) { avrdude_message(MSG_INFO, "%s: error reading signature data for part \"%s\", rc=%d\n", progname, p->desc, rc); return rc; } report_progress (1,1,NULL); - return 0; + return LIBAVRDUDE_SUCCESS; } static uint8_t get_fuse_bitmask(AVRMEM * m) { diff --git a/src/jtag3.c b/src/jtag3.c index 6d358dfa..23df86ff 100644 --- a/src/jtag3.c +++ b/src/jtag3.c @@ -313,6 +313,16 @@ static void jtag3_prmsg(PROGRAMMER * pgm, unsigned char * data, size_t len) } } +static int jtag3_errcode(int status) +{ + if (status >= LIBAVRDUDE_SUCCESS) + return status; + if (status == RSP3_FAIL_OCD_LOCKED || + status == RSP3_FAIL_CRC_FAILURE) + return LIBAVRDUDE_SOFTFAIL; + return LIBAVRDUDE_GENERAL_FAILURE; +} + static void jtag3_prevent(PROGRAMMER * pgm, unsigned char * data, size_t len) { int i; @@ -850,7 +860,7 @@ int jtag3_recv(PROGRAMMER * pgm, unsigned char **msg) { putc('\n', stderr); avrdude_message(MSG_NOTICE2, "%s: %s command: timeout/error communicating with programmer (status %d)\n", progname, descr, status); - return -1; + return LIBAVRDUDE_GENERAL_FAILURE; } else if (verbose >= 3) { putc('\n', stderr); jtag3_prmsg(pgm, *resp, status); @@ -871,10 +881,11 @@ int jtag3_recv(PROGRAMMER * pgm, unsigned char **msg) { status = (*resp)[3]; free(*resp); resp = 0; - return -status; + + return jtag3_errcode(status); } - return status; + return LIBAVRDUDE_SUCCESS; } @@ -987,10 +998,10 @@ static int jtag3_program_enable(PROGRAMMER * pgm) free(resp); PDATA(pgm)->prog_enabled = 1; - return 0; + return LIBAVRDUDE_SUCCESS; } - return status; + return jtag3_errcode(status); } static int jtag3_program_disable(PROGRAMMER * pgm) @@ -1921,7 +1932,7 @@ static int jtag3_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, if (!(pgm->flag & PGM_FL_IS_DW)) if ((status = jtag3_program_enable(pgm)) < 0) - return status; + return jtag3_errcode(status); cmd[0] = SCOPE_AVR; cmd[1] = CMD3_READ_MEMORY; @@ -2007,7 +2018,7 @@ static int jtag3_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, if (addr == 0) { if ((status = jtag3_command(pgm, cmd, 12, &resp, "read memory")) < 0) - return status; + return jtag3_errcode(status); signature_cache[0] = resp[4]; signature_cache[1] = resp[5]; @@ -2057,7 +2068,7 @@ static int jtag3_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, } if ((status = jtag3_command(pgm, cmd, 12, &resp, "read memory")) < 0) - return status; + return jtag3_errcode(status); if (resp[1] != RSP3_DATA || status < (pagesize? pagesize: 1) + 4) { @@ -2185,7 +2196,7 @@ static int jtag3_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, cmd[13] = data; if ((status = jtag3_command(pgm, cmd, 14, &resp, "write memory")) < 0) - return status; + return jtag3_errcode(status); free(resp); @@ -2316,7 +2327,7 @@ int jtag3_read_sib(PROGRAMMER * pgm, AVRPART * p, char * sib) u32_to_b4(cmd + 8, AVR_SIBLEN); if ((status = jtag3_command(pgm, cmd, 12, &resp, "read SIB")) < 0) - return status; + return jtag3_errcode(status); memcpy(sib, resp+3, AVR_SIBLEN); sib[AVR_SIBLEN] = 0; // Zero terminate string diff --git a/src/jtag3_private.h b/src/jtag3_private.h index a3e7fb08..6385aa4c 100644 --- a/src/jtag3_private.h +++ b/src/jtag3_private.h @@ -145,6 +145,7 @@ # define RSP3_FAIL_UNSUPP_MEMORY 0x34 /* unsupported memory type */ # define RSP3_FAIL_WRONG_LENGTH 0x35 /* wrong lenth for mem access */ # define RSP3_FAIL_OCD_LOCKED 0x44 /* device is locked */ +# define RSP3_FAIL_CRC_FAILURE 0x47 /* CRC failure in device */ # define RSP3_FAIL_NOT_UNDERSTOOD 0x91 /* ICE events */ diff --git a/src/libavrdude.h b/src/libavrdude.h index ddb72b48..46789f4f 100644 --- a/src/libavrdude.h +++ b/src/libavrdude.h @@ -27,6 +27,16 @@ #include typedef uint32_t pinmask_t; +/* + * Values returned by library functions. + * Some library functions also return a count, i.e. a positive + * number greater than 0. + */ +#define LIBAVRDUDE_SUCCESS 0 +#define LIBAVRDUDE_GENERAL_FAILURE (-1) +#define LIBAVRDUDE_NOTSUPPORTED (-2) // operation not supported +#define LIBAVRDUDE_SOFTFAIL (-3) // returned by avr_signature() if caller + // might proceed with chip erase /* formerly lists.h */ diff --git a/src/main.c b/src/main.c index 253c6e51..5b0a6e38 100644 --- a/src/main.c +++ b/src/main.c @@ -1116,9 +1116,8 @@ int main(int argc, char * argv []) usleep(waittime); if (init_ok) { rc = avr_signature(pgm, p); - if (rc != 0) { - // -68 == -(0x44) == -(RSP3_FAIL_OCD_LOCKED) - if ((rc == -68) && (p->flags & AVRPART_HAS_UPDI) && (attempt < 1)) { + if (rc != LIBAVRDUDE_SUCCESS) { + if ((rc == LIBAVRDUDE_SOFTFAIL) && (p->flags & AVRPART_HAS_UPDI) && (attempt < 1)) { attempt++; if (pgm->read_sib) { // Read SIB and compare FamilyID From c8350f816c2ec26022bba5758aadebd4b3095230 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Sat, 18 Jun 2022 22:34:54 +0100 Subject: [PATCH 05/14] Fix support for ATmega2560 et al (load extended address) --- src/avrftdi.c | 41 +++++++++++++++++++---------------------- src/avrftdi_private.h | 2 ++ 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/src/avrftdi.c b/src/avrftdi.c index e41d775e..c6d2f86e 100644 --- a/src/avrftdi.c +++ b/src/avrftdi.c @@ -917,8 +917,15 @@ static int avrftdi_chip_erase(PROGRAMMER * pgm, AVRPART * p) static int avrftdi_lext(PROGRAMMER *pgm, AVRPART *p, AVRMEM *m, unsigned int address) { + avrftdi_t *pdata = to_pdata(pgm); unsigned char buf[] = { 0x00, 0x00, 0x00, 0x00 }; + /* only send load extended address command if high byte changed */ + if(pdata->lext_byte == (uint8_t) (address>>16)) + return 0; + + pdata->lext_byte = (uint8_t) (address>>16); + avr_set_bits(m->op[AVR_OP_LOAD_EXT_ADDR], buf); avr_set_addr(m->op[AVR_OP_LOAD_EXT_ADDR], buf, address); @@ -983,8 +990,6 @@ static int avrftdi_eeprom_read(PROGRAMMER *pgm, AVRPART *p, AVRMEM *m, static int avrftdi_flash_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, unsigned int page_size, unsigned int addr, unsigned int len) { - int use_lext_address = m->op[AVR_OP_LOAD_EXT_ADDR] != NULL; - unsigned int word; unsigned int poll_index; @@ -1013,22 +1018,12 @@ static int avrftdi_flash_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, page_size = m->page_size; - /* if we do cross a 64k word boundary (or write the - * first page), we need to issue a 'load extended - * address byte' command, which is defined as 0x4d - * 0x00
0x00. As far as i know, this - * is only available on 256k parts. 64k word is 128k - * bytes. - * write the command only once. - */ - if(use_lext_address && (((addr/2) & 0xffff0000))) { - if (0 > avrftdi_lext(pgm, p, m, addr/2)) - return -1; - } + /* on large-flash devices > 128k issue extended address command when needed */ + if(m->op[AVR_OP_LOAD_EXT_ADDR] && avrftdi_lext(pgm, p, m, addr/2) < 0) + return -1; /* prepare the command stream for the whole page */ - /* addr is in bytes, but we program in words. addr/2 should be something - * like addr >> WORD_SHIFT, though */ + /* addr is in bytes, but we program in words. */ for(word = addr/2; word < (len + addr)/2; word++) { log_debug("-< bytes = %d of %d\n", word * 2, len + addr); @@ -1107,7 +1102,6 @@ static int avrftdi_flash_read(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, { OPCODE * readop; int byte, word; - int use_lext_address = m->op[AVR_OP_LOAD_EXT_ADDR] != NULL; unsigned int address = addr/2; unsigned int buf_size = 4 * len + 4; @@ -1128,10 +1122,8 @@ static int avrftdi_flash_read(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, return -1; } - if(use_lext_address && ((address & 0xffff0000))) { - if (0 > avrftdi_lext(pgm, p, m, address)) - return -1; - } + if(m->op[AVR_OP_LOAD_EXT_ADDR] && avrftdi_lext(pgm, p, m, address) < 0) + return -1; /* word addressing! */ for(word = addr/2, index = 0; word < (addr + len)/2; word++) @@ -1210,7 +1202,11 @@ avrftdi_setup(PROGRAMMER * pgm) { avrftdi_t* pdata; - pgm->cookie = malloc(sizeof(avrftdi_t)); + + if(!(pgm->cookie = calloc(sizeof(avrftdi_t), 1))) { + log_err("Error allocating memory.\n"); + exit(1); + } pdata = to_pdata(pgm); pdata->ftdic = ftdi_new(); @@ -1224,6 +1220,7 @@ avrftdi_setup(PROGRAMMER * pgm) pdata->pin_value = 0; pdata->pin_direction = 0; pdata->led_mask = 0; + pdata->lext_byte = 0xff; } static void diff --git a/src/avrftdi_private.h b/src/avrftdi_private.h index 3c965ed8..15b9caec 100644 --- a/src/avrftdi_private.h +++ b/src/avrftdi_private.h @@ -81,6 +81,8 @@ typedef struct avrftdi_s { int tx_buffer_size; /* use bitbanging instead of mpsse spi */ bool use_bitbanging; + /* bits 16-23 of extended 24-bit word flash address for parts with flash > 128k */ + uint8_t lext_byte; } avrftdi_t; void avrftdi_log(int level, const char * func, int line, const char * fmt, ...); From 3b0a2abc20e88101a194b953ab31cd8ab89d27dd Mon Sep 17 00:00:00 2001 From: MCUdude Date: Sun, 19 Jun 2022 10:53:07 +0200 Subject: [PATCH 06/14] Reduce programmer description string length to less than 80 characters. #941 related --- src/avrdude.conf.in | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/avrdude.conf.in b/src/avrdude.conf.in index 362b6167..ba7f4f8e 100644 --- a/src/avrdude.conf.in +++ b/src/avrdude.conf.in @@ -947,9 +947,10 @@ programmer ; # commercial version of USBtiny, using a separate VID/PID +# https://github.com/IowaScaledEngineering/ckt-avrprogrammer programmer id = "iseavrprog"; - desc = "USBtiny-based USB programmer, https://github.com/IowaScaledEngineering/ckt-avrprogrammer"; + desc = "USBtiny-based programmer, https://iascaled.com"; type = "usbtiny"; connection_type = usb; usbvid = 0x1209; From 1aa59aaa98e6a79bb4a321be80c5113184dd2668 Mon Sep 17 00:00:00 2001 From: Joerg Wunsch Date: Sun, 19 Jun 2022 19:56:56 +0200 Subject: [PATCH 07/14] PR #1000 is done now --- NEWS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS b/NEWS index 4638746a..888796ca 100644 --- a/NEWS +++ b/NEWS @@ -24,6 +24,8 @@ Changes since version 7.0: - Fix .Dd macro in manpage #949 - fix M1 homebrew path #950 - CMake Enhancements #962 + - Reduce programmer desc string length in avrdude.conf + to < 80 characters #1000 * Internals: From ae0e3e2f8e239c5075cd5a8507c9ada021197bcf Mon Sep 17 00:00:00 2001 From: Joerg Wunsch Date: Wed, 22 Jun 2022 23:33:53 +0200 Subject: [PATCH 08/14] Fix a number of logic errors in the previous commits RSP3_FAIL_CRC_FAILURE is 0x43 rather than 0x47. jtag3_errcode() must only be applied to a reason code, not to any general status code. --- src/jtag3.c | 32 +++++++++++++++----------------- src/jtag3_private.h | 2 +- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/src/jtag3.c b/src/jtag3.c index 23df86ff..4c159ee8 100644 --- a/src/jtag3.c +++ b/src/jtag3.c @@ -313,12 +313,10 @@ static void jtag3_prmsg(PROGRAMMER * pgm, unsigned char * data, size_t len) } } -static int jtag3_errcode(int status) +static int jtag3_errcode(int reason) { - if (status >= LIBAVRDUDE_SUCCESS) - return status; - if (status == RSP3_FAIL_OCD_LOCKED || - status == RSP3_FAIL_CRC_FAILURE) + if (reason == RSP3_FAIL_OCD_LOCKED || + reason == RSP3_FAIL_CRC_FAILURE) return LIBAVRDUDE_SOFTFAIL; return LIBAVRDUDE_GENERAL_FAILURE; } @@ -844,7 +842,7 @@ int jtag3_recv(PROGRAMMER * pgm, unsigned char **msg) { } } - int jtag3_command(PROGRAMMER *pgm, unsigned char *cmd, unsigned int cmdlen, +int jtag3_command(PROGRAMMER *pgm, unsigned char *cmd, unsigned int cmdlen, unsigned char **resp, const char *descr) { int status; @@ -868,9 +866,10 @@ int jtag3_recv(PROGRAMMER * pgm, unsigned char **msg) { avrdude_message(MSG_NOTICE2, "0x%02x (%d bytes msg)\n", (*resp)[1], status); } - c = (*resp)[1]; - if ((c & RSP3_STATUS_MASK) != RSP3_OK) { - if ((c == RSP3_FAILED) && ((*resp)[3] == RSP3_FAIL_OCD_LOCKED)) { + c = (*resp)[1] & RSP3_STATUS_MASK; + if (c != RSP3_OK) { + if ((c == RSP3_FAILED) && ((*resp)[3] == RSP3_FAIL_OCD_LOCKED || + (*resp)[3] == RSP3_FAIL_CRC_FAILURE)) { avrdude_message(MSG_INFO, "%s: Device is locked! Chip erase required to unlock.\n", progname); @@ -881,11 +880,10 @@ int jtag3_recv(PROGRAMMER * pgm, unsigned char **msg) { status = (*resp)[3]; free(*resp); resp = 0; - return jtag3_errcode(status); } - return LIBAVRDUDE_SUCCESS; + return status; } @@ -1001,7 +999,7 @@ static int jtag3_program_enable(PROGRAMMER * pgm) return LIBAVRDUDE_SUCCESS; } - return jtag3_errcode(status); + return status; } static int jtag3_program_disable(PROGRAMMER * pgm) @@ -1932,7 +1930,7 @@ static int jtag3_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, if (!(pgm->flag & PGM_FL_IS_DW)) if ((status = jtag3_program_enable(pgm)) < 0) - return jtag3_errcode(status); + return status; cmd[0] = SCOPE_AVR; cmd[1] = CMD3_READ_MEMORY; @@ -2018,7 +2016,7 @@ static int jtag3_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, if (addr == 0) { if ((status = jtag3_command(pgm, cmd, 12, &resp, "read memory")) < 0) - return jtag3_errcode(status); + return status; signature_cache[0] = resp[4]; signature_cache[1] = resp[5]; @@ -2068,7 +2066,7 @@ static int jtag3_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, } if ((status = jtag3_command(pgm, cmd, 12, &resp, "read memory")) < 0) - return jtag3_errcode(status); + return status; if (resp[1] != RSP3_DATA || status < (pagesize? pagesize: 1) + 4) { @@ -2196,7 +2194,7 @@ static int jtag3_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem, cmd[13] = data; if ((status = jtag3_command(pgm, cmd, 14, &resp, "write memory")) < 0) - return jtag3_errcode(status); + return status; free(resp); @@ -2327,7 +2325,7 @@ int jtag3_read_sib(PROGRAMMER * pgm, AVRPART * p, char * sib) u32_to_b4(cmd + 8, AVR_SIBLEN); if ((status = jtag3_command(pgm, cmd, 12, &resp, "read SIB")) < 0) - return jtag3_errcode(status); + return status; memcpy(sib, resp+3, AVR_SIBLEN); sib[AVR_SIBLEN] = 0; // Zero terminate string diff --git a/src/jtag3_private.h b/src/jtag3_private.h index 6385aa4c..7d0cbb74 100644 --- a/src/jtag3_private.h +++ b/src/jtag3_private.h @@ -144,8 +144,8 @@ # define RSP3_FAIL_WRONG_MODE 0x32 /* progmode vs. non-prog */ # define RSP3_FAIL_UNSUPP_MEMORY 0x34 /* unsupported memory type */ # define RSP3_FAIL_WRONG_LENGTH 0x35 /* wrong lenth for mem access */ +# define RSP3_FAIL_CRC_FAILURE 0x43 /* CRC failure in device */ # define RSP3_FAIL_OCD_LOCKED 0x44 /* device is locked */ -# define RSP3_FAIL_CRC_FAILURE 0x47 /* CRC failure in device */ # define RSP3_FAIL_NOT_UNDERSTOOD 0x91 /* ICE events */ From 89b0aa72e0f605e4408989ae9a579dbffd65688d Mon Sep 17 00:00:00 2001 From: MCUdude Date: Sat, 25 Jun 2022 11:39:16 +0200 Subject: [PATCH 09/14] Attempt to fix EEPROM write issue #1009 --- src/jtag3.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jtag3.c b/src/jtag3.c index 6d358dfa..bb41431f 100644 --- a/src/jtag3.c +++ b/src/jtag3.c @@ -1761,7 +1761,7 @@ static int jtag3_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, free(cmd); return n_bytes; } - cmd[3] = ( p->flags & AVRPART_HAS_PDI ) ? MTYPE_EEPROM_XMEGA : MTYPE_EEPROM_PAGE; + cmd[3] = ( p->flags & AVRPART_HAS_PDI || p->flags & AVRPART_HAS_UPDI ) ? MTYPE_EEPROM_XMEGA : MTYPE_EEPROM_PAGE; PDATA(pgm)->eeprom_pageaddr = (unsigned long)-1L; } else if (strcmp(m->desc, "usersig") == 0 || strcmp(m->desc, "userrow") == 0) { From 1b997968a526c630a45ba8c705162140f86a7419 Mon Sep 17 00:00:00 2001 From: Joerg Wunsch Date: Sun, 26 Jun 2022 22:58:25 +0200 Subject: [PATCH 10/14] Closing PR 979 --- NEWS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS b/NEWS index 888796ca..16fef572 100644 --- a/NEWS +++ b/NEWS @@ -18,6 +18,7 @@ Changes since version 7.0: - Fix micronucleus bootloader to check for unresponsive USB devices #945 - Fix src/CMakeLists.txt to honor CMAKE_INSTALL_LIBDIR #972 + - [bug #43898] atmega644p remains stopped after JTAG transaction #366 * Pull requests: @@ -26,6 +27,7 @@ Changes since version 7.0: - CMake Enhancements #962 - Reduce programmer desc string length in avrdude.conf to < 80 characters #1000 + - Dragon JTAG fix #979 * Internals: From 362e6993acc863c282a16fd4d3642ebbeab4eae7 Mon Sep 17 00:00:00 2001 From: Joerg Wunsch Date: Sun, 26 Jun 2022 23:00:32 +0200 Subject: [PATCH 11/14] PR 993 done --- NEWS | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS b/NEWS index 16fef572..da4e42d0 100644 --- a/NEWS +++ b/NEWS @@ -28,6 +28,7 @@ Changes since version 7.0: - Reduce programmer desc string length in avrdude.conf to < 80 characters #1000 - Dragon JTAG fix #979 + - adding support for all Linux baud rates v.2 #993 * Internals: From a6ea797c1cd51ccebdb44ac5cc5fc71b4c2a8cc7 Mon Sep 17 00:00:00 2001 From: Joerg Wunsch Date: Tue, 28 Jun 2022 22:53:24 +0200 Subject: [PATCH 12/14] PR 996 and 1013 done --- NEWS | 2 ++ 1 file changed, 2 insertions(+) diff --git a/NEWS b/NEWS index da4e42d0..d5ce1df4 100644 --- a/NEWS +++ b/NEWS @@ -29,6 +29,8 @@ Changes since version 7.0: to < 80 characters #1000 - Dragon JTAG fix #979 - adding support for all Linux baud rates v.2 #993 + - Replace internal knowledge in jtag3.c by a public API #996 + - JTAG3 UPDI EEPROM fix #1013 * Internals: From 43c6b0422681ca271b9f32537bdba488df221e06 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Tue, 28 Jun 2022 22:46:06 +0100 Subject: [PATCH 13/14] Update NEWS --- NEWS | 1 + 1 file changed, 1 insertion(+) diff --git a/NEWS b/NEWS index d5ce1df4..e78362b3 100644 --- a/NEWS +++ b/NEWS @@ -31,6 +31,7 @@ Changes since version 7.0: - adding support for all Linux baud rates v.2 #993 - Replace internal knowledge in jtag3.c by a public API #996 - JTAG3 UPDI EEPROM fix #1013 + - Treat x bits in .conf SPI commands as 0 #943 * Internals: From d95c1a91f72578a761c579b103c3a1c787a741e1 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Mon, 4 Jul 2022 12:25:50 +0100 Subject: [PATCH 14/14] Steamline avrftdi support for ATmega2560 et al --- src/avrftdi.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/avrftdi.c b/src/avrftdi.c index c6d2f86e..54490dc0 100644 --- a/src/avrftdi.c +++ b/src/avrftdi.c @@ -917,6 +917,10 @@ static int avrftdi_chip_erase(PROGRAMMER * pgm, AVRPART * p) static int avrftdi_lext(PROGRAMMER *pgm, AVRPART *p, AVRMEM *m, unsigned int address) { + /* nothing to do if load extended address command unavailable */ + if(m->op[AVR_OP_LOAD_EXT_ADDR] == NULL) + return 0; + avrftdi_t *pdata = to_pdata(pgm); unsigned char buf[] = { 0x00, 0x00, 0x00, 0x00 }; @@ -1019,7 +1023,7 @@ static int avrftdi_flash_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, page_size = m->page_size; /* on large-flash devices > 128k issue extended address command when needed */ - if(m->op[AVR_OP_LOAD_EXT_ADDR] && avrftdi_lext(pgm, p, m, addr/2) < 0) + if(avrftdi_lext(pgm, p, m, addr/2) < 0) return -1; /* prepare the command stream for the whole page */ @@ -1102,7 +1106,6 @@ static int avrftdi_flash_read(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, { OPCODE * readop; int byte, word; - unsigned int address = addr/2; unsigned int buf_size = 4 * len + 4; unsigned char* o_buf = alloca(buf_size); @@ -1122,7 +1125,7 @@ static int avrftdi_flash_read(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, return -1; } - if(m->op[AVR_OP_LOAD_EXT_ADDR] && avrftdi_lext(pgm, p, m, address) < 0) + if(avrftdi_lext(pgm, p, m, addr/2) < 0) return -1; /* word addressing! */