check more error codes, fixed some leftover parts which still used MPSSE even when using bitbanging, reduced blocksize to get a more stable behaviour of bitbanging
git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1185 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
parent
da3961e155
commit
1f8462ca58
10
avr.c
10
avr.c
|
@ -242,7 +242,7 @@ int avr_read_byte_default(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"avr_read_byte(): operation not supported on memory type \"%s\"\n",
|
"avr_read_byte(): operation not supported on memory type \"%s\"\n",
|
||||||
p->desc);
|
mem->desc);
|
||||||
#endif
|
#endif
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -256,14 +256,18 @@ int avr_read_byte_default(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
|
||||||
|
|
||||||
avr_set_bits(lext, cmd);
|
avr_set_bits(lext, cmd);
|
||||||
avr_set_addr(lext, cmd, addr);
|
avr_set_addr(lext, cmd, addr);
|
||||||
pgm->cmd(pgm, cmd, res);
|
r = pgm->cmd(pgm, cmd, res);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(cmd, 0, sizeof(cmd));
|
memset(cmd, 0, sizeof(cmd));
|
||||||
|
|
||||||
avr_set_bits(readop, cmd);
|
avr_set_bits(readop, cmd);
|
||||||
avr_set_addr(readop, cmd, addr);
|
avr_set_addr(readop, cmd, addr);
|
||||||
pgm->cmd(pgm, cmd, res);
|
r = pgm->cmd(pgm, cmd, res);
|
||||||
|
if (r < 0)
|
||||||
|
return r;
|
||||||
data = 0;
|
data = 0;
|
||||||
avr_get_output(readop, res, &data);
|
avr_get_output(readop, res, &data);
|
||||||
|
|
||||||
|
|
36
avrftdi.c
36
avrftdi.c
|
@ -356,7 +356,7 @@ static int avrftdi_transmit_bb(PROGRAMMER * pgm, unsigned char mode, unsigned ch
|
||||||
avrftdi_t* pdata = to_pdata(pgm);
|
avrftdi_t* pdata = to_pdata(pgm);
|
||||||
|
|
||||||
// more than this does not work with FT2232D
|
// more than this does not work with FT2232D
|
||||||
blocksize = 16;//pdata->rx_buffer_size/2; // we are reading 2 bytes per data byte
|
blocksize = 12;//pdata->rx_buffer_size/2; // we are reading 2 bytes per data byte
|
||||||
|
|
||||||
while(remaining)
|
while(remaining)
|
||||||
{
|
{
|
||||||
|
@ -988,21 +988,20 @@ static int avrftdi_chip_erase(PROGRAMMER * pgm, AVRPART * p)
|
||||||
|
|
||||||
/* Load extended address byte command */
|
/* Load extended address byte command */
|
||||||
static int
|
static int
|
||||||
avrftdi_lext(avrftdi_t* pdata, AVRPART *p, AVRMEM *m, unsigned int address)
|
avrftdi_lext(PROGRAMMER *pgm, AVRPART *p, AVRMEM *m, unsigned int address)
|
||||||
{
|
{
|
||||||
unsigned char buf[] =
|
unsigned char buf[] = { 0x00, 0x00, 0x00, 0x00 };
|
||||||
{ MPSSE_DO_WRITE | MPSSE_WRITE_NEG, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00 };
|
|
||||||
|
|
||||||
avr_set_bits(m->op[AVR_OP_LOAD_EXT_ADDR], &buf[3]);
|
avr_set_bits(m->op[AVR_OP_LOAD_EXT_ADDR], buf);
|
||||||
avr_set_addr(m->op[AVR_OP_LOAD_EXT_ADDR], &buf[3], address);
|
avr_set_addr(m->op[AVR_OP_LOAD_EXT_ADDR], buf, address);
|
||||||
|
|
||||||
if(verbose > TRACE)
|
if(verbose > TRACE)
|
||||||
buf_dump(buf, sizeof(buf),
|
buf_dump(buf, sizeof(buf),
|
||||||
"load extended address command", 0, 16 * 3);
|
"load extended address command", 0, 16 * 3);
|
||||||
|
|
||||||
#ifndef DRYRUN
|
#ifndef DRYRUN
|
||||||
E(ftdi_write_data(pdata->ftdic, buf, sizeof(buf)) != sizeof(buf),
|
if (0 > avrftdi_transmit(pgm, MPSSE_DO_WRITE, buf, buf, 4))
|
||||||
pdata->ftdic);
|
return -1;
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1014,14 +1013,15 @@ static int avrftdi_eeprom_write(PROGRAMMER *pgm, AVRPART *p, AVRMEM *m,
|
||||||
unsigned char *data = &m->buf[addr];
|
unsigned char *data = &m->buf[addr];
|
||||||
unsigned int add;
|
unsigned int add;
|
||||||
|
|
||||||
avr_set_bits(m->op[AVR_OP_WRITE], &cmd[3]);
|
avr_set_bits(m->op[AVR_OP_WRITE], cmd);
|
||||||
|
|
||||||
for (add = addr; add < addr + len; add++)
|
for (add = addr; add < addr + len; add++)
|
||||||
{
|
{
|
||||||
avr_set_addr(m->op[AVR_OP_WRITE], cmd, add);
|
avr_set_addr(m->op[AVR_OP_WRITE], cmd, add);
|
||||||
avr_set_input(m->op[AVR_OP_WRITE], cmd, *data++);
|
avr_set_input(m->op[AVR_OP_WRITE], cmd, *data++);
|
||||||
|
|
||||||
avrftdi_transmit(pgm, MPSSE_DO_WRITE, cmd, cmd, 4);
|
if (0 > avrftdi_transmit(pgm, MPSSE_DO_WRITE, cmd, cmd, 4))
|
||||||
|
return -1;
|
||||||
usleep((m->max_write_delay));
|
usleep((m->max_write_delay));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1042,7 +1042,8 @@ static int avrftdi_eeprom_read(PROGRAMMER *pgm, AVRPART *p, AVRMEM *m,
|
||||||
avr_set_bits(m->op[AVR_OP_READ], cmd);
|
avr_set_bits(m->op[AVR_OP_READ], cmd);
|
||||||
avr_set_addr(m->op[AVR_OP_READ], cmd, add);
|
avr_set_addr(m->op[AVR_OP_READ], cmd, add);
|
||||||
|
|
||||||
avrftdi_transmit(pgm, MPSSE_DO_READ | MPSSE_DO_WRITE, cmd, cmd, 4);
|
if (0 > avrftdi_transmit(pgm, MPSSE_DO_READ | MPSSE_DO_WRITE, cmd, cmd, 4))
|
||||||
|
return -1;
|
||||||
|
|
||||||
avr_get_output(m->op[AVR_OP_READ], cmd, bufptr++);
|
avr_get_output(m->op[AVR_OP_READ], cmd, bufptr++);
|
||||||
}
|
}
|
||||||
|
@ -1092,7 +1093,8 @@ static int avrftdi_flash_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
||||||
* write the command only once.
|
* write the command only once.
|
||||||
*/
|
*/
|
||||||
if(use_lext_address && (((addr/2) & 0xffff0000))) {
|
if(use_lext_address && (((addr/2) & 0xffff0000))) {
|
||||||
avrftdi_lext(to_pdata(pgm), p, m, addr/2);
|
if (0 > avrftdi_lext(pgm, p, m, addr/2))
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* prepare the command stream for the whole page */
|
/* prepare the command stream for the whole page */
|
||||||
|
@ -1132,7 +1134,8 @@ static int avrftdi_flash_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
||||||
buf_dump(buf, buf_size, "command buffer", 0, 16*2);
|
buf_dump(buf, buf_size, "command buffer", 0, 16*2);
|
||||||
|
|
||||||
log_info("Transmitting buffer of size: %d\n", buf_size);
|
log_info("Transmitting buffer of size: %d\n", buf_size);
|
||||||
avrftdi_transmit(pgm, MPSSE_DO_WRITE, buf, buf, buf_size);
|
if (0 > avrftdi_transmit(pgm, MPSSE_DO_WRITE, buf, buf, buf_size))
|
||||||
|
return -1;
|
||||||
|
|
||||||
bufptr = buf;
|
bufptr = buf;
|
||||||
/* find a poll byte. we cannot poll a value of 0xff, so look
|
/* find a poll byte. we cannot poll a value of 0xff, so look
|
||||||
|
@ -1183,6 +1186,7 @@ static int avrftdi_flash_read(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
||||||
unsigned char i_buf[4*len+4];
|
unsigned char i_buf[4*len+4];
|
||||||
unsigned int index;
|
unsigned int index;
|
||||||
|
|
||||||
|
|
||||||
memset(o_buf, 0, sizeof(o_buf));
|
memset(o_buf, 0, sizeof(o_buf));
|
||||||
memset(i_buf, 0, sizeof(i_buf));
|
memset(i_buf, 0, sizeof(i_buf));
|
||||||
|
|
||||||
|
@ -1197,7 +1201,8 @@ static int avrftdi_flash_read(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
||||||
}
|
}
|
||||||
|
|
||||||
if(use_lext_address && ((address & 0xffff0000))) {
|
if(use_lext_address && ((address & 0xffff0000))) {
|
||||||
avrftdi_lext(to_pdata(pgm), p, m, address);
|
if (0 > avrftdi_lext(pgm, p, m, address))
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* word addressing! */
|
/* word addressing! */
|
||||||
|
@ -1222,7 +1227,8 @@ static int avrftdi_flash_read(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
|
||||||
buf_dump(o_buf, sizeof(o_buf), "o_buf", 0, 32);
|
buf_dump(o_buf, sizeof(o_buf), "o_buf", 0, 32);
|
||||||
}
|
}
|
||||||
|
|
||||||
avrftdi_transmit(pgm, MPSSE_DO_READ | MPSSE_DO_WRITE, o_buf, i_buf, len * 4);
|
if (0 > avrftdi_transmit(pgm, MPSSE_DO_READ | MPSSE_DO_WRITE, o_buf, i_buf, len * 4))
|
||||||
|
return -1;
|
||||||
|
|
||||||
if(verbose > TRACE) {
|
if(verbose > TRACE) {
|
||||||
buf_dump(i_buf, sizeof(i_buf), "i_buf", 0, 32);
|
buf_dump(i_buf, sizeof(i_buf), "i_buf", 0, 32);
|
||||||
|
|
Loading…
Reference in New Issue