Submitted by Jan Egil Ruud <janegil.ruud@microchip.com>

patch #9507: Fix UPDI chip erase
* lexer.l (family_id): New keyword.
* config_gram.y: (Ditto)
* doc/avrdude.texi: Document new keyword
* avrdude.conf.in: Add family_id for avr8x devices
* avr.c: Pass error code up.
* jtag3.c: Pass error code from memory read up; implement
jtag3_read_sib()
* libavrdude.h: Add new items.
* main.c: Implement different chip erase handling required
for UPDI devices.

Submitted by Jan Egil Ruud <janegil.ruud@microchip.com>
patch #9506: Script to create device configuration stub from Atmel ATDF files
* avrdude.conf.in (ATtiny202, ATtiny204, ATtiny402, ATtiny404)
(ATtiny406, ATtiny804, ATtiny806, ATtiny807, ATtiny1604)
(ATtiny1606, ATtiny1607, ATtiny212, ATtiny214, ATtiny412)
(ATTiny414, ATtiny416, ATtiny417, ATtiny814, ATtiny816)
(ATtiny1614, ATtiny1616, ATtiny3214, ATtiny3216, ATtiny3217)
(ATmega3208, ATmega3209, ATmega4808, ATmega4809): New devices




git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1405 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
Joerg Wunsch
2018-01-09 23:29:31 +00:00
parent 6b57f3dc8b
commit 47112a4734
10 changed files with 871 additions and 50 deletions

65
jtag3.c
View File

@@ -848,9 +848,10 @@ int jtag3_recv(PROGRAMMER * pgm, unsigned char **msg) {
avrdude_message(MSG_INFO, "%s: bad response to %s command: 0x%02x\n",
progname, descr, c);
}
status = (*resp)[3];
free(*resp);
resp = 0;
return -1;
return -status;
}
return status;
@@ -949,6 +950,7 @@ static int jtag3_program_enable_dummy(PROGRAMMER * pgm, AVRPART * p)
static int jtag3_program_enable(PROGRAMMER * pgm)
{
unsigned char buf[3], *resp;
int status;
if (PDATA(pgm)->prog_enabled)
return 0;
@@ -957,14 +959,14 @@ static int jtag3_program_enable(PROGRAMMER * pgm)
buf[1] = CMD3_ENTER_PROGMODE;
buf[2] = 0;
if (jtag3_command(pgm, buf, 3, &resp, "enter progmode") >= 0) {
if ((status = jtag3_command(pgm, buf, 3, &resp, "enter progmode")) >= 0) {
free(resp);
PDATA(pgm)->prog_enabled = 1;
return 0;
}
return -1;
return status;
}
static int jtag3_program_disable(PROGRAMMER * pgm)
@@ -1286,17 +1288,28 @@ static int jtag3_initialize(PROGRAMMER * pgm, AVRPART * p)
}
/*
* Depending on the target connection, there are two different
* Depending on the target connection, there are three different
* possible replies of the ICE. For a JTAG connection, the reply
* format is RSP3_DATA, followed by 4 bytes of the JTAG ID read from
* the device (followed by a trailing 0). For all other connections
* the device (followed by a trailing 0).
* For a UPDI connection the reply format is RSP3_DATA, followed by
* 4 bytes of the SIB Family_ID read from the device (followed by a
* trailing 0).
* For all other connections
* (except ISP which is handled completely differently, but that
* doesn't apply here anyway), the response is just RSP_OK.
*/
if (resp[1] == RSP3_DATA && status >= 7)
/* JTAG ID has been returned */
avrdude_message(MSG_NOTICE, "%s: JTAG ID returned: 0x%02x 0x%02x 0x%02x 0x%02x\n",
progname, resp[3], resp[4], resp[5], resp[6]);
if (resp[1] == RSP3_DATA && status >= 7) {
if (p->flags & AVRPART_HAS_UPDI) {
/* Partial Family_ID has been returned */
avrdude_message(MSG_NOTICE, "%s: Partial Family_ID returned: \"%c%c%c%c\"\n",
progname, resp[3], resp[4], resp[5], resp[6]);
}
else
/* JTAG ID has been returned */
avrdude_message(MSG_NOTICE, "%s: JTAG ID returned: 0x%02x 0x%02x 0x%02x 0x%02x\n",
progname, resp[3], resp[4], resp[5], resp[6]);
}
free(resp);
@@ -1806,8 +1819,9 @@ static int jtag3_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
avrdude_message(MSG_NOTICE2, "%s: jtag3_read_byte(.., %s, 0x%lx, ...)\n",
progname, mem->desc, addr);
if (!(pgm->flag & PGM_FL_IS_DW) && jtag3_program_enable(pgm) < 0)
return -1;
if (!(pgm->flag & PGM_FL_IS_DW))
if ((status = jtag3_program_enable(pgm)) < 0)
return status;
cmd[0] = SCOPE_AVR;
cmd[1] = CMD3_READ_MEMORY;
@@ -1886,7 +1900,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 -1;
return status;
signature_cache[0] = resp[4];
signature_cache[1] = resp[5];
@@ -1935,7 +1949,7 @@ static int jtag3_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
}
if ((status = jtag3_command(pgm, cmd, 12, &resp, "read memory")) < 0)
return -1;
return status;
if (resp[1] != RSP3_DATA ||
status < (pagesize? pagesize: 1) + 4) {
@@ -2061,7 +2075,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 -1;
return status;
free(resp);
@@ -2178,6 +2192,28 @@ int jtag3_setparm(PROGRAMMER * pgm, unsigned char scope,
return status;
}
int jtag3_read_sib(PROGRAMMER * pgm, AVRPART * p, char * sib)
{
int status;
unsigned char cmd[12];
unsigned char *resp = NULL;
cmd[0] = SCOPE_AVR;
cmd[1] = CMD3_READ_MEMORY;
cmd[2] = 0;
cmd[3] = MTYPE_SIB;
u32_to_b4(cmd + 4, 0);
u32_to_b4(cmd + 8, AVR_SIBLEN);
if ((status = jtag3_command(pgm, cmd, 12, &resp, "read SIB")) < 0)
return status;
memcpy(sib, resp+3, AVR_SIBLEN);
sib[AVR_SIBLEN] = 0; // Zero terminate string
avrdude_message(MSG_DEBUG, "%s: jtag3_read_sib(): Received SIB: \"%s\"\n", progname, sib);
free(resp);
return 0;
}
static void jtag3_display(PROGRAMMER * pgm, const char * p)
{
@@ -2430,5 +2466,6 @@ void jtag3_updi_initpgm(PROGRAMMER * pgm)
pgm->teardown = jtag3_teardown;
pgm->page_size = 256;
pgm->flag = PGM_FL_IS_UPDI;
pgm->read_sib = jtag3_read_sib;
}