Fix TPI memory writes for odd number of bytes

This commit is contained in:
Marius Greuel 2022-01-10 23:14:46 +01:00
parent b08dd59ce2
commit 9706426d8f
1 changed files with 8 additions and 9 deletions

View File

@ -853,15 +853,11 @@ int avr_write(PROGRAMMER * pgm, AVRPART * p, char * memtype, int size,
/* setup for WORD_WRITE */
avr_tpi_setup_rw(pgm, m, 0, TPI_NVMCMD_WORD_WRITE);
/* make sure it's aligned to a word boundary */
if (wsize & 0x1) {
wsize++;
}
/* write words, low byte first */
for (lastaddr = i = 0; i < wsize; i += 2) {
bool have_two_bytes = i + 1 < wsize;
if ((m->tags[i] & TAG_ALLOCATED) != 0 ||
(m->tags[i + 1] & TAG_ALLOCATED) != 0) {
(have_two_bytes && m->tags[i + 1] & TAG_ALLOCATED) != 0) {
if (lastaddr != i) {
/* need to setup new address */
@ -873,8 +869,11 @@ int avr_write(PROGRAMMER * pgm, AVRPART * p, char * memtype, int size,
cmd[1] = m->buf[i];
rc = pgm->cmd_tpi(pgm, cmd, 2, NULL, 0);
cmd[1] = m->buf[i + 1];
rc = pgm->cmd_tpi(pgm, cmd, 2, NULL, 0);
if (have_two_bytes)
{
cmd[1] = m->buf[i + 1];
rc = pgm->cmd_tpi(pgm, cmd, 2, NULL, 0);
}
lastaddr += 2;
@ -882,7 +881,7 @@ int avr_write(PROGRAMMER * pgm, AVRPART * p, char * memtype, int size,
}
report_progress(i, wsize, NULL);
}
return i;
return wsize;
}
if (pgm->paged_write != NULL && m->page_size > 1) {