The STK500 can perform paged read/write operations even on standard
"non-paged" parts. Take advantage of that and use the faster internal routines of the STK500 for those parts as well. git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@162 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
parent
8368f8317b
commit
94f22b15ee
|
@ -374,12 +374,20 @@ int avr_read(PROGRAMMER * pgm, AVRPART * p, char * memtype, int size,
|
||||||
size = mem->size;
|
size = mem->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mem->paged && pgm->paged_load != NULL) {
|
if ((strcmp(mem->desc, "flash")==0) || (strcmp(mem->desc, "eeprom")==0)) {
|
||||||
/*
|
if (pgm->paged_load != NULL) {
|
||||||
* the programmer directly supports writing this memory, perhaps
|
/*
|
||||||
* more efficiently than we can from here
|
* the programmer supports a paged mode read, perhaps more
|
||||||
*/
|
* efficiently than we can read it directly, so use its routine
|
||||||
return pgm->paged_load(pgm, p, mem, size);
|
* instead
|
||||||
|
*/
|
||||||
|
if (mem->paged) {
|
||||||
|
return pgm->paged_load(pgm, p, mem, mem->page_size, size);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return pgm->paged_load(pgm, p, mem, pgm->page_size, size);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -434,7 +442,7 @@ int avr_write_page(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
||||||
* if this memory is word-addressable, adjust the address
|
* if this memory is word-addressable, adjust the address
|
||||||
* accordingly
|
* accordingly
|
||||||
*/
|
*/
|
||||||
if (mem->op[AVR_OP_LOADPAGE_LO])
|
if ((mem->op[AVR_OP_LOADPAGE_LO]) || (mem->op[AVR_OP_READ_LO]))
|
||||||
addr = addr / 2;
|
addr = addr / 2;
|
||||||
|
|
||||||
pgm->pgm_led(pgm, ON);
|
pgm->pgm_led(pgm, ON);
|
||||||
|
@ -674,12 +682,20 @@ int avr_write(PROGRAMMER * pgm, AVRPART * p, char * memtype, int size,
|
||||||
|
|
||||||
pgm->err_led(pgm, OFF);
|
pgm->err_led(pgm, OFF);
|
||||||
|
|
||||||
if (m->paged && pgm->paged_write != NULL) {
|
if ((strcmp(m->desc, "flash")==0) || (strcmp(m->desc, "eeprom")==0)) {
|
||||||
/*
|
if (pgm->paged_write != NULL) {
|
||||||
* the programmer directly supports writing this memory, perhaps
|
/*
|
||||||
* more efficiently than we can from here
|
* the programmer supports a paged mode write, perhaps more
|
||||||
*/
|
* efficiently than we can read it directly, so use its routine
|
||||||
return pgm->paged_write(pgm, p, m, size);
|
* instead
|
||||||
|
*/
|
||||||
|
if (m->paged) {
|
||||||
|
return pgm->paged_write(pgm, p, m, m->page_size, size);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
return pgm->paged_write(pgm, p, m, pgm->page_size, size);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printed = 0;
|
printed = 0;
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
# programmer
|
# programmer
|
||||||
# id = <id1> [, <id2> [, <id3>] ...] ; # <idN> are quoted strings
|
# id = <id1> [, <id2> [, <id3>] ...] ; # <idN> are quoted strings
|
||||||
# desc = <description> ; # quoted string
|
# desc = <description> ; # quoted string
|
||||||
|
# type = ppi | stk500 ; # programmer type
|
||||||
# vcc = <num1> [, <num2> ... ] ; # pin number(s)
|
# vcc = <num1> [, <num2> ... ] ; # pin number(s)
|
||||||
# reset = <num> ; # pin number
|
# reset = <num> ; # pin number
|
||||||
# sck = <num> ; # pin number
|
# sck = <num> ; # pin number
|
||||||
|
@ -29,6 +30,7 @@
|
||||||
# part
|
# part
|
||||||
# id = <id> ; # quoted string
|
# id = <id> ; # quoted string
|
||||||
# desc = <description> ; # quoted string
|
# desc = <description> ; # quoted string
|
||||||
|
# devicecode = <num> ; # numeric
|
||||||
# chip_erase_delay = <num> ; # micro-seconds
|
# chip_erase_delay = <num> ; # micro-seconds
|
||||||
# pgm_enable = <instruction format> ;
|
# pgm_enable = <instruction format> ;
|
||||||
# chip_erase = <instruction format> ;
|
# chip_erase = <instruction format> ;
|
||||||
|
@ -60,6 +62,8 @@
|
||||||
# complain.
|
# complain.
|
||||||
#
|
#
|
||||||
# NOTES:
|
# NOTES:
|
||||||
|
# * 'devicecode' is the device code used by the STK500 (see codes
|
||||||
|
# listed below)
|
||||||
# * Not all memory types will implement all instructions.
|
# * Not all memory types will implement all instructions.
|
||||||
# * AVR Fuse bits and Lock bits are implemented as a type of memory.
|
# * AVR Fuse bits and Lock bits are implemented as a type of memory.
|
||||||
# * Example memory types are:
|
# * Example memory types are:
|
||||||
|
@ -106,6 +110,64 @@
|
||||||
#
|
#
|
||||||
# See below for some examples.
|
# See below for some examples.
|
||||||
#
|
#
|
||||||
|
#
|
||||||
|
# The following are STK500 part device codes to use for the
|
||||||
|
# "devicecode" field of the part. These came from Atmel's software
|
||||||
|
# section avr061.zip which accompanies the application note
|
||||||
|
# AVR061 available from:
|
||||||
|
#
|
||||||
|
# http://www.atmel.com/atmel/acrobat/doc2525.pdf
|
||||||
|
#
|
||||||
|
|
||||||
|
#define ATTINY10 0x10
|
||||||
|
#define ATTINY11 0x11
|
||||||
|
#define ATTINY12 0x12
|
||||||
|
|
||||||
|
#define ATTINY22 0x20
|
||||||
|
#define ATTINY26 0x21
|
||||||
|
#define ATTINY28 0x22
|
||||||
|
|
||||||
|
#define AT90S1200 0x33
|
||||||
|
|
||||||
|
#define AT90S2313 0x40
|
||||||
|
#define AT90S2323 0x41
|
||||||
|
#define AT90S2333 0x42
|
||||||
|
#define AT90S2343 0x43
|
||||||
|
|
||||||
|
#define AT90S4414 0x50
|
||||||
|
#define AT90S4433 0x51
|
||||||
|
#define AT90S4434 0x52
|
||||||
|
|
||||||
|
#define AT90S8515 0x60
|
||||||
|
#define AT90S8535 0x61
|
||||||
|
#define AT90C8534 0x62
|
||||||
|
#define ATMEGA8515 0x63
|
||||||
|
#define ATMEGA8535 0x64
|
||||||
|
|
||||||
|
#define ATMEGA8 0x70
|
||||||
|
|
||||||
|
#define ATMEGA161 0x80
|
||||||
|
#define ATMEGA163 0x81
|
||||||
|
#define ATMEGA16 0x82
|
||||||
|
#define ATMEGA162 0x83
|
||||||
|
#define ATMEGA169 0x84
|
||||||
|
|
||||||
|
#define ATMEGA323 0x90
|
||||||
|
#define ATMEGA32 0x91
|
||||||
|
|
||||||
|
#define ATMEGA103 0xB1
|
||||||
|
#define ATMEGA128 0xB2
|
||||||
|
|
||||||
|
#define AT86RF401 0xD0
|
||||||
|
|
||||||
|
#define AT89START 0xE0
|
||||||
|
#define AT89S51 0xE0
|
||||||
|
#define AT89S52 0xE1
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# PROGRAMMER DEFINITIONS
|
||||||
|
#
|
||||||
|
|
||||||
programmer
|
programmer
|
||||||
id = "bsd", "default";
|
id = "bsd", "default";
|
||||||
|
@ -165,55 +227,9 @@ programmer
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#
|
||||||
|
# PART DEFINITIONS
|
||||||
|
#
|
||||||
#define ATTINY10 0x10
|
|
||||||
#define ATTINY11 0x11
|
|
||||||
#define ATTINY12 0x12
|
|
||||||
|
|
||||||
#define ATTINY22 0x20
|
|
||||||
#define ATTINY26 0x21
|
|
||||||
#define ATTINY28 0x22
|
|
||||||
|
|
||||||
#define AT90S1200 0x33
|
|
||||||
|
|
||||||
#define AT90S2313 0x40
|
|
||||||
#define AT90S2323 0x41
|
|
||||||
#define AT90S2333 0x42
|
|
||||||
#define AT90S2343 0x43
|
|
||||||
|
|
||||||
#define AT90S4414 0x50
|
|
||||||
#define AT90S4433 0x51
|
|
||||||
#define AT90S4434 0x52
|
|
||||||
|
|
||||||
#define AT90S8515 0x60
|
|
||||||
#define AT90S8535 0x61
|
|
||||||
#define AT90C8534 0x62
|
|
||||||
#define ATMEGA8515 0x63
|
|
||||||
#define ATMEGA8535 0x64
|
|
||||||
|
|
||||||
#define ATMEGA8 0x70
|
|
||||||
|
|
||||||
#define ATMEGA161 0x80
|
|
||||||
#define ATMEGA163 0x81
|
|
||||||
#define ATMEGA16 0x82
|
|
||||||
#define ATMEGA162 0x83
|
|
||||||
#define ATMEGA169 0x84
|
|
||||||
|
|
||||||
#define ATMEGA323 0x90
|
|
||||||
#define ATMEGA32 0x91
|
|
||||||
|
|
||||||
#define ATMEGA103 0xB1
|
|
||||||
#define ATMEGA128 0xB2
|
|
||||||
|
|
||||||
#define AT86RF401 0xD0
|
|
||||||
|
|
||||||
#define AT89START 0xE0
|
|
||||||
#define AT89S51 0xE0
|
|
||||||
#define AT89S52 0xE1
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
part
|
part
|
||||||
|
|
|
@ -103,9 +103,10 @@ extern char * lists_version;
|
||||||
extern char * main_version;
|
extern char * main_version;
|
||||||
extern char * pgm_version;
|
extern char * pgm_version;
|
||||||
extern char * ppi_version;
|
extern char * ppi_version;
|
||||||
|
extern char * stk500_version;
|
||||||
extern char * term_version;
|
extern char * term_version;
|
||||||
|
|
||||||
#define N_MODULES 8
|
#define N_MODULES 9
|
||||||
|
|
||||||
char ** modules[N_MODULES] = {
|
char ** modules[N_MODULES] = {
|
||||||
&avr_version,
|
&avr_version,
|
||||||
|
@ -115,10 +116,11 @@ char ** modules[N_MODULES] = {
|
||||||
&main_version,
|
&main_version,
|
||||||
&pgm_version,
|
&pgm_version,
|
||||||
&ppi_version,
|
&ppi_version,
|
||||||
|
&stk500_version,
|
||||||
&term_version
|
&term_version
|
||||||
};
|
};
|
||||||
|
|
||||||
char * version = "2.1.5";
|
char * version = "3.0.0";
|
||||||
|
|
||||||
char * main_version = "$Id$";
|
char * main_version = "$Id$";
|
||||||
|
|
||||||
|
@ -189,7 +191,7 @@ int parse_cvsid(char * cvsid, char * name, char * rev, char * datetime)
|
||||||
{
|
{
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
if (strncmp(cvsid,"$Id: ",5) != 0)
|
if (strncmp(cvsid,"$Id: ", 5) != 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
name[0] = 0;
|
name[0] = 0;
|
||||||
|
|
|
@ -53,6 +53,7 @@ typedef struct programmer_t {
|
||||||
unsigned int pinno[N_PINS];
|
unsigned int pinno[N_PINS];
|
||||||
int ppidata;
|
int ppidata;
|
||||||
int fd;
|
int fd;
|
||||||
|
int page_size; /* page size if the programmer supports paged write/load */
|
||||||
int (*rdy_led) (struct programmer_t * pgm, int value);
|
int (*rdy_led) (struct programmer_t * pgm, int value);
|
||||||
int (*err_led) (struct programmer_t * pgm, int value);
|
int (*err_led) (struct programmer_t * pgm, int value);
|
||||||
int (*pgm_led) (struct programmer_t * pgm, int value);
|
int (*pgm_led) (struct programmer_t * pgm, int value);
|
||||||
|
@ -72,9 +73,9 @@ typedef struct programmer_t {
|
||||||
void (*open) (struct programmer_t * pgm, char * port);
|
void (*open) (struct programmer_t * pgm, char * port);
|
||||||
void (*close) (struct programmer_t * pgm);
|
void (*close) (struct programmer_t * pgm);
|
||||||
int (*paged_write) (struct programmer_t * pgm, AVRPART * p, AVRMEM * m,
|
int (*paged_write) (struct programmer_t * pgm, AVRPART * p, AVRMEM * m,
|
||||||
int n_bytes);
|
int page_size, int n_bytes);
|
||||||
int (*paged_load) (struct programmer_t * pgm, AVRPART * p, AVRMEM * m,
|
int (*paged_load) (struct programmer_t * pgm, AVRPART * p, AVRMEM * m,
|
||||||
int n_bytes);
|
int page_size, int n_bytes);
|
||||||
} PROGRAMMER;
|
} PROGRAMMER;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -737,7 +737,8 @@ static int loadaddr(PROGRAMMER * pgm, uint16_t addr)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int stk500_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, int n_bytes)
|
int stk500_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
||||||
|
int page_size, int n_bytes)
|
||||||
{
|
{
|
||||||
unsigned char buf[16];
|
unsigned char buf[16];
|
||||||
int memtype;
|
int memtype;
|
||||||
|
@ -747,9 +748,6 @@ int stk500_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, int n_bytes)
|
||||||
int tries;
|
int tries;
|
||||||
unsigned int n;
|
unsigned int n;
|
||||||
|
|
||||||
if (!m->paged)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (strcmp(m->desc, "flash") == 0) {
|
if (strcmp(m->desc, "flash") == 0) {
|
||||||
memtype = 'F';
|
memtype = 'F';
|
||||||
}
|
}
|
||||||
|
@ -760,7 +758,7 @@ int stk500_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, int n_bytes)
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m->op[AVR_OP_LOADPAGE_LO])
|
if ((m->op[AVR_OP_LOADPAGE_LO]) || (m->op[AVR_OP_READ_LO]))
|
||||||
a_div = 2;
|
a_div = 2;
|
||||||
else
|
else
|
||||||
a_div = 1;
|
a_div = 1;
|
||||||
|
@ -770,26 +768,26 @@ int stk500_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, int n_bytes)
|
||||||
n = m->size;
|
n = m->size;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ((n_bytes % m->page_size) != 0) {
|
if ((n_bytes % page_size) != 0) {
|
||||||
n = n_bytes + m->page_size - (n_bytes % m->page_size);
|
n = n_bytes + page_size - (n_bytes % page_size);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
n = n_bytes;
|
n = n_bytes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (addr = 0; addr < n; addr += m->page_size) {
|
for (addr = 0; addr < n; addr += page_size) {
|
||||||
fprintf(stderr, "\r \r%6u", addr);
|
fprintf(stderr, "\r \r%6u", addr);
|
||||||
tries = 0;
|
tries = 0;
|
||||||
retry:
|
retry:
|
||||||
tries++;
|
tries++;
|
||||||
loadaddr(pgm, addr/a_div);
|
loadaddr(pgm, addr/a_div);
|
||||||
buf[0] = Cmnd_STK_PROG_PAGE;
|
buf[0] = Cmnd_STK_PROG_PAGE;
|
||||||
buf[1] = (m->page_size >> 8) & 0xff;
|
buf[1] = (page_size >> 8) & 0xff;
|
||||||
buf[2] = m->page_size & 0xff;
|
buf[2] = page_size & 0xff;
|
||||||
buf[3] = memtype;
|
buf[3] = memtype;
|
||||||
send(pgm, buf, 4);
|
send(pgm, buf, 4);
|
||||||
for (i=0; i<m->page_size; i++) {
|
for (i=0; i<page_size; i++) {
|
||||||
buf[0] = m->buf[addr + i];
|
buf[0] = m->buf[addr + i];
|
||||||
send(pgm, buf, 1);
|
send(pgm, buf, 1);
|
||||||
}
|
}
|
||||||
|
@ -830,7 +828,8 @@ int stk500_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, int n_bytes)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int stk500_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, int n_bytes)
|
int stk500_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
||||||
|
int page_size, int n_bytes)
|
||||||
{
|
{
|
||||||
unsigned char buf[16];
|
unsigned char buf[16];
|
||||||
int memtype;
|
int memtype;
|
||||||
|
@ -839,9 +838,6 @@ int stk500_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, int n_bytes)
|
||||||
int tries;
|
int tries;
|
||||||
unsigned int n;
|
unsigned int n;
|
||||||
|
|
||||||
if (!m->paged)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
if (strcmp(m->desc, "flash") == 0) {
|
if (strcmp(m->desc, "flash") == 0) {
|
||||||
memtype = 'F';
|
memtype = 'F';
|
||||||
}
|
}
|
||||||
|
@ -852,7 +848,7 @@ int stk500_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, int n_bytes)
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m->op[AVR_OP_LOADPAGE_LO])
|
if ((m->op[AVR_OP_LOADPAGE_LO]) || (m->op[AVR_OP_READ_LO]))
|
||||||
a_div = 2;
|
a_div = 2;
|
||||||
else
|
else
|
||||||
a_div = 1;
|
a_div = 1;
|
||||||
|
@ -862,23 +858,26 @@ int stk500_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, int n_bytes)
|
||||||
n = m->size;
|
n = m->size;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ((n_bytes % m->page_size) != 0) {
|
if ((n_bytes % page_size) != 0) {
|
||||||
n = n_bytes + m->page_size - (n_bytes % m->page_size);
|
n = n_bytes + page_size - (n_bytes % page_size);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
n = n_bytes;
|
n = n_bytes;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (addr = 0; addr < n; addr += m->page_size) {
|
fprintf(stderr, "%s: stk500_paged_load(): n=%d, a_div=%d\n",
|
||||||
|
progname, n, a_div);
|
||||||
|
|
||||||
|
for (addr = 0; addr < n; addr += page_size) {
|
||||||
fprintf(stderr, "\r \r%6u", addr);
|
fprintf(stderr, "\r \r%6u", addr);
|
||||||
tries = 0;
|
tries = 0;
|
||||||
retry:
|
retry:
|
||||||
tries++;
|
tries++;
|
||||||
loadaddr(pgm, addr/a_div);
|
loadaddr(pgm, addr/a_div);
|
||||||
buf[0] = Cmnd_STK_READ_PAGE;
|
buf[0] = Cmnd_STK_READ_PAGE;
|
||||||
buf[1] = (m->page_size >> 8) & 0xff;
|
buf[1] = (page_size >> 8) & 0xff;
|
||||||
buf[2] = m->page_size & 0xff;
|
buf[2] = page_size & 0xff;
|
||||||
buf[3] = memtype;
|
buf[3] = memtype;
|
||||||
buf[4] = Sync_CRC_EOP;
|
buf[4] = Sync_CRC_EOP;
|
||||||
send(pgm, buf, 5);
|
send(pgm, buf, 5);
|
||||||
|
@ -901,7 +900,7 @@ int stk500_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, int n_bytes)
|
||||||
return -4;
|
return -4;
|
||||||
}
|
}
|
||||||
|
|
||||||
recv(pgm, &m->buf[addr], m->page_size);
|
recv(pgm, &m->buf[addr], page_size);
|
||||||
|
|
||||||
recv(pgm, buf, 1);
|
recv(pgm, buf, 1);
|
||||||
if (buf[0] != Resp_STK_OK) {
|
if (buf[0] != Resp_STK_OK) {
|
||||||
|
@ -1020,6 +1019,7 @@ void stk500_initpgm(PROGRAMMER * pgm)
|
||||||
*/
|
*/
|
||||||
pgm->paged_write = stk500_paged_write;
|
pgm->paged_write = stk500_paged_write;
|
||||||
pgm->paged_load = stk500_paged_load;
|
pgm->paged_load = stk500_paged_load;
|
||||||
|
pgm->page_size = 256;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue