Various fixes for Xmega devices.
* avrdude.conf.in: Correctly declare EEPROM page sizes for all Xmega devices (0x20 instead of 0x100). * avr.c: If a memory region has a page size declared, try using the paged IO routines regardless of the target memory name. Xmega EEPROM requires to be written in paged mode. Correctly use a long (rather than unsigned long) variable to evaluate the success status of the paged mode write attempt. * stk500v2.c: Don't apply TIF space offsets twice (bug #27995: AVRDUDE 5.8svn fails to program and read XMEGA); use stk500v2_loadaddr() prior to paged mode (EEPROM and flash) writes, otherwise programming of flash areas will fail; while being there, check the return value of stk500v2_loadaddr() everywhere; use the correct write/erase mode bits (same as AVR Studio does). git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@907 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
parent
d5023fbd6d
commit
814ff25d79
17
ChangeLog
17
ChangeLog
|
@ -1,3 +1,20 @@
|
||||||
|
2010-01-12 Joerg Wunsch <j.gnu@uriah.heep.sax.de>
|
||||||
|
|
||||||
|
Various fixes for Xmega devices.
|
||||||
|
* avrdude.conf.in: Correctly declare EEPROM page sizes for
|
||||||
|
all Xmega devices (0x20 instead of 0x100).
|
||||||
|
* avr.c: If a memory region has a page size declared, try
|
||||||
|
using the paged IO routines regardless of the target memory
|
||||||
|
name. Xmega EEPROM requires to be written in paged mode.
|
||||||
|
Correctly use a long (rather than unsigned long) variable to
|
||||||
|
evaluate the success status of the paged mode write attempt.
|
||||||
|
* stk500v2.c: Don't apply TIF space offsets twice (bug #27995:
|
||||||
|
AVRDUDE 5.8svn fails to program and read XMEGA); use
|
||||||
|
stk500v2_loadaddr() prior to paged mode (EEPROM and flash) writes,
|
||||||
|
otherwise programming of flash areas will fail; while being there,
|
||||||
|
check the return value of stk500v2_loadaddr() everywhere; use the
|
||||||
|
correct write/erase mode bits (same as AVR Studio does).
|
||||||
|
|
||||||
2010-01-12 Michal Ludvig <mludvig@logix.net.nz>
|
2010-01-12 Michal Ludvig <mludvig@logix.net.nz>
|
||||||
|
|
||||||
* buspirate.c: Initialise firmware version to v0.0
|
* buspirate.c: Initialise firmware version to v0.0
|
||||||
|
|
17
avr.c
17
avr.c
|
@ -171,13 +171,6 @@ int avr_read(PROGRAMMER * pgm, AVRPART * p, char * memtype, int size,
|
||||||
*/
|
*/
|
||||||
memset(buf, 0xff, size);
|
memset(buf, 0xff, size);
|
||||||
|
|
||||||
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) {
|
if (pgm->paged_load != NULL && mem->page_size != 0) {
|
||||||
/*
|
/*
|
||||||
* the programmer supports a paged mode read, perhaps more
|
* the programmer supports a paged mode read, perhaps more
|
||||||
|
@ -192,7 +185,6 @@ int avr_read(PROGRAMMER * pgm, AVRPART * p, char * memtype, int size,
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (strcmp(mem->desc, "signature") == 0) {
|
if (strcmp(mem->desc, "signature") == 0) {
|
||||||
if (pgm->read_sig_bytes) {
|
if (pgm->read_sig_bytes) {
|
||||||
|
@ -545,7 +537,7 @@ int avr_write(PROGRAMMER * pgm, AVRPART * p, char * memtype, int size,
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
int wsize;
|
int wsize;
|
||||||
unsigned long i;
|
long i;
|
||||||
unsigned char data;
|
unsigned char data;
|
||||||
int werror;
|
int werror;
|
||||||
AVRMEM * m;
|
AVRMEM * m;
|
||||||
|
@ -574,12 +566,6 @@ int avr_write(PROGRAMMER * pgm, AVRPART * p, char * memtype, int size,
|
||||||
progbuf, wsize);
|
progbuf, wsize);
|
||||||
}
|
}
|
||||||
|
|
||||||
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) {
|
if (pgm->paged_write != NULL && m->page_size != 0) {
|
||||||
/*
|
/*
|
||||||
* the programmer supports a paged mode write, perhaps more
|
* the programmer supports a paged mode write, perhaps more
|
||||||
|
@ -589,7 +575,6 @@ int avr_write(PROGRAMMER * pgm, AVRPART * p, char * memtype, int size,
|
||||||
if ((i = pgm->paged_write(pgm, p, m, m->page_size, size)) >= 0)
|
if ((i = pgm->paged_write(pgm, p, m, m->page_size, size)) >= 0)
|
||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (pgm->write_setup) {
|
if (pgm->write_setup) {
|
||||||
pgm->write_setup(pgm, p, m);
|
pgm->write_setup(pgm, p, m);
|
||||||
|
|
|
@ -13737,7 +13737,7 @@ part
|
||||||
memory "eeprom"
|
memory "eeprom"
|
||||||
size = 0x0800;
|
size = 0x0800;
|
||||||
offset = 0x08c0000;
|
offset = 0x08c0000;
|
||||||
page_size = 0x100;
|
page_size = 0x20;
|
||||||
readsize = 0x100;
|
readsize = 0x100;
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -13834,7 +13834,7 @@ part
|
||||||
memory "eeprom"
|
memory "eeprom"
|
||||||
size = 0x0800;
|
size = 0x0800;
|
||||||
offset = 0x08c0000;
|
offset = 0x08c0000;
|
||||||
page_size = 0x100;
|
page_size = 0x20;
|
||||||
readsize = 0x100;
|
readsize = 0x100;
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -13931,7 +13931,7 @@ part
|
||||||
memory "eeprom"
|
memory "eeprom"
|
||||||
size = 0x0800;
|
size = 0x0800;
|
||||||
offset = 0x08c0000;
|
offset = 0x08c0000;
|
||||||
page_size = 0x100;
|
page_size = 0x20;
|
||||||
readsize = 0x100;
|
readsize = 0x100;
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -14028,7 +14028,7 @@ part
|
||||||
memory "eeprom"
|
memory "eeprom"
|
||||||
size = 0x0800;
|
size = 0x0800;
|
||||||
offset = 0x08c0000;
|
offset = 0x08c0000;
|
||||||
page_size = 0x100;
|
page_size = 0x20;
|
||||||
readsize = 0x100;
|
readsize = 0x100;
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -14125,7 +14125,7 @@ part
|
||||||
memory "eeprom"
|
memory "eeprom"
|
||||||
size = 0x1000;
|
size = 0x1000;
|
||||||
offset = 0x08c0000;
|
offset = 0x08c0000;
|
||||||
page_size = 0x100;
|
page_size = 0x20;
|
||||||
readsize = 0x100;
|
readsize = 0x100;
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -14222,7 +14222,7 @@ part
|
||||||
memory "eeprom"
|
memory "eeprom"
|
||||||
size = 0x0800;
|
size = 0x0800;
|
||||||
offset = 0x08c0000;
|
offset = 0x08c0000;
|
||||||
page_size = 0x100;
|
page_size = 0x20;
|
||||||
readsize = 0x100;
|
readsize = 0x100;
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -14319,7 +14319,7 @@ part
|
||||||
memory "eeprom"
|
memory "eeprom"
|
||||||
size = 0x0800;
|
size = 0x0800;
|
||||||
offset = 0x08c0000;
|
offset = 0x08c0000;
|
||||||
page_size = 0x100;
|
page_size = 0x20;
|
||||||
readsize = 0x100;
|
readsize = 0x100;
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -14416,7 +14416,7 @@ part
|
||||||
memory "eeprom"
|
memory "eeprom"
|
||||||
size = 0x0800;
|
size = 0x0800;
|
||||||
offset = 0x08c0000;
|
offset = 0x08c0000;
|
||||||
page_size = 0x100;
|
page_size = 0x20;
|
||||||
readsize = 0x100;
|
readsize = 0x100;
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -14513,7 +14513,7 @@ part
|
||||||
memory "eeprom"
|
memory "eeprom"
|
||||||
size = 0x1000;
|
size = 0x1000;
|
||||||
offset = 0x08c0000;
|
offset = 0x08c0000;
|
||||||
page_size = 0x100;
|
page_size = 0x20;
|
||||||
readsize = 0x100;
|
readsize = 0x100;
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -14610,7 +14610,7 @@ part
|
||||||
memory "eeprom"
|
memory "eeprom"
|
||||||
size = 0x1000;
|
size = 0x1000;
|
||||||
offset = 0x08c0000;
|
offset = 0x08c0000;
|
||||||
page_size = 0x100;
|
page_size = 0x20;
|
||||||
readsize = 0x100;
|
readsize = 0x100;
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -14707,7 +14707,7 @@ part
|
||||||
memory "eeprom"
|
memory "eeprom"
|
||||||
size = 0x0400;
|
size = 0x0400;
|
||||||
offset = 0x08c0000;
|
offset = 0x08c0000;
|
||||||
page_size = 0x100;
|
page_size = 0x20;
|
||||||
readsize = 0x100;
|
readsize = 0x100;
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -14804,7 +14804,7 @@ part
|
||||||
memory "eeprom"
|
memory "eeprom"
|
||||||
size = 0x0400;
|
size = 0x0400;
|
||||||
offset = 0x08c0000;
|
offset = 0x08c0000;
|
||||||
page_size = 0x100;
|
page_size = 0x20;
|
||||||
readsize = 0x100;
|
readsize = 0x100;
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -14901,7 +14901,7 @@ part
|
||||||
memory "eeprom"
|
memory "eeprom"
|
||||||
size = 0x0800;
|
size = 0x0800;
|
||||||
offset = 0x08c0000;
|
offset = 0x08c0000;
|
||||||
page_size = 0x100;
|
page_size = 0x20;
|
||||||
readsize = 0x100;
|
readsize = 0x100;
|
||||||
;
|
;
|
||||||
|
|
||||||
|
@ -14998,7 +14998,7 @@ part
|
||||||
memory "eeprom"
|
memory "eeprom"
|
||||||
size = 0x0800;
|
size = 0x0800;
|
||||||
offset = 0x08c0000;
|
offset = 0x08c0000;
|
||||||
page_size = 0x100;
|
page_size = 0x20;
|
||||||
readsize = 0x100;
|
readsize = 0x100;
|
||||||
;
|
;
|
||||||
|
|
||||||
|
|
78
stk500v2.c
78
stk500v2.c
|
@ -1456,7 +1456,8 @@ static int stk500hv_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
||||||
buf[2] = pagesize & 0xff;
|
buf[2] = pagesize & 0xff;
|
||||||
|
|
||||||
/* flash and EEPROM reads require the load address command */
|
/* flash and EEPROM reads require the load address command */
|
||||||
stk500v2_loadaddr(pgm, use_ext_addr | (paddr >> addrshift));
|
if (stk500v2_loadaddr(pgm, use_ext_addr | (paddr >> addrshift)) < 0)
|
||||||
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
buf[1] = addr;
|
buf[1] = addr;
|
||||||
}
|
}
|
||||||
|
@ -1612,7 +1613,8 @@ static int stk500hv_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
||||||
memcpy(buf + 5, cache_ptr, pagesize);
|
memcpy(buf + 5, cache_ptr, pagesize);
|
||||||
|
|
||||||
/* flash and EEPROM reads require the load address command */
|
/* flash and EEPROM reads require the load address command */
|
||||||
stk500v2_loadaddr(pgm, use_ext_addr | (paddr >> addrshift));
|
if (stk500v2_loadaddr(pgm, use_ext_addr | (paddr >> addrshift)) < 0)
|
||||||
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
buf[1] = addr;
|
buf[1] = addr;
|
||||||
buf[2] = data;
|
buf[2] = data;
|
||||||
|
@ -1781,7 +1783,8 @@ static int stk500v2_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
||||||
buf[2] = block_size & 0xff;
|
buf[2] = block_size & 0xff;
|
||||||
|
|
||||||
if((last_addr==UINT_MAX)||(last_addr+block_size != addr)){
|
if((last_addr==UINT_MAX)||(last_addr+block_size != addr)){
|
||||||
stk500v2_loadaddr(pgm, use_ext_addr | (addr >> addrshift));
|
if (stk500v2_loadaddr(pgm, use_ext_addr | (addr >> addrshift)) < 0)
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
last_addr=addr;
|
last_addr=addr;
|
||||||
|
|
||||||
|
@ -1877,7 +1880,8 @@ static int stk500hv_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
||||||
buf[2] = page_size & 0xff;
|
buf[2] = page_size & 0xff;
|
||||||
|
|
||||||
if ((last_addr == UINT_MAX) || (last_addr + block_size != addr)) {
|
if ((last_addr == UINT_MAX) || (last_addr + block_size != addr)) {
|
||||||
stk500v2_loadaddr(pgm, use_ext_addr | (addr >> addrshift));
|
if (stk500v2_loadaddr(pgm, use_ext_addr | (addr >> addrshift)) < 0)
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
last_addr=addr;
|
last_addr=addr;
|
||||||
|
|
||||||
|
@ -1996,7 +2000,8 @@ static int stk500v2_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
||||||
// when crossing a 64 KB boundary in flash.
|
// when crossing a 64 KB boundary in flash.
|
||||||
if (hiaddr != (addr & ~0xFFFF)) {
|
if (hiaddr != (addr & ~0xFFFF)) {
|
||||||
hiaddr = addr & ~0xFFFF;
|
hiaddr = addr & ~0xFFFF;
|
||||||
stk500v2_loadaddr(pgm, use_ext_addr | (addr >> addrshift));
|
if (stk500v2_loadaddr(pgm, use_ext_addr | (addr >> addrshift)) < 0)
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = stk500v2_command(pgm,buf,4,sizeof(buf));
|
result = stk500v2_command(pgm,buf,4,sizeof(buf));
|
||||||
|
@ -2075,7 +2080,8 @@ static int stk500hv_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
||||||
// when crossing a 64 KB boundary in flash.
|
// when crossing a 64 KB boundary in flash.
|
||||||
if (hiaddr != (addr & ~0xFFFF)) {
|
if (hiaddr != (addr & ~0xFFFF)) {
|
||||||
hiaddr = addr & ~0xFFFF;
|
hiaddr = addr & ~0xFFFF;
|
||||||
stk500v2_loadaddr(pgm, use_ext_addr | (addr >> addrshift));
|
if (stk500v2_loadaddr(pgm, use_ext_addr | (addr >> addrshift)) < 0)
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = stk500v2_command(pgm, buf, 3, sizeof(buf));
|
result = stk500v2_command(pgm, buf, 3, sizeof(buf));
|
||||||
|
@ -3085,29 +3091,18 @@ static int stk600_xprog_write_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
||||||
{
|
{
|
||||||
unsigned char b[10];
|
unsigned char b[10];
|
||||||
|
|
||||||
/*
|
|
||||||
* Fancy offsets everywhere.
|
|
||||||
* This is probably what AVR079 means when writing about the
|
|
||||||
* "TIF address space".
|
|
||||||
*/
|
|
||||||
if (strcmp(mem->desc, "flash") == 0) {
|
if (strcmp(mem->desc, "flash") == 0) {
|
||||||
b[1] = XPRG_MEM_TYPE_APPL;
|
b[1] = XPRG_MEM_TYPE_APPL;
|
||||||
addr += 0x00800000;
|
|
||||||
} else if (strcmp(mem->desc, "boot") == 0) {
|
} else if (strcmp(mem->desc, "boot") == 0) {
|
||||||
b[1] = XPRG_MEM_TYPE_BOOT;
|
b[1] = XPRG_MEM_TYPE_BOOT;
|
||||||
addr += 0x00800000;
|
|
||||||
} else if (strcmp(mem->desc, "eeprom") == 0) {
|
} else if (strcmp(mem->desc, "eeprom") == 0) {
|
||||||
b[1] = XPRG_MEM_TYPE_EEPROM;
|
b[1] = XPRG_MEM_TYPE_EEPROM;
|
||||||
addr += 0x008c0000;
|
|
||||||
} else if (strcmp(mem->desc, "lockbits") == 0) {
|
} else if (strcmp(mem->desc, "lockbits") == 0) {
|
||||||
b[1] = XPRG_MEM_TYPE_LOCKBITS;
|
b[1] = XPRG_MEM_TYPE_LOCKBITS;
|
||||||
addr += 0x008f0000;
|
|
||||||
} else if (strncmp(mem->desc, "fuse", strlen("fuse")) == 0) {
|
} else if (strncmp(mem->desc, "fuse", strlen("fuse")) == 0) {
|
||||||
b[1] = XPRG_MEM_TYPE_FUSE;
|
b[1] = XPRG_MEM_TYPE_FUSE;
|
||||||
addr += 0x008f0000;
|
|
||||||
} else if (strcmp(mem->desc, "usersig") == 0) {
|
} else if (strcmp(mem->desc, "usersig") == 0) {
|
||||||
b[1] = XPRG_MEM_TYPE_USERSIG;
|
b[1] = XPRG_MEM_TYPE_USERSIG;
|
||||||
addr += 0x008e0000;
|
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"%s: stk600_xprog_write_byte(): unknown memory \"%s\"\n",
|
"%s: stk600_xprog_write_byte(): unknown memory \"%s\"\n",
|
||||||
|
@ -3140,35 +3135,22 @@ static int stk600_xprog_read_byte(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
||||||
{
|
{
|
||||||
unsigned char b[8];
|
unsigned char b[8];
|
||||||
|
|
||||||
/*
|
|
||||||
* Fancy offsets everywhere.
|
|
||||||
* This is probably what AVR079 means when writing about the
|
|
||||||
* "TIF address space".
|
|
||||||
*/
|
|
||||||
if (strcmp(mem->desc, "flash") == 0) {
|
if (strcmp(mem->desc, "flash") == 0) {
|
||||||
b[1] = XPRG_MEM_TYPE_APPL;
|
b[1] = XPRG_MEM_TYPE_APPL;
|
||||||
addr += 0x00800000;
|
|
||||||
} else if (strcmp(mem->desc, "boot") == 0) {
|
} else if (strcmp(mem->desc, "boot") == 0) {
|
||||||
b[1] = XPRG_MEM_TYPE_BOOT;
|
b[1] = XPRG_MEM_TYPE_BOOT;
|
||||||
addr += 0x00800000;
|
|
||||||
} else if (strcmp(mem->desc, "eeprom") == 0) {
|
} else if (strcmp(mem->desc, "eeprom") == 0) {
|
||||||
b[1] = XPRG_MEM_TYPE_EEPROM;
|
b[1] = XPRG_MEM_TYPE_EEPROM;
|
||||||
addr += 0x008c0000;
|
|
||||||
} else if (strcmp(mem->desc, "signature") == 0) {
|
} else if (strcmp(mem->desc, "signature") == 0) {
|
||||||
b[1] = XPRG_MEM_TYPE_APPL;
|
b[1] = XPRG_MEM_TYPE_APPL;
|
||||||
addr += 0x01000000;
|
|
||||||
} else if (strncmp(mem->desc, "fuse", strlen("fuse")) == 0) {
|
} else if (strncmp(mem->desc, "fuse", strlen("fuse")) == 0) {
|
||||||
b[1] = XPRG_MEM_TYPE_FUSE;
|
b[1] = XPRG_MEM_TYPE_FUSE;
|
||||||
addr += 0x008f0000;
|
|
||||||
} else if (strcmp(mem->desc, "lockbits") == 0) {
|
} else if (strcmp(mem->desc, "lockbits") == 0) {
|
||||||
b[1] = XPRG_MEM_TYPE_LOCKBITS;
|
b[1] = XPRG_MEM_TYPE_LOCKBITS;
|
||||||
addr += 0x008f0000;
|
|
||||||
} else if (strcmp(mem->desc, "calibration") == 0) {
|
} else if (strcmp(mem->desc, "calibration") == 0) {
|
||||||
b[1] = XPRG_MEM_TYPE_FACTORY_CALIBRATION;
|
b[1] = XPRG_MEM_TYPE_FACTORY_CALIBRATION;
|
||||||
addr += 0x008e0000;
|
|
||||||
} else if (strcmp(mem->desc, "usersig") == 0) {
|
} else if (strcmp(mem->desc, "usersig") == 0) {
|
||||||
b[1] = XPRG_MEM_TYPE_USERSIG;
|
b[1] = XPRG_MEM_TYPE_USERSIG;
|
||||||
addr += 0x008e0000;
|
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"%s: stk600_xprog_read_byte(): unknown memory \"%s\"\n",
|
"%s: stk600_xprog_read_byte(): unknown memory \"%s\"\n",
|
||||||
|
@ -3203,6 +3185,7 @@ static int stk600_xprog_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
||||||
unsigned int offset;
|
unsigned int offset;
|
||||||
unsigned char memtype;
|
unsigned char memtype;
|
||||||
int n_bytes_orig = n_bytes;
|
int n_bytes_orig = n_bytes;
|
||||||
|
unsigned long use_ext_addr = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The XPROG read command supports at most 256 bytes in one
|
* The XPROG read command supports at most 256 bytes in one
|
||||||
|
@ -3218,19 +3201,23 @@ static int stk600_xprog_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
||||||
*/
|
*/
|
||||||
if (strcmp(mem->desc, "flash") == 0) {
|
if (strcmp(mem->desc, "flash") == 0) {
|
||||||
memtype = XPRG_MEM_TYPE_APPL;
|
memtype = XPRG_MEM_TYPE_APPL;
|
||||||
addr = 0x00800000;
|
if (mem->size > 64 * 1024)
|
||||||
|
use_ext_addr = (1UL << 31);
|
||||||
} else if (strcmp(mem->desc, "boot") == 0) {
|
} else if (strcmp(mem->desc, "boot") == 0) {
|
||||||
memtype = XPRG_MEM_TYPE_BOOT;
|
memtype = XPRG_MEM_TYPE_BOOT;
|
||||||
addr = 0x00800000;
|
// Do we have to consider the total amount of flash
|
||||||
|
// instead to decide whether to use extended addressing?
|
||||||
|
if (mem->size > 64 * 1024)
|
||||||
|
use_ext_addr = (1UL << 31);
|
||||||
} else if (strcmp(mem->desc, "eeprom") == 0) {
|
} else if (strcmp(mem->desc, "eeprom") == 0) {
|
||||||
memtype = XPRG_MEM_TYPE_EEPROM;
|
memtype = XPRG_MEM_TYPE_EEPROM;
|
||||||
addr = 0x008c0000;
|
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"%s: stk600_xprog_paged_load(): unknown paged memory \"%s\"\n",
|
"%s: stk600_xprog_paged_load(): unknown paged memory \"%s\"\n",
|
||||||
progname, mem->desc);
|
progname, mem->desc);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
addr = mem->offset;
|
||||||
|
|
||||||
if ((b = malloc(page_size + 2)) == NULL) {
|
if ((b = malloc(page_size + 2)) == NULL) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
|
@ -3239,6 +3226,9 @@ static int stk600_xprog_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (stk500v2_loadaddr(pgm, use_ext_addr) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
offset = 0;
|
offset = 0;
|
||||||
while (n_bytes != 0) {
|
while (n_bytes != 0) {
|
||||||
report_progress(offset, n_bytes_orig, NULL);
|
report_progress(offset, n_bytes_orig, NULL);
|
||||||
|
@ -3278,6 +3268,8 @@ static int stk600_xprog_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
||||||
unsigned char memtype;
|
unsigned char memtype;
|
||||||
int n_bytes_orig = n_bytes;
|
int n_bytes_orig = n_bytes;
|
||||||
size_t writesize;
|
size_t writesize;
|
||||||
|
unsigned long use_ext_addr = 0;
|
||||||
|
unsigned char writemode;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* The XPROG read command supports at most 256 bytes in one
|
* The XPROG read command supports at most 256 bytes in one
|
||||||
|
@ -3297,19 +3289,26 @@ static int stk600_xprog_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
||||||
*/
|
*/
|
||||||
if (strcmp(mem->desc, "flash") == 0) {
|
if (strcmp(mem->desc, "flash") == 0) {
|
||||||
memtype = XPRG_MEM_TYPE_APPL;
|
memtype = XPRG_MEM_TYPE_APPL;
|
||||||
addr = 0x00800000;
|
writemode = (1 << XPRG_MEM_WRITE_WRITE);
|
||||||
|
if (mem->size > 64 * 1024)
|
||||||
|
use_ext_addr = (1UL << 31);
|
||||||
} else if (strcmp(mem->desc, "boot") == 0) {
|
} else if (strcmp(mem->desc, "boot") == 0) {
|
||||||
memtype = XPRG_MEM_TYPE_BOOT;
|
memtype = XPRG_MEM_TYPE_BOOT;
|
||||||
addr = 0x00800000;
|
writemode = (1 << XPRG_MEM_WRITE_WRITE);
|
||||||
|
// Do we have to consider the total amount of flash
|
||||||
|
// instead to decide whether to use extended addressing?
|
||||||
|
if (mem->size > 64 * 1024)
|
||||||
|
use_ext_addr = (1UL << 31);
|
||||||
} else if (strcmp(mem->desc, "eeprom") == 0) {
|
} else if (strcmp(mem->desc, "eeprom") == 0) {
|
||||||
memtype = XPRG_MEM_TYPE_EEPROM;
|
memtype = XPRG_MEM_TYPE_EEPROM;
|
||||||
addr = 0x008c0000;
|
writemode = (1 << XPRG_MEM_WRITE_WRITE) | (1 << XPRG_MEM_WRITE_ERASE);
|
||||||
} else {
|
} else {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"%s: stk600_xprog_paged_write(): unknown paged memory \"%s\"\n",
|
"%s: stk600_xprog_paged_write(): unknown paged memory \"%s\"\n",
|
||||||
progname, mem->desc);
|
progname, mem->desc);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
addr = mem->offset;
|
||||||
|
|
||||||
if ((b = malloc(page_size + 9)) == NULL) {
|
if ((b = malloc(page_size + 9)) == NULL) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
|
@ -3318,6 +3317,9 @@ static int stk600_xprog_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (stk500v2_loadaddr(pgm, use_ext_addr) < 0)
|
||||||
|
return -1;
|
||||||
|
|
||||||
offset = 0;
|
offset = 0;
|
||||||
while (n_bytes != 0) {
|
while (n_bytes != 0) {
|
||||||
report_progress(offset, n_bytes_orig, NULL);
|
report_progress(offset, n_bytes_orig, NULL);
|
||||||
|
@ -3349,7 +3351,7 @@ static int stk600_xprog_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
||||||
b[0] = XPRG_CMD_WRITE_MEM;
|
b[0] = XPRG_CMD_WRITE_MEM;
|
||||||
b[1] = memtype;
|
b[1] = memtype;
|
||||||
if (chunk + 256 == page_size) {
|
if (chunk + 256 == page_size) {
|
||||||
b[2] = 3; /* last chunk: erase page | write page */
|
b[2] = writemode; /* last chunk */
|
||||||
} else {
|
} else {
|
||||||
b[2] = 0; /* initial/intermediate chunk: just download */
|
b[2] = 0; /* initial/intermediate chunk: just download */
|
||||||
}
|
}
|
||||||
|
@ -3386,7 +3388,7 @@ static int stk600_xprog_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
||||||
}
|
}
|
||||||
b[0] = XPRG_CMD_WRITE_MEM;
|
b[0] = XPRG_CMD_WRITE_MEM;
|
||||||
b[1] = memtype;
|
b[1] = memtype;
|
||||||
b[2] = 3; /* erase page | write page */
|
b[2] = writemode;
|
||||||
b[3] = addr >> 24;
|
b[3] = addr >> 24;
|
||||||
b[4] = addr >> 16;
|
b[4] = addr >> 16;
|
||||||
b[5] = addr >> 8;
|
b[5] = addr >> 8;
|
||||||
|
|
Loading…
Reference in New Issue