Submitted by freckle@sf.net:

* stk500.c (stk500_paged_write): Send the command and the data
payload within a single write().
patch #5025: Improve stk500.c robustness

Submitted by Matthias Ringwald:
* stk500.c (stk500_open): do not flush the serial line after
getting in sync with the programmer.
patch #5293: stk500.c: no drain after sync (-> allow BTnode
Bootloader to work on cygwin)


git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@670 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
Joerg Wunsch 2006-10-09 09:56:10 +00:00
parent a0e56daa3b
commit 57028107ff
2 changed files with 26 additions and 12 deletions

View File

@ -1,3 +1,16 @@
2006-10-09 Joerg Wunsch <j@uriah.heep.sax.de>
Submitted by freckle@sf.net:
* stk500.c (stk500_paged_write): Send the command and the data
payload within a single write().
patch #5025: Improve stk500.c robustness
Submitted by Matthias Ringwald:
* stk500.c (stk500_open): do not flush the serial line after
getting in sync with the programmer.
patch #5293: stk500.c: no drain after sync (-> allow BTnode
Bootloader to work on cygwin)
2006-09-29 Joerg Wunsch <j@uriah.heep.sax.de> 2006-09-29 Joerg Wunsch <j@uriah.heep.sax.de>
* pgm.h: Fix prototype for gettimeofday(). * pgm.h: Fix prototype for gettimeofday().

View File

@ -590,8 +590,6 @@ static int stk500_open(PROGRAMMER * pgm, char * port)
if (stk500_getsync(pgm) < 0) if (stk500_getsync(pgm) < 0)
return -1; return -1;
stk500_drain(pgm, 0);
return 0; return 0;
} }
@ -656,13 +654,14 @@ static int stk500_loadaddr(PROGRAMMER * pgm, unsigned int addr)
static int stk500_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, static int stk500_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
int page_size, int n_bytes) int page_size, int n_bytes)
{ {
unsigned char buf[16]; unsigned char buf[page_size + 16];
int memtype; int memtype;
unsigned int addr; unsigned int addr;
int a_div; int a_div;
int block_size; int block_size;
int tries; int tries;
unsigned int n; unsigned int n;
unsigned int i;
int flash; int flash;
if (page_size == 0) { if (page_size == 0) {
@ -728,16 +727,18 @@ static int stk500_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
retry: retry:
tries++; tries++;
stk500_loadaddr(pgm, addr/a_div); stk500_loadaddr(pgm, addr/a_div);
buf[0] = Cmnd_STK_PROG_PAGE;
buf[1] = (block_size >> 8) & 0xff;
buf[2] = block_size & 0xff;
buf[3] = memtype;
stk500_send(pgm, buf, 4);
stk500_send(pgm, &m->buf[addr], block_size); /* build command block and avoid multiple send commands as it leads to a crash
of the silabs usb serial driver on mac os x */
buf[0] = Sync_CRC_EOP; i = 0;
stk500_send(pgm, buf, 1); buf[i++] = Cmnd_STK_PROG_PAGE;
buf[i++] = (block_size >> 8) & 0xff;
buf[i++] = block_size & 0xff;
buf[i++] = memtype;
memcpy(&buf[i], &m->buf[addr], block_size);
i += block_size;
buf[i++] = Sync_CRC_EOP;
stk500_send( pgm, buf, i);
if (stk500_recv(pgm, buf, 1) < 0) if (stk500_recv(pgm, buf, 1) < 0)
exit(1); exit(1);