I thought I had already committed this but I don't see it in CVS.
This fixes EEPROM access using the STK500V2 programmer, partially undoing part of a previous general fixup commit. Choose the correct read/write operations with the stk500v2 program function - the correct one depends on the memory type. EEPROM is byte addressable so uses read/write. FLASH is word addressable and so uses read_lo/write_lo. git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk@501 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
parent
66a5f13b2c
commit
ae1a671a68
|
@ -1790,12 +1790,12 @@ part
|
||||||
max_write_delay = 9000;
|
max_write_delay = 9000;
|
||||||
readback_p1 = 0xff;
|
readback_p1 = 0xff;
|
||||||
readback_p2 = 0xff;
|
readback_p2 = 0xff;
|
||||||
read_lo = " 1 0 1 0 0 0 0 0",
|
read = " 1 0 1 0 0 0 0 0",
|
||||||
" x x x x a11 a10 a9 a8",
|
" x x x x a11 a10 a9 a8",
|
||||||
" a7 a6 a5 a4 a3 a2 a1 a0",
|
" a7 a6 a5 a4 a3 a2 a1 a0",
|
||||||
" o o o o o o o o";
|
" o o o o o o o o";
|
||||||
|
|
||||||
write_lo = " 1 1 0 0 0 0 0 0",
|
write = " 1 1 0 0 0 0 0 0",
|
||||||
" x x x x a11 a10 a9 a8",
|
" x x x x a11 a10 a9 a8",
|
||||||
" a7 a6 a5 a4 a3 a2 a1 a0",
|
" a7 a6 a5 a4 a3 a2 a1 a0",
|
||||||
" i i i i i i i i";
|
" i i i i i i i i";
|
||||||
|
@ -1943,12 +1943,12 @@ part
|
||||||
max_write_delay = 9000;
|
max_write_delay = 9000;
|
||||||
readback_p1 = 0xff;
|
readback_p1 = 0xff;
|
||||||
readback_p2 = 0xff;
|
readback_p2 = 0xff;
|
||||||
read_lo = " 1 0 1 0 0 0 0 0",
|
read = " 1 0 1 0 0 0 0 0",
|
||||||
" x x x x a11 a10 a9 a8",
|
" x x x x a11 a10 a9 a8",
|
||||||
" a7 a6 a5 a4 a3 a2 a1 a0",
|
" a7 a6 a5 a4 a3 a2 a1 a0",
|
||||||
" o o o o o o o o";
|
" o o o o o o o o";
|
||||||
|
|
||||||
write_lo = " 1 1 0 0 0 0 0 0",
|
write = " 1 1 0 0 0 0 0 0",
|
||||||
" x x x x a11 a10 a9 a8",
|
" x x x x a11 a10 a9 a8",
|
||||||
" a7 a6 a5 a4 a3 a2 a1 a0",
|
" a7 a6 a5 a4 a3 a2 a1 a0",
|
||||||
" i i i i i i i i";
|
" i i i i i i i i";
|
||||||
|
|
|
@ -501,6 +501,7 @@ static int stk500v2_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
||||||
unsigned char buf[266];
|
unsigned char buf[266];
|
||||||
unsigned char cmds[4];
|
unsigned char cmds[4];
|
||||||
int result;
|
int result;
|
||||||
|
OPCODE * rop, * wop;
|
||||||
|
|
||||||
DEBUG("STK500V2: stk500v2_paged_write(..,%s,%d,%d)\n",m->desc,page_size,n_bytes);
|
DEBUG("STK500V2: stk500v2_paged_write(..,%s,%d,%d)\n",m->desc,page_size,n_bytes);
|
||||||
|
|
||||||
|
@ -515,9 +516,18 @@ static int stk500v2_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
||||||
}
|
}
|
||||||
commandbuf[4] = m->delay;
|
commandbuf[4] = m->delay;
|
||||||
|
|
||||||
|
if (a_div == 1) {
|
||||||
|
wop = m->op[AVR_OP_WRITE];
|
||||||
|
rop = m->op[AVR_OP_READ];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
wop = m->op[AVR_OP_WRITE_LO];
|
||||||
|
rop = m->op[AVR_OP_READ_LO];
|
||||||
|
}
|
||||||
|
|
||||||
// if the memory is paged, load the appropriate commands into the buffer
|
// if the memory is paged, load the appropriate commands into the buffer
|
||||||
if (m->mode & 0x01) {
|
if (m->mode & 0x01) {
|
||||||
commandbuf[3] = m->mode | 0x80; // yes, write the stupid page to flash
|
commandbuf[3] = m->mode | 0x80; // yes, write the page to flash
|
||||||
|
|
||||||
if (m->op[AVR_OP_LOADPAGE_LO] == NULL) {
|
if (m->op[AVR_OP_LOADPAGE_LO] == NULL) {
|
||||||
fprintf(stderr, "%s: stk500v2_paged_write: loadpage instruction not defined for part \"%s\"\n",
|
fprintf(stderr, "%s: stk500v2_paged_write: loadpage instruction not defined for part \"%s\"\n",
|
||||||
|
@ -536,26 +546,27 @@ static int stk500v2_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
||||||
commandbuf[6] = cmds[0];
|
commandbuf[6] = cmds[0];
|
||||||
|
|
||||||
// otherwise, we need to load different commands in
|
// otherwise, we need to load different commands in
|
||||||
} else {
|
}
|
||||||
commandbuf[3] = m->mode | 0x80; // yes, write the stupid words to flash
|
else {
|
||||||
|
commandbuf[3] = m->mode | 0x80; // yes, write the words to flash
|
||||||
|
|
||||||
if (m->op[AVR_OP_WRITE_LO] == NULL) {
|
if (wop == NULL) {
|
||||||
fprintf(stderr, "%s: stk500v2_paged_write: write instruction not defined for part \"%s\"\n",
|
fprintf(stderr, "%s: stk500v2_paged_write: write instruction not defined for part \"%s\"\n",
|
||||||
progname, p->desc);
|
progname, p->desc);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
avr_set_bits(m->op[AVR_OP_WRITE_LO], cmds);
|
avr_set_bits(wop, cmds);
|
||||||
commandbuf[5] = cmds[0];
|
commandbuf[5] = cmds[0];
|
||||||
commandbuf[6] = 0;
|
commandbuf[6] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// the read command is common to both methods
|
// the read command is common to both methods
|
||||||
if (m->op[AVR_OP_READ_LO] == NULL) {
|
if (rop == NULL) {
|
||||||
fprintf(stderr, "%s: stk500v2_paged_write: read instruction not defined for part \"%s\"\n",
|
fprintf(stderr, "%s: stk500v2_paged_write: read instruction not defined for part \"%s\"\n",
|
||||||
progname, p->desc);
|
progname, p->desc);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
avr_set_bits(m->op[AVR_OP_READ_LO], cmds);
|
avr_set_bits(rop, cmds);
|
||||||
commandbuf[7] = cmds[0];
|
commandbuf[7] = cmds[0];
|
||||||
|
|
||||||
commandbuf[8] = m->readback[0];
|
commandbuf[8] = m->readback[0];
|
||||||
|
@ -625,25 +636,30 @@ static int stk500v2_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
||||||
unsigned char buf[275]; // max buffer size for stk500v2 at this point
|
unsigned char buf[275]; // max buffer size for stk500v2 at this point
|
||||||
unsigned char cmds[4];
|
unsigned char cmds[4];
|
||||||
int result;
|
int result;
|
||||||
|
OPCODE * rop;
|
||||||
|
|
||||||
DEBUG("STK500V2: stk500v2_paged_load(..,%s,%d,%d)\n",m->desc,page_size,n_bytes);
|
DEBUG("STK500V2: stk500v2_paged_load(..,%s,%d,%d)\n",m->desc,page_size,n_bytes);
|
||||||
|
|
||||||
page_size = m->readsize;
|
page_size = m->readsize;
|
||||||
|
|
||||||
|
rop = m->op[AVR_OP_READ];
|
||||||
|
|
||||||
// determine which command is to be used
|
// determine which command is to be used
|
||||||
if (strcmp(m->desc, "flash") == 0) {
|
if (strcmp(m->desc, "flash") == 0) {
|
||||||
commandbuf[0] = CMD_READ_FLASH_ISP;
|
commandbuf[0] = CMD_READ_FLASH_ISP;
|
||||||
} else if (strcmp(m->desc, "eeprom") == 0) {
|
rop = m->op[AVR_OP_READ_LO];
|
||||||
|
}
|
||||||
|
else if (strcmp(m->desc, "eeprom") == 0) {
|
||||||
commandbuf[0] = CMD_READ_EEPROM_ISP;
|
commandbuf[0] = CMD_READ_EEPROM_ISP;
|
||||||
}
|
}
|
||||||
|
|
||||||
// the read command is common to both methods
|
// the read command is common to both methods
|
||||||
if (m->op[AVR_OP_READ_LO] == NULL) {
|
if (rop == NULL) {
|
||||||
fprintf(stderr, "%s: stk500v2_paged_load: read instruction not defined for part \"%s\"\n",
|
fprintf(stderr, "%s: stk500v2_paged_load: read instruction not defined for part \"%s\"\n",
|
||||||
progname, p->desc);
|
progname, p->desc);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
avr_set_bits(m->op[AVR_OP_READ_LO], cmds);
|
avr_set_bits(rop, cmds);
|
||||||
commandbuf[3] = cmds[0];
|
commandbuf[3] = cmds[0];
|
||||||
|
|
||||||
stk500v2_loadaddr(pgm, 0);
|
stk500v2_loadaddr(pgm, 0);
|
||||||
|
|
Loading…
Reference in New Issue