Contributed by Zoltan Laday:
patch #6825: xmega problems with JTAGICEmkII * jtagmkII.c: Many fixes for Xmega devices. * jtagmkII_private.h: Add various new constants required for Xmega devices. * avrdude.conf.in: New devices: ATXMEGA64A1, ATXMEGA192A1, ATXMEGA256A1, ATXMEGA64A3, ATXMEGA128A3, ATXMEGA192A3, ATXMEGA256A3, ATXMEGA256A3B, ATXMEGA16A4, ATXMEGA32A4, ATXMEGA64A4, ATXMEGA128A4 * avr.c (avr_read, avr_write): Add more names for (Xmega) memory areas that require paged operation. git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@821 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
parent
9c1f1f921b
commit
a5f42858ea
14
ChangeLog
14
ChangeLog
|
@ -1,3 +1,17 @@
|
|||
2009-06-24 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
Contributed by Zoltan Laday:
|
||||
patch #6825: xmega problems with JTAGICEmkII
|
||||
* jtagmkII.c: Many fixes for Xmega devices.
|
||||
* jtagmkII_private.h: Add various new constants required for
|
||||
Xmega devices.
|
||||
* avrdude.conf.in: New devices: ATXMEGA64A1, ATXMEGA192A1,
|
||||
ATXMEGA256A1, ATXMEGA64A3, ATXMEGA128A3, ATXMEGA192A3,
|
||||
ATXMEGA256A3, ATXMEGA256A3B, ATXMEGA16A4, ATXMEGA32A4,
|
||||
ATXMEGA64A4, ATXMEGA128A4
|
||||
* avr.c (avr_read, avr_write): Add more names for (Xmega)
|
||||
memory areas that require paged operation.
|
||||
|
||||
2009-06-24 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||
|
||||
* stk500v2.c (stk600_xprog_write_byte): Handle writing fuse bytes.
|
||||
|
|
17
NEWS
17
NEWS
|
@ -9,9 +9,22 @@ Current:
|
|||
|
||||
* New devices supported:
|
||||
|
||||
- ATXMEGA64A1
|
||||
- ATXMEGA192A1
|
||||
- ATXMEGA256A1
|
||||
- ATXMEGA64A3
|
||||
- ATXMEGA128A3
|
||||
- ATXMEGA192A3
|
||||
- ATXMEGA256A3
|
||||
- ATXMEGA256A3B
|
||||
- ATXMEGA16A4
|
||||
- ATXMEGA32A4
|
||||
- ATXMEGA64A4
|
||||
- ATXMEGA128A4
|
||||
|
||||
* New programmers supported:
|
||||
|
||||
*
|
||||
|
||||
* Major Xmega fixes for the JTAG ICE mkII (patch #6825)
|
||||
|
||||
|
||||
Version 5.6:
|
||||
|
|
17
avr.c
17
avr.c
|
@ -171,8 +171,13 @@ int avr_read(PROGRAMMER * pgm, AVRPART * p, char * memtype, int size,
|
|||
*/
|
||||
memset(buf, 0xff, size);
|
||||
|
||||
if ((strcmp(mem->desc, "flash")==0) || (strcmp(mem->desc, "eeprom")==0) ||
|
||||
(strcmp(mem->desc, "boot")==0)) {
|
||||
if ((strcmp(mem->desc, "eeprom")==0) ||
|
||||
(strcmp(mem->desc, "flash")==0) ||
|
||||
(strcmp(mem->desc, "application")==0) ||
|
||||
(strcmp(mem->desc, "apptable")==0) ||
|
||||
(strcmp(mem->desc, "boot")==0) ||
|
||||
(strcmp(mem->desc, "usersig")==0) ||
|
||||
(strcmp(mem->desc, "prodsig")==0)) {
|
||||
if (pgm->paged_load != NULL && mem->page_size != 0) {
|
||||
/*
|
||||
* the programmer supports a paged mode read, perhaps more
|
||||
|
@ -569,8 +574,12 @@ int avr_write(PROGRAMMER * pgm, AVRPART * p, char * memtype, int size,
|
|||
progbuf, wsize);
|
||||
}
|
||||
|
||||
if ((strcmp(m->desc, "flash")==0) || (strcmp(m->desc, "eeprom")==0) ||
|
||||
(strcmp(m->desc, "boot")==0)) {
|
||||
if ((strcmp(m->desc, "application")==0) ||
|
||||
(strcmp(m->desc, "apptable")==0) ||
|
||||
(strcmp(m->desc, "boot")==0) ||
|
||||
(strcmp(m->desc, "flash")==0) ||
|
||||
(strcmp(m->desc, "prodsig")==0) ||
|
||||
(strcmp(m->desc, "usersig")==0)) {
|
||||
if (pgm->paged_write != NULL && m->page_size != 0) {
|
||||
/*
|
||||
* the programmer supports a paged mode write, perhaps more
|
||||
|
|
1491
avrdude.conf.in
1491
avrdude.conf.in
File diff suppressed because it is too large
Load Diff
107
jtagmkII.c
107
jtagmkII.c
|
@ -1016,6 +1016,45 @@ static int jtagmkII_program_enable(PROGRAMMER * pgm)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static int jtagmkII_pre_write(PROGRAMMER * pgm)
|
||||
{
|
||||
int status;
|
||||
unsigned char *resp, c;
|
||||
unsigned char buf[] = { CMND_0x34, 0x0, 0x0, 0x0, 0x0, 0x0 };
|
||||
if (verbose >= 2)
|
||||
fprintf(stderr, "%s: jtagmkII_pre_write(): Sending pre-write command: ",
|
||||
progname);
|
||||
jtagmkII_send(pgm, buf, 6);
|
||||
|
||||
status = jtagmkII_recv(pgm, &resp);
|
||||
if (status <= 0) {
|
||||
if (verbose >= 2)
|
||||
putc('\n', stderr);
|
||||
fprintf(stderr,
|
||||
"%s: jtagmkII_pre_write(): "
|
||||
"timeout/error communicating with programmer (status %d)\n",
|
||||
progname, status);
|
||||
return -1;
|
||||
}
|
||||
if (verbose >= 3) {
|
||||
putc('\n', stderr);
|
||||
jtagmkII_prmsg(pgm, resp, status);
|
||||
} else if (verbose == 2)
|
||||
fprintf(stderr, "0x%02x (%d bytes msg)\n", resp[0], status);
|
||||
c = resp[0];
|
||||
free(resp);
|
||||
if (c != RSP_OK) {
|
||||
fprintf(stderr,
|
||||
"%s: jtagmkII_pre_write(): "
|
||||
"bad response to pre_write command: %s\n",
|
||||
progname, jtagmkII_get_rc(c));
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int jtagmkII_program_disable(PROGRAMMER * pgm)
|
||||
{
|
||||
int status;
|
||||
|
@ -1509,6 +1548,7 @@ static int jtagmkII_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||
int addr, block_size;
|
||||
unsigned char *cmd;
|
||||
unsigned char *resp;
|
||||
unsigned char par[4];
|
||||
int status, tries;
|
||||
long otimeout = serial_recv_timeout;
|
||||
|
||||
|
@ -1526,10 +1566,17 @@ static int jtagmkII_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||
progname);
|
||||
return -1;
|
||||
}
|
||||
if ( p->flags & AVRPART_HAS_PDI )
|
||||
{
|
||||
u32_to_b4( par, m->offset );
|
||||
(void) jtagmkII_setparm( pgm, PAR_PDI_OFFSET_START, par );
|
||||
u32_to_b4( par, m->offset + m->size );
|
||||
(void) jtagmkII_setparm( pgm, PAR_PDI_OFFSET_END, par );
|
||||
}
|
||||
|
||||
cmd[0] = CMND_WRITE_MEMORY;
|
||||
cmd[1] = ( p->flags & AVRPART_HAS_PDI ) ? MTYPE_FLASH : MTYPE_FLASH_PAGE;
|
||||
if (strcmp(m->desc, "flash") == 0) {
|
||||
cmd[1] = MTYPE_FLASH_PAGE;
|
||||
PDATA(pgm)->flash_pageaddr = (unsigned long)-1L;
|
||||
page_size = PDATA(pgm)->flash_pagesize;
|
||||
} else if (strcmp(m->desc, "eeprom") == 0) {
|
||||
|
@ -1549,11 +1596,12 @@ static int jtagmkII_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||
free(cmd);
|
||||
return n_bytes;
|
||||
}
|
||||
cmd[1] = MTYPE_EEPROM_PAGE;
|
||||
cmd[1] = ( p->flags & AVRPART_HAS_PDI ) ? MTYPE_EEPROM : MTYPE_EEPROM_PAGE;
|
||||
PDATA(pgm)->eeprom_pageaddr = (unsigned long)-1L;
|
||||
page_size = PDATA(pgm)->eeprom_pagesize;
|
||||
}
|
||||
|
||||
if ( cmd[1] == MTYPE_FLASH ) (void)jtagmkII_pre_write(pgm);
|
||||
|
||||
serial_recv_timeout = 100;
|
||||
for (addr = 0; addr < n_bytes; addr += page_size) {
|
||||
report_progress(addr, n_bytes,NULL);
|
||||
|
@ -1568,7 +1616,7 @@ static int jtagmkII_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||
progname, addr, block_size);
|
||||
|
||||
u32_to_b4(cmd + 2, page_size);
|
||||
u32_to_b4(cmd + 6, addr);
|
||||
u32_to_b4(cmd + 6, addr+m->offset );
|
||||
|
||||
/*
|
||||
* The JTAG ICE will refuse to write anything but a full page, at
|
||||
|
@ -1653,14 +1701,16 @@ static int jtagmkII_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||
page_size = m->readsize;
|
||||
|
||||
cmd[0] = CMND_READ_MEMORY;
|
||||
if (strcmp(m->desc, "flash") == 0) {
|
||||
cmd[1] = MTYPE_FLASH_PAGE;
|
||||
} else if (strcmp(m->desc, "eeprom") == 0) {
|
||||
cmd[1] = MTYPE_EEPROM_PAGE;
|
||||
cmd[1] = ( p->flags & AVRPART_HAS_PDI ) ? MTYPE_FLASH : MTYPE_FLASH_PAGE;
|
||||
if (strcmp(m->desc, "eeprom") == 0) {
|
||||
cmd[1] = ( p->flags & AVRPART_HAS_PDI ) ? MTYPE_EEPROM : MTYPE_EEPROM_PAGE;
|
||||
if (pgm->flag & PGM_FL_IS_DW)
|
||||
return -1;
|
||||
} else if ( ( strcmp(m->desc, "prodsig") == 0 ) ) {
|
||||
cmd[1] = MTYPE_PRODSIG;
|
||||
} else if ( ( strcmp(m->desc, "usersig") == 0 ) ) {
|
||||
cmd[1] = MTYPE_USERSIG;
|
||||
}
|
||||
|
||||
serial_recv_timeout = 100;
|
||||
for (addr = 0; addr < n_bytes; addr += page_size) {
|
||||
report_progress(addr, n_bytes,NULL);
|
||||
|
@ -1675,7 +1725,7 @@ static int jtagmkII_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||
progname, addr, block_size);
|
||||
|
||||
u32_to_b4(cmd + 2, block_size);
|
||||
u32_to_b4(cmd + 6, addr);
|
||||
u32_to_b4(cmd + 6, addr+m->offset );
|
||||
|
||||
tries = 0;
|
||||
|
||||
|
@ -1719,7 +1769,7 @@ static int jtagmkII_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
|||
serial_recv_timeout = otimeout;
|
||||
return -1;
|
||||
}
|
||||
memcpy(m->buf + addr, resp + 1, status);
|
||||
memcpy(m->buf + addr, resp + 1, status-1);
|
||||
free(resp);
|
||||
}
|
||||
serial_recv_timeout = otimeout;
|
||||
|
@ -1746,14 +1796,15 @@ static int jtagmkII_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
|||
cmd[0] = CMND_READ_MEMORY;
|
||||
unsupp = 0;
|
||||
|
||||
addr += mem->offset;
|
||||
cmd[1] = ( p->flags & AVRPART_HAS_PDI ) ? MTYPE_FLASH : MTYPE_FLASH_PAGE;
|
||||
if (strcmp(mem->desc, "flash") == 0) {
|
||||
cmd[1] = MTYPE_FLASH_PAGE;
|
||||
pagesize = mem->page_size;
|
||||
paddr = addr & ~(pagesize - 1);
|
||||
paddr_ptr = &PDATA(pgm)->flash_pageaddr;
|
||||
cache_ptr = PDATA(pgm)->flash_pagecache;
|
||||
} else if (strcmp(mem->desc, "eeprom") == 0) {
|
||||
if (pgm->flag & PGM_FL_IS_DW) {
|
||||
if ( (pgm->flag & PGM_FL_IS_DW) || ( p->flags & AVRPART_HAS_PDI ) ) {
|
||||
/* debugWire cannot use page access for EEPROM */
|
||||
cmd[1] = MTYPE_EEPROM;
|
||||
} else {
|
||||
|
@ -1782,6 +1833,12 @@ static int jtagmkII_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
|||
cmd[1] = MTYPE_LOCK_BITS;
|
||||
if (pgm->flag & PGM_FL_IS_DW)
|
||||
unsupp = 1;
|
||||
} else if (strncmp(mem->desc, "fuse", strlen("fuse")) == 0) {
|
||||
cmd[1] = MTYPE_FUSE_BITS;
|
||||
} else if (strcmp(mem->desc, "usersig") == 0) {
|
||||
cmd[1] = MTYPE_USERSIG;
|
||||
} else if (strcmp(mem->desc, "prodsig") == 0) {
|
||||
cmd[1] = MTYPE_PRODSIG;
|
||||
} else if (strcmp(mem->desc, "calibration") == 0) {
|
||||
cmd[1] = MTYPE_OSCCAL_BYTE;
|
||||
if (pgm->flag & PGM_FL_IS_DW)
|
||||
|
@ -1816,10 +1873,6 @@ static int jtagmkII_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
else if (mem->offset != 0) {
|
||||
cmd[1] = MTYPE_SRAM;
|
||||
addr += mem->offset;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -1919,14 +1972,16 @@ static int jtagmkII_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
|||
fprintf(stderr, "%s: jtagmkII_write_byte(.., %s, 0x%lx, ...)\n",
|
||||
progname, mem->desc, addr);
|
||||
|
||||
addr += mem->offset;
|
||||
|
||||
writedata = data;
|
||||
cmd[0] = CMND_WRITE_MEMORY;
|
||||
cmd[1] = ( p->flags & AVRPART_HAS_PDI ) ? MTYPE_FLASH : MTYPE_SPM;
|
||||
if (strcmp(mem->desc, "flash") == 0) {
|
||||
cmd[1] = MTYPE_SPM;
|
||||
need_progmode = 0;
|
||||
PDATA(pgm)->flash_pageaddr = (unsigned long)-1L;
|
||||
if (pgm->flag & PGM_FL_IS_DW)
|
||||
unsupp = 1;
|
||||
need_progmode = 0;
|
||||
PDATA(pgm)->flash_pageaddr = (unsigned long)-1L;
|
||||
if (pgm->flag & PGM_FL_IS_DW)
|
||||
unsupp = 1;
|
||||
} else if (strcmp(mem->desc, "eeprom") == 0) {
|
||||
cmd[1] = MTYPE_EEPROM;
|
||||
need_progmode = 0;
|
||||
|
@ -1946,6 +2001,12 @@ static int jtagmkII_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
|||
addr = 2;
|
||||
if (pgm->flag & PGM_FL_IS_DW)
|
||||
unsupp = 1;
|
||||
} else if (strncmp(mem->desc, "fuse", strlen("fuse")) == 0) {
|
||||
cmd[1] = MTYPE_FUSE_BITS;
|
||||
} else if (strcmp(mem->desc, "usersig") == 0) {
|
||||
cmd[1] = MTYPE_USERSIG;
|
||||
} else if (strcmp(mem->desc, "prodsig") == 0) {
|
||||
cmd[1] = MTYPE_PRODSIG;
|
||||
} else if (strcmp(mem->desc, "lock") == 0) {
|
||||
cmd[1] = MTYPE_LOCK_BITS;
|
||||
if (pgm->flag & PGM_FL_IS_DW)
|
||||
|
@ -2127,6 +2188,8 @@ static int jtagmkII_setparm(PROGRAMMER * pgm, unsigned char parm,
|
|||
case PAR_OCD_JTAG_CLK: size = 1; break;
|
||||
case PAR_TIMERS_RUNNING: size = 1; break;
|
||||
case PAR_DAISY_CHAIN_INFO: size = 4; break;
|
||||
case PAR_PDI_OFFSET_START:
|
||||
case PAR_PDI_OFFSET_END: size = 4; break;
|
||||
default:
|
||||
fprintf(stderr, "%s: jtagmkII_setparm(): unknown parameter 0x%02x\n",
|
||||
progname, parm);
|
||||
|
|
|
@ -103,6 +103,7 @@
|
|||
#define CMND_SPI_CMD 0x1D
|
||||
#define CMND_WRITE_MEMORY 0x04
|
||||
#define CMND_WRITE_PC 0x06
|
||||
#define CMND_0x34 0x34
|
||||
|
||||
/* ICE responses */
|
||||
#define RSP_DEBUGWIRE_SYNC_FAILED 0xAC
|
||||
|
@ -170,6 +171,9 @@
|
|||
#define MTYPE_SIGN_JTAG 0xB4 /* signature in programming mode */
|
||||
#define MTYPE_OSCCAL_BYTE 0xB5 /* osccal cells in programming mode */
|
||||
#define MTYPE_CAN 0xB6 /* CAN mailbox */
|
||||
#define MTYPE_FLASH 0xc0 /* xmega flash - undocumented in AVR067 */
|
||||
#define MTYPE_USERSIG 0xc5 /* xmega user signature - undocumented in AVR067 */
|
||||
#define MTYPE_PRODSIG 0xc6 /* xmega production signature - undocumented in AVR067 */
|
||||
|
||||
/* (some) ICE parameters, for CMND_{GET,SET}_PARAMETER */
|
||||
#define PAR_HW_VERSION 0x01
|
||||
|
@ -219,6 +223,8 @@
|
|||
#define PAR_TARGET_SIGNATURE 0x1D
|
||||
#define PAR_DEBUGWIRE_BAUDRATE 0x1E
|
||||
#define PAR_PROGRAM_ENTRY_POINT 0x1F
|
||||
#define PAR_PDI_OFFSET_START 0x32
|
||||
#define PAR_PDI_OFFSET_END 0x33
|
||||
#define PAR_PACKET_PARSING_ERRORS 0x40
|
||||
#define PAR_VALID_PACKETS_RECEIVED 0x41
|
||||
#define PAR_INTERCOMMUNICATION_TX_FAILURES 0x42
|
||||
|
|
Loading…
Reference in New Issue