mirror of
https://github.com/avrdudes/avrdude.git
synced 2026-09-24 01:56:25 +03:00
Merge pull request #1486 from stefanrueger/overlapping-memories
Fix overapping XMEGA flash memories for dryrun programmer
This commit is contained in:
20
src/dryrun.c
20
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user