diff --git a/avrdude/ChangeLog b/avrdude/ChangeLog index 41034de9..c2261d54 100644 --- a/avrdude/ChangeLog +++ b/avrdude/ChangeLog @@ -1,3 +1,9 @@ +2003-04-09 Theodore A. Roth + + * avr910.c: Reading a 16 bit word in paged load needs to swap the + bytes since the 'R' command returns MSB first and the internal buffer + stores LSB first. + 2003-04-07 Theodore A. Roth * stk500.c: Don't print out read/write byte progress unless the verbose diff --git a/avrdude/avr910.c b/avrdude/avr910.c index 7a5a93da..9520b51c 100644 --- a/avrdude/avr910.c +++ b/avrdude/avr910.c @@ -572,6 +572,7 @@ static int avr910_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, int rd_size; unsigned int addr = 0; unsigned int max_addr; + unsigned char buf[2]; if (strcmp(m->desc, "flash") == 0) { cmd = 'R'; @@ -591,7 +592,16 @@ static int avr910_paged_load(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m, while (addr < max_addr) { avr910_send(pgm, &cmd, 1); - avr910_recv(pgm, &m->buf[addr], rd_size); + if (cmd == 'R') { + /* The 'R' command returns two bytes, MSB first, we need to put the data + into the memory buffer LSB first. */ + avr910_recv(pgm, buf, 2); + m->buf[addr*2] = buf[1]; /* LSB */ + m->buf[addr*2+1] = buf[0]; /* MSB */ + } + else { + avr910_recv(pgm, &m->buf[addr], 1); + } addr++;