diff --git a/src/dryrun.c b/src/dryrun.c index 3793aacd..702349cc 100644 --- a/src/dryrun.c +++ b/src/dryrun.c @@ -212,7 +212,7 @@ static int dryrun_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const AVR Return("no dryrun device? Raise an issue at https://github.com/avrdudes/avrdude/issues"); if(n_bytes) { - AVRMEM *dmem; + AVRMEM *dmem, *dm2; int mchr, chunk; unsigned int end; @@ -237,6 +237,24 @@ static int dryrun_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const AVR for(; addr < end; addr += chunk) { chunk = end-addr < page_size? end-addr: page_size; (mchr == 'F'? memand: memcpy)(dmem->buf+addr, m->buf+addr, chunk); + + // Copy chunk to overlapping XMEGA's apptable, application, boot and flash memories + if(mchr == 'F') { + if(str_eq(dmem->desc, "flash")) { + for(LNODEID ln=lfirst(dry.dp->mem); ln; ln=lnext(ln)) { + dm2 = ldata(ln); + if(avr_mem_is_flash_type(dm2) && !str_eq(dm2->desc, "flash")) { // Overlapping region? + unsigned int cpaddr = addr + dmem->offset - dm2->offset; + if(cpaddr < (unsigned int) dm2->size && cpaddr + chunk <= (unsigned int) dm2->size) + memcpy(dm2->buf+cpaddr, dmem->buf+addr, chunk); + } + } + } else if((dm2 = avr_locate_mem(dry.dp, "flash"))) { + unsigned int cpaddr = addr + dmem->offset - dm2->offset; + if(cpaddr < (unsigned int) dm2->size && cpaddr + chunk <= (unsigned int) dm2->size) + memcpy(dm2->buf+cpaddr, dmem->buf+addr, chunk); + } + } } }