Merge pull request #828 from dl8dtl/fix-tpi-fuse-write

Fix for TPI fuse write (closes #823)
This commit is contained in:
Jörg Wunsch 2022-01-11 22:12:37 +01:00 committed by GitHub
commit dc2f5b25a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 0 deletions

View File

@ -867,6 +867,11 @@ int avr_write(PROGRAMMER * pgm, AVRPART * p, char * memtype, int size,
if ((p->flags & AVRPART_HAS_TPI) && m->page_size > 1 && if ((p->flags & AVRPART_HAS_TPI) && m->page_size > 1 &&
pgm->cmd_tpi != NULL) { pgm->cmd_tpi != NULL) {
if (wsize == 1) {
/* fuse (configuration) memory: only single byte to write */
return avr_write_byte(pgm, p, m, 0, m->buf[0]) == 0? 1: -1;
}
while (avr_tpi_poll_nvmbsy(pgm)); while (avr_tpi_poll_nvmbsy(pgm));
/* setup for WORD_WRITE */ /* setup for WORD_WRITE */
@ -1074,6 +1079,11 @@ static uint8_t get_fuse_bitmask(AVRMEM * m) {
return 0xFF; return 0xFF;
} }
if (m->op[AVR_OP_WRITE] == NULL ||
m->op[AVR_OP_READ] == NULL)
// no memory operations provided by configuration, compare directly
return 0xFF;
// For fuses, only compare bytes that are actually written *and* read. // For fuses, only compare bytes that are actually written *and* read.
for (i = 0; i < 32; i++) { for (i = 0; i < 32; i++) {
if (m->op[AVR_OP_WRITE]->bit[i].type == AVR_CMDBIT_INPUT) if (m->op[AVR_OP_WRITE]->bit[i].type == AVR_CMDBIT_INPUT)