Fix jtag3_page_erase for targets with UPDI
Very handy to have now that #1106 is merged
This commit is contained in:
parent
cd79f81747
commit
d5e4ed9f89
13
src/jtag3.c
13
src/jtag3.c
|
@ -1687,8 +1687,8 @@ static int jtag3_page_erase(const PROGRAMMER *pgm, const AVRPART *p, const AVRME
|
||||||
avrdude_message(MSG_NOTICE2, "%s: jtag3_page_erase(.., %s, 0x%x)\n",
|
avrdude_message(MSG_NOTICE2, "%s: jtag3_page_erase(.., %s, 0x%x)\n",
|
||||||
progname, m->desc, addr);
|
progname, m->desc, addr);
|
||||||
|
|
||||||
if (!(p->prog_modes & PM_PDI)) {
|
if (!(p->prog_modes & (PM_PDI | PM_UPDI))) {
|
||||||
avrdude_message(MSG_INFO, "%s: jtag3_page_erase: not an Xmega device\n",
|
avrdude_message(MSG_INFO, "%s: jtag3_page_erase: not supported\n",
|
||||||
progname);
|
progname);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1701,7 +1701,7 @@ static int jtag3_page_erase(const PROGRAMMER *pgm, const AVRPART *p, const AVRME
|
||||||
cmd[2] = 0;
|
cmd[2] = 0;
|
||||||
|
|
||||||
if (strcmp(m->desc, "flash") == 0) {
|
if (strcmp(m->desc, "flash") == 0) {
|
||||||
if (jtag3_memtype(pgm, p, addr) == MTYPE_FLASH)
|
if (p->prog_modes & PM_UPDI || jtag3_memtype(pgm, p, addr) == MTYPE_FLASH)
|
||||||
cmd[3] = XMEGA_ERASE_APP_PAGE;
|
cmd[3] = XMEGA_ERASE_APP_PAGE;
|
||||||
else
|
else
|
||||||
cmd[3] = XMEGA_ERASE_BOOT_PAGE;
|
cmd[3] = XMEGA_ERASE_BOOT_PAGE;
|
||||||
|
@ -1716,8 +1716,13 @@ static int jtag3_page_erase(const PROGRAMMER *pgm, const AVRPART *p, const AVRME
|
||||||
cmd[3] = XMEGA_ERASE_APP_PAGE;
|
cmd[3] = XMEGA_ERASE_APP_PAGE;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32_to_b4(cmd + 4, addr + m->offset);
|
unsigned int addr_adj = addr;
|
||||||
|
if(p->prog_modes & PM_PDI)
|
||||||
|
addr_adj += m->offset;
|
||||||
|
else // PM_UPDI
|
||||||
|
addr_adj = jtag3_memaddr(pgm, p, m, addr);
|
||||||
|
|
||||||
|
u32_to_b4(cmd + 4, addr_adj);
|
||||||
if (jtag3_command(pgm, cmd, 8, &resp, "page erase") < 0)
|
if (jtag3_command(pgm, cmd, 8, &resp, "page erase") < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue