Consider avr_write_byte_default() skips unnecessary writes

This commit is contained in:
Stefan Rueger
2026-03-25 21:30:39 +00:00
parent bfba3364d5
commit f062636a25
2 changed files with 10 additions and 6 deletions

View File

@@ -916,6 +916,9 @@ rcerror:
int avr_update_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem,
unsigned long addr, unsigned char data) {
if(pgm->write_byte == avr_write_byte_default) // avr_write_byte_default() already updates
return avr_write_byte(pgm, p, mem, addr, data);
pmsg_debug("%s(%s, %s, %s, %s, 0x%02x)\n", __func__, pgmid, p->id, mem->desc,
str_ccaddress(addr, mem->size), data);
@@ -928,9 +931,8 @@ int avr_update_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *mem,
return -1;
}
if(pgm->write_byte != avr_write_byte_default)
if(!(p->prog_modes & (PM_UPDI | PM_aWire))) // Initialise unused bits in classic & XMEGA parts
data = avr_bitmask_data(pgm, p, mem, addr, data);
if(!(p->prog_modes & (PM_UPDI | PM_aWire))) // Initialise unused bits in classic & XMEGA parts
data = avr_bitmask_data(pgm, p, mem, addr, data);
return pgm->write_byte(pgm, p, mem, addr, data);
}

View File

@@ -198,6 +198,9 @@ int led_chip_erase(const PROGRAMMER *pgm, const AVRPART *p) {
// Programmer specific update byte function with ERR/PGM LED info (ie, only write if data not there)
int led_update_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *m, unsigned long addr, unsigned char value) {
if(pgm->write_byte == avr_write_byte_default) // avr_write_byte_default() already updates
return led_write_byte(pgm, p, m, addr, value);
pmsg_debug("%s(%s, %s, %s, %s, 0x%02x)\n", __func__, pgmid, p->id, m->desc, str_ccaddress(addr, m->size), value);
if(avr_can_skip_write_byte(pgm, p, m, addr, value, NULL))
@@ -209,9 +212,8 @@ int led_update_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *m, un
return -1;
}
if(pgm->write_byte != avr_write_byte_default)
if(!(p->prog_modes & (PM_UPDI | PM_aWire))) // Initialise unused bits in classic & XMEGA parts
value = avr_bitmask_data(pgm, p, m, addr, value);
if(!(p->prog_modes & (PM_UPDI | PM_aWire))) // Initialise unused bits in classic & XMEGA parts
value = avr_bitmask_data(pgm, p, m, addr, value);
led_clr(pgm, LED_ERR);
led_set(pgm, LED_PGM);