Offload the programming interface info from part->flags to part->prog_modes
flags now just hold parameters of the JTAG interface and some secondary serial, parallel, pseudo parallel info. This separation brings clarity. It used to be hard to augur whether a part has an ISP interface: (part->flags & (AVRPART_HAS_PDI | AVRPART_AVR32 | AVRPART_HAS_TPI | AVRPART_HAS_UPDI)) == 0 && (part->flags & AVRPART_SERIALOK) != 0 or had HVSP or HVPP capability, for that matter. Now it is just, eg, part->prog_modes & PM_ISP part->prog_modes & PM_HVPP
This commit is contained in:
parent
0756b8e3ad
commit
b0198a319f
17
src/avr.c
17
src/avr.c
|
@ -52,7 +52,7 @@ int avr_tpi_chip_erase(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
int err;
|
||||
AVRMEM *mem;
|
||||
|
||||
if (p->flags & AVRPART_HAS_TPI) {
|
||||
if (p->prog_modes & PM_TPI) {
|
||||
pgm->pgm_led(pgm, ON);
|
||||
|
||||
/* Set Pointer Register */
|
||||
|
@ -102,7 +102,7 @@ int avr_tpi_program_enable(const PROGRAMMER *pgm, const AVRPART *p, unsigned cha
|
|||
unsigned char cmd[2];
|
||||
unsigned char response;
|
||||
|
||||
if(p->flags & AVRPART_HAS_TPI) {
|
||||
if(p->prog_modes & PM_TPI) {
|
||||
/* set guard time */
|
||||
cmd[0] = (TPI_CMD_SSTCS | TPI_REG_TPIPCR);
|
||||
cmd[1] = guard_time;
|
||||
|
@ -194,7 +194,7 @@ int avr_read_byte_default(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM
|
|||
pgm->pgm_led(pgm, ON);
|
||||
pgm->err_led(pgm, OFF);
|
||||
|
||||
if (p->flags & AVRPART_HAS_TPI) {
|
||||
if (p->prog_modes & PM_TPI) {
|
||||
if (pgm->cmd_tpi == NULL) {
|
||||
avrdude_message(MSG_INFO, "%s: Error: %s programmer does not support TPI\n",
|
||||
progname, pgm->type);
|
||||
|
@ -342,7 +342,7 @@ int avr_read(const PROGRAMMER *pgm, const AVRPART *p, const char *memtype,
|
|||
memset(mem->buf, 0xff, mem->size);
|
||||
|
||||
/* supports "paged load" thru post-increment */
|
||||
if ((p->flags & AVRPART_HAS_TPI) && mem->page_size > 1 &&
|
||||
if ((p->prog_modes & PM_TPI) && mem->page_size > 1 &&
|
||||
mem->size % mem->page_size == 0 && pgm->cmd_tpi != NULL) {
|
||||
|
||||
while (avr_tpi_poll_nvmbsy(pgm));
|
||||
|
@ -550,7 +550,7 @@ int avr_write_byte_default(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (p->flags & AVRPART_HAS_TPI) {
|
||||
if (p->prog_modes & PM_TPI) {
|
||||
if (pgm->cmd_tpi == NULL) {
|
||||
avrdude_message(MSG_INFO, "%s: Error: %s programmer does not support TPI\n",
|
||||
progname, pgm->type);
|
||||
|
@ -596,8 +596,7 @@ int avr_write_byte_default(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM
|
|||
return 0;
|
||||
}
|
||||
|
||||
if (!mem->paged &&
|
||||
(p->flags & AVRPART_IS_AT90S1200) == 0) {
|
||||
if (!mem->paged && (p->flags & AVRPART_IS_AT90S1200) == 0) {
|
||||
/*
|
||||
* check to see if the write is necessary by reading the existing
|
||||
* value and only write if we are changing the value; we can't
|
||||
|
@ -839,9 +838,7 @@ int avr_write(const PROGRAMMER *pgm, const AVRPART *p, const char *memtype,
|
|||
}
|
||||
|
||||
|
||||
if ((p->flags & AVRPART_HAS_TPI) && m->page_size > 1 &&
|
||||
pgm->cmd_tpi != NULL) {
|
||||
|
||||
if ((p->prog_modes & PM_TPI) && m->page_size > 1 && pgm->cmd_tpi) {
|
||||
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;
|
||||
|
|
|
@ -267,7 +267,7 @@ static void avrftdi_enable(PROGRAMMER *pgm, const AVRPART *p) {
|
|||
set_pin(pgm, PPI_AVR_BUFF, ON);
|
||||
|
||||
// Switch to TPI initialisation in avrftdi_tpi.c
|
||||
if(p->flags & AVRPART_HAS_TPI)
|
||||
if(p->prog_modes & PM_TPI)
|
||||
avrftdi_tpi_initpgm(pgm);
|
||||
}
|
||||
|
||||
|
@ -808,7 +808,7 @@ static void avrftdi_close(PROGRAMMER * pgm)
|
|||
static int avrftdi_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
||||
avrftdi_powerup(pgm);
|
||||
|
||||
if(p->flags & AVRPART_HAS_TPI)
|
||||
if(p->prog_modes & PM_TPI)
|
||||
{
|
||||
/* see avrftdi_tpi.c */
|
||||
avrftdi_tpi_initialize(pgm, p);
|
||||
|
|
|
@ -422,7 +422,7 @@ int bitbang_chip_erase(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
unsigned char res[4];
|
||||
AVRMEM *mem;
|
||||
|
||||
if (p->flags & AVRPART_HAS_TPI) {
|
||||
if (p->prog_modes & PM_TPI) {
|
||||
pgm->pgm_led(pgm, ON);
|
||||
|
||||
while (avr_tpi_poll_nvmbsy(pgm));
|
||||
|
@ -482,7 +482,7 @@ int bitbang_program_enable(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
unsigned char res[4];
|
||||
int i;
|
||||
|
||||
if (p->flags & AVRPART_HAS_TPI) {
|
||||
if (p->prog_modes & PM_TPI) {
|
||||
/* enable NVM programming */
|
||||
bitbang_tpi_tx(pgm, TPI_CMD_SKEY);
|
||||
for (i = sizeof(tpi_skey) - 1; i >= 0; i--)
|
||||
|
@ -524,7 +524,7 @@ int bitbang_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
usleep(20000);
|
||||
|
||||
/* TPIDATA is a single line, so MISO & MOSI should be connected */
|
||||
if (p->flags & AVRPART_HAS_TPI) {
|
||||
if (p->prog_modes & PM_TPI) {
|
||||
/* make sure cmd_tpi() is defined */
|
||||
if (pgm->cmd_tpi == NULL) {
|
||||
avrdude_message(MSG_INFO, "%s: Error: %s programmer does not support TPI\n",
|
||||
|
@ -559,7 +559,7 @@ int bitbang_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
pgm->setpin(pgm, PIN_AVR_RESET, 0);
|
||||
usleep(20000);
|
||||
|
||||
if (p->flags & AVRPART_HAS_TPI) {
|
||||
if (p->prog_modes & PM_TPI) {
|
||||
/* keep TPIDATA high for 16 clock cycles */
|
||||
pgm->setpin(pgm, PIN_AVR_MOSI, 1);
|
||||
for (i = 0; i < 16; i++)
|
||||
|
|
|
@ -1117,61 +1117,46 @@ part_parm :
|
|||
|
||||
K_HAS_JTAG TKN_EQUAL yesno
|
||||
{
|
||||
if ($3->primary == K_YES) {
|
||||
current_part->flags |= AVRPART_HAS_JTAG;
|
||||
if ($3->primary == K_YES)
|
||||
current_part->prog_modes |= PM_JTAG;
|
||||
} else if ($3->primary == K_NO) {
|
||||
current_part->flags &= ~AVRPART_HAS_JTAG;
|
||||
else if ($3->primary == K_NO)
|
||||
current_part->prog_modes &= ~PM_JTAG;
|
||||
}
|
||||
free_token($3);
|
||||
} |
|
||||
|
||||
K_HAS_DW TKN_EQUAL yesno
|
||||
{
|
||||
if ($3->primary == K_YES) {
|
||||
current_part->flags |= AVRPART_HAS_DW;
|
||||
if ($3->primary == K_YES)
|
||||
current_part->prog_modes |= PM_debugWIRE;
|
||||
} else if ($3->primary == K_NO) {
|
||||
current_part->flags &= ~AVRPART_HAS_DW;
|
||||
else if ($3->primary == K_NO)
|
||||
current_part->prog_modes &= ~PM_debugWIRE;
|
||||
}
|
||||
free_token($3);
|
||||
} |
|
||||
|
||||
K_HAS_PDI TKN_EQUAL yesno
|
||||
{
|
||||
if ($3->primary == K_YES) {
|
||||
current_part->flags |= AVRPART_HAS_PDI;
|
||||
if ($3->primary == K_YES)
|
||||
current_part->prog_modes |= PM_PDI;
|
||||
} else if ($3->primary == K_NO) {
|
||||
current_part->flags &= ~AVRPART_HAS_PDI;
|
||||
else if ($3->primary == K_NO)
|
||||
current_part->prog_modes &= ~PM_PDI;
|
||||
}
|
||||
free_token($3);
|
||||
} |
|
||||
|
||||
K_HAS_UPDI TKN_EQUAL yesno
|
||||
{
|
||||
if ($3->primary == K_YES) {
|
||||
current_part->flags |= AVRPART_HAS_UPDI;
|
||||
if ($3->primary == K_YES)
|
||||
current_part->prog_modes |= PM_UPDI;
|
||||
} else if ($3->primary == K_NO) {
|
||||
current_part->flags &= ~AVRPART_HAS_UPDI;
|
||||
else if ($3->primary == K_NO)
|
||||
current_part->prog_modes &= ~PM_UPDI;
|
||||
}
|
||||
free_token($3);
|
||||
} |
|
||||
|
||||
K_HAS_TPI TKN_EQUAL yesno
|
||||
{
|
||||
if ($3->primary == K_YES) {
|
||||
current_part->flags |= AVRPART_HAS_TPI;
|
||||
if ($3->primary == K_YES)
|
||||
current_part->prog_modes |= PM_TPI;
|
||||
} else if ($3->primary == K_NO) {
|
||||
current_part->flags &= ~AVRPART_HAS_TPI;
|
||||
else if ($3->primary == K_NO)
|
||||
current_part->prog_modes &= ~PM_TPI;
|
||||
}
|
||||
free_token($3);
|
||||
} |
|
||||
|
||||
|
@ -1187,13 +1172,10 @@ part_parm :
|
|||
|
||||
K_IS_AVR32 TKN_EQUAL yesno
|
||||
{
|
||||
if ($3->primary == K_YES) {
|
||||
current_part->flags |= AVRPART_AVR32;
|
||||
if ($3->primary == K_YES)
|
||||
current_part->prog_modes |= PM_aWire;
|
||||
} else if ($3->primary == K_NO) {
|
||||
current_part->flags &= ~AVRPART_AVR32;
|
||||
else if ($3->primary == K_NO)
|
||||
current_part->prog_modes &= ~PM_aWire;
|
||||
}
|
||||
free_token($3);
|
||||
} |
|
||||
|
||||
|
|
|
@ -74,8 +74,6 @@ static struct {
|
|||
};
|
||||
|
||||
|
||||
|
||||
|
||||
// Return 0 if op code would encode (essentially) the same SPI command
|
||||
static int opcodecmp(const OPCODE *op1, const OPCODE *op2, int opnum) {
|
||||
char *opstr1, *opstr2, *p;
|
||||
|
@ -134,6 +132,13 @@ static void printallopcodes(const AVRPART *p, const char *d, OPCODE * const *opa
|
|||
|
||||
|
||||
// Programming modes
|
||||
|
||||
/*
|
||||
* p->flags no longer used for programming modes, use p->prog_modes
|
||||
*
|
||||
|
||||
remove this comment in 2023
|
||||
|
||||
static char *prog_modes_str_flags(const AVRPART *p) {
|
||||
static char type[1024];
|
||||
|
||||
|
@ -194,6 +199,10 @@ static char *prog_modes_str_flags(const AVRPART *p) {
|
|||
return type + (*type == '|');
|
||||
}
|
||||
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
static char *prog_modes_str(int pm) {
|
||||
static char type[1024];
|
||||
|
||||
|
@ -627,13 +636,7 @@ static void dev_part_strct(const AVRPART *p, bool tsv, const AVRPART *base, bool
|
|||
if(tsv) {
|
||||
_partout("0x%04x", flags);
|
||||
} else {
|
||||
_if_flagout(AVRPART_HAS_JTAG, has_jtag);
|
||||
_if_flagout(AVRPART_HAS_DW, has_debugwire);
|
||||
_if_flagout(AVRPART_HAS_PDI, has_pdi);
|
||||
_if_flagout(AVRPART_HAS_UPDI, has_updi);
|
||||
_if_flagout(AVRPART_HAS_TPI, has_tpi);
|
||||
_if_flagout(AVRPART_IS_AT90S1200, is_at90s1200);
|
||||
_if_flagout(AVRPART_AVR32, is_avr32);
|
||||
_if_flagout(AVRPART_ALLOWFULLPAGEBITSTREAM, allowfullpagebitstream);
|
||||
_if_flagout(AVRPART_ENABLEPAGEPROGRAMMING, enablepageprogramming);
|
||||
_if_flagout(AVRPART_SERIALOK, serial);
|
||||
|
@ -1064,7 +1067,7 @@ void dev_output_part_defs(char *partdesc) {
|
|||
nfuses,
|
||||
ok,
|
||||
p->flags,
|
||||
prog_modes_str_flags(p),
|
||||
prog_modes_str(p->prog_modes),
|
||||
p->config_file, p->lineno
|
||||
);
|
||||
}
|
||||
|
@ -1083,14 +1086,14 @@ void dev_output_part_defs(char *partdesc) {
|
|||
|
||||
// Print wait delays for AVR family parts
|
||||
if(waits) {
|
||||
if(!(p->flags & (AVRPART_HAS_PDI | AVRPART_HAS_UPDI | AVRPART_HAS_TPI | AVRPART_AVR32)))
|
||||
if(p->prog_modes & PM_ISP)
|
||||
dev_info(".wd_chip_erase %.3f ms %s\n", p->chip_erase_delay/1000.0, p->desc);
|
||||
if(p->mem) {
|
||||
for(LNODEID lnm=lfirst(p->mem); lnm; lnm=lnext(lnm)) {
|
||||
AVRMEM *m = ldata(lnm);
|
||||
// Write delays not needed for read-only calibration and signature memories
|
||||
if(strcmp(m->desc, "calibration") && strcmp(m->desc, "signature")) {
|
||||
if(!(p->flags & (AVRPART_HAS_PDI | AVRPART_HAS_UPDI | AVRPART_HAS_TPI | AVRPART_AVR32))) {
|
||||
if(p->prog_modes & PM_ISP) {
|
||||
if(m->min_write_delay == m->max_write_delay)
|
||||
dev_info(".wd_%s %.3f ms %s\n", m->desc, m->min_write_delay/1000.0, p->desc);
|
||||
else {
|
||||
|
|
17
src/fileio.c
17
src/fileio.c
|
@ -778,7 +778,7 @@ static int elf_mem_limits(AVRMEM *mem, struct avrpart * p,
|
|||
{
|
||||
int rv = 0;
|
||||
|
||||
if (p->flags & AVRPART_AVR32) {
|
||||
if (p->prog_modes & PM_aWire) { // AVR32
|
||||
if (strcmp(mem->desc, "flash") == 0) {
|
||||
*lowbound = 0x80000000;
|
||||
*highbound = 0xffffffff;
|
||||
|
@ -850,7 +850,7 @@ static int elf2b(char * infile, FILE * inf,
|
|||
* sections out of an ELF file that contains section data for more
|
||||
* than one sub-segment.
|
||||
*/
|
||||
if ((p->flags & AVRPART_HAS_PDI) != 0 &&
|
||||
if ((p->prog_modes & PM_PDI) != 0 &&
|
||||
(strcmp(mem->desc, "boot") == 0 ||
|
||||
strcmp(mem->desc, "application") == 0 ||
|
||||
strcmp(mem->desc, "apptable") == 0)) {
|
||||
|
@ -893,7 +893,7 @@ static int elf2b(char * infile, FILE * inf,
|
|||
|
||||
const char *endianname;
|
||||
unsigned char endianess;
|
||||
if (p->flags & AVRPART_AVR32) {
|
||||
if (p->prog_modes & PM_aWire) { // AVR32
|
||||
endianess = ELFDATA2MSB;
|
||||
endianname = "little";
|
||||
} else {
|
||||
|
@ -923,7 +923,7 @@ static int elf2b(char * infile, FILE * inf,
|
|||
|
||||
const char *mname;
|
||||
uint16_t machine;
|
||||
if (p->flags & AVRPART_AVR32) {
|
||||
if (p->prog_modes & PM_aWire) {
|
||||
machine = EM_AVR32;
|
||||
mname = "AVR32";
|
||||
} else {
|
||||
|
@ -1383,14 +1383,7 @@ int fileio_setparms(int op, struct fioparms * fp,
|
|||
* AVR32 devices maintain their load offset within the file itself,
|
||||
* but AVRDUDE maintains all memory images 0-based.
|
||||
*/
|
||||
if ((p->flags & AVRPART_AVR32) != 0)
|
||||
{
|
||||
fp->fileoffset = m->offset;
|
||||
}
|
||||
else
|
||||
{
|
||||
fp->fileoffset = 0;
|
||||
}
|
||||
fp->fileoffset = p->prog_modes & PM_aWire? m->offset: 0;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -239,7 +239,7 @@ int flip1_initialize(const PROGRAMMER *pgm, const AVRPART *part) {
|
|||
} else {
|
||||
pid = part->usbpid;
|
||||
}
|
||||
if (!ovsigck && (part->flags & AVRPART_HAS_PDI)) {
|
||||
if (!ovsigck && (part->prog_modes & PM_PDI)) {
|
||||
avrdude_message(MSG_INFO, "%s: \"flip1\" (FLIP protocol version 1) is for AT90USB* and ATmega*U* devices.\n"
|
||||
"%s For Xmega devices, use \"flip2\".\n"
|
||||
"%s (Use -F to bypass this check.)\n",
|
||||
|
|
|
@ -234,7 +234,7 @@ int flip2_initialize(const PROGRAMMER *pgm, const AVRPART *part) {
|
|||
pid = part->usbpid;
|
||||
}
|
||||
|
||||
if (!ovsigck && !(part->flags & AVRPART_HAS_PDI)) {
|
||||
if (!ovsigck && !(part->prog_modes & PM_PDI)) {
|
||||
avrdude_message(MSG_INFO, "%s: \"flip2\" (FLIP protocol version 2) is for Xmega devices.\n"
|
||||
"%s For AT90USB* or ATmega*U* devices, use \"flip1\".\n"
|
||||
"%s (Use -F to bypass this check.)\n",
|
||||
|
|
|
@ -343,7 +343,7 @@ static int ft245r_chip_erase(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
unsigned char cmd[4] = {0,0,0,0};
|
||||
unsigned char res[4];
|
||||
|
||||
if (p->flags & AVRPART_HAS_TPI)
|
||||
if (p->prog_modes & PM_TPI)
|
||||
return avr_tpi_chip_erase(pgm, p);
|
||||
|
||||
if (p->op[AVR_OP_CHIP_ERASE] == NULL) {
|
||||
|
@ -502,7 +502,7 @@ static int ft245r_program_enable(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
unsigned char res[4];
|
||||
int i;
|
||||
|
||||
if (p->flags & AVRPART_HAS_TPI)
|
||||
if (p->prog_modes & PM_TPI)
|
||||
return avr_tpi_program_enable(pgm, p, TPIPCR_GT_0b);
|
||||
|
||||
if (p->op[AVR_OP_PGM_ENABLE] == NULL) {
|
||||
|
@ -565,7 +565,7 @@ static int ft245r_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
*/
|
||||
ft245r_usleep(pgm, 20000); // 20ms
|
||||
|
||||
if (p->flags & AVRPART_HAS_TPI) {
|
||||
if (p->prog_modes & PM_TPI) {
|
||||
bool io_link_ok = true;
|
||||
uint8_t byte;
|
||||
int i;
|
||||
|
|
72
src/jtag3.c
72
src/jtag3.c
|
@ -1064,19 +1064,19 @@ static int jtag3_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
|
||||
if (pgm->flag & PGM_FL_IS_DW) {
|
||||
ifname = "debugWire";
|
||||
if (p->flags & AVRPART_HAS_DW)
|
||||
if (p->prog_modes & PM_debugWIRE)
|
||||
conn = PARM3_CONN_DW;
|
||||
} else if (pgm->flag & PGM_FL_IS_PDI) {
|
||||
ifname = "PDI";
|
||||
if (p->flags & AVRPART_HAS_PDI)
|
||||
if (p->prog_modes & PM_PDI)
|
||||
conn = PARM3_CONN_PDI;
|
||||
} else if (pgm->flag & PGM_FL_IS_UPDI) {
|
||||
ifname = "UPDI";
|
||||
if (p->flags & AVRPART_HAS_UPDI)
|
||||
if (p->prog_modes & PM_UPDI)
|
||||
conn = PARM3_CONN_UPDI;
|
||||
} else {
|
||||
ifname = "JTAG";
|
||||
if (p->flags & AVRPART_HAS_JTAG)
|
||||
if (p->prog_modes & PM_JTAG)
|
||||
conn = PARM3_CONN_JTAG;
|
||||
}
|
||||
|
||||
|
@ -1086,11 +1086,11 @@ static int jtag3_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (p->flags & AVRPART_HAS_PDI)
|
||||
if (p->prog_modes & PM_PDI)
|
||||
parm[0] = PARM3_ARCH_XMEGA;
|
||||
else if (p->flags & AVRPART_HAS_UPDI)
|
||||
else if (p->prog_modes & PM_UPDI)
|
||||
parm[0] = PARM3_ARCH_UPDI;
|
||||
else if (p->flags & AVRPART_HAS_DW)
|
||||
else if (p->prog_modes & PM_debugWIRE)
|
||||
parm[0] = PARM3_ARCH_TINY;
|
||||
else
|
||||
parm[0] = PARM3_ARCH_MEGA;
|
||||
|
@ -1108,7 +1108,7 @@ static int jtag3_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
if (conn == PARM3_CONN_PDI || conn == PARM3_CONN_UPDI)
|
||||
PDATA(pgm)->set_sck = jtag3_set_sck_xmega_pdi;
|
||||
else if (conn == PARM3_CONN_JTAG) {
|
||||
if (p->flags & AVRPART_HAS_PDI)
|
||||
if (p->prog_modes & PM_PDI)
|
||||
PDATA(pgm)->set_sck = jtag3_set_sck_xmega_jtag;
|
||||
else
|
||||
PDATA(pgm)->set_sck = jtag3_set_sck_mega_jtag;
|
||||
|
@ -1137,7 +1137,7 @@ static int jtag3_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
}
|
||||
|
||||
/* set device descriptor data */
|
||||
if ((p->flags & AVRPART_HAS_PDI))
|
||||
if ((p->prog_modes & PM_PDI))
|
||||
{
|
||||
struct xmega_device_desc xd;
|
||||
LNODEID ln;
|
||||
|
@ -1182,7 +1182,7 @@ static int jtag3_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
if (jtag3_setparm(pgm, SCOPE_AVR, 2, PARM3_DEVICEDESC, (unsigned char *)&xd, sizeof xd) < 0)
|
||||
return -1;
|
||||
}
|
||||
else if ((p->flags & AVRPART_HAS_UPDI))
|
||||
else if ((p->prog_modes & PM_UPDI))
|
||||
{
|
||||
struct updi_device_desc xd;
|
||||
LNODEID ln;
|
||||
|
@ -1247,7 +1247,7 @@ static int jtag3_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
|
||||
// Generate UPDI high-voltage pulse if user asks for it and hardware supports it
|
||||
LNODEID support;
|
||||
if (p->flags & AVRPART_HAS_UPDI &&
|
||||
if (p->prog_modes & PM_UPDI &&
|
||||
PDATA(pgm)->use_hvupdi == true &&
|
||||
p->hvupdi_variant != HV_UPDI_VARIANT_1) {
|
||||
parm[0] = PARM3_UPDI_HV_NONE;
|
||||
|
@ -1332,7 +1332,7 @@ static int jtag3_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
int ocdrev;
|
||||
|
||||
/* lacking a proper definition, guess the OCD revision */
|
||||
if (p->flags & AVRPART_HAS_DW)
|
||||
if (p->prog_modes & PM_debugWIRE)
|
||||
ocdrev = 1; /* exception: ATtiny13, 2313, 4313 */
|
||||
else if (flashsize > 128 * 1024)
|
||||
ocdrev = 4;
|
||||
|
@ -1376,7 +1376,7 @@ static int jtag3_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
}
|
||||
|
||||
if (use_ext_reset > 1) {
|
||||
if(strcmp(pgm->type, "JTAGICE3") == 0 && p->flags & AVRPART_HAS_JTAG)
|
||||
if(strcmp(pgm->type, "JTAGICE3") == 0 && (p->prog_modes & PM_JTAG))
|
||||
avrdude_message(MSG_INFO, "%s: JTAGEN fuse disabled?\n", progname);
|
||||
return -1;
|
||||
}
|
||||
|
@ -1394,7 +1394,7 @@ static int jtag3_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
* doesn't apply here anyway), the response is just RSP_OK.
|
||||
*/
|
||||
if (resp[1] == RSP3_DATA && status >= 7) {
|
||||
if (p->flags & AVRPART_HAS_UPDI) {
|
||||
if (p->prog_modes & PM_UPDI) {
|
||||
/* Partial Family_ID has been returned */
|
||||
avrdude_message(MSG_NOTICE, "%s: Partial Family_ID returned: \"%c%c%c%c\"\n",
|
||||
progname, resp[3], resp[4], resp[5], resp[6]);
|
||||
|
@ -1408,11 +1408,8 @@ static int jtag3_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
free(resp);
|
||||
|
||||
PDATA(pgm)->boot_start = ULONG_MAX;
|
||||
if ((p->flags & AVRPART_HAS_PDI)) {
|
||||
/*
|
||||
* Find out where the border between application and boot area
|
||||
* is.
|
||||
*/
|
||||
if (p->prog_modes & PM_PDI) {
|
||||
// Find the border between application and boot area
|
||||
AVRMEM *bootmem = avr_locate_mem(p, "boot");
|
||||
AVRMEM *flashmem = avr_locate_mem(p, "flash");
|
||||
if (bootmem == NULL || flashmem == NULL) {
|
||||
|
@ -1690,7 +1687,7 @@ 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",
|
||||
progname, m->desc, addr);
|
||||
|
||||
if (!(p->flags & AVRPART_HAS_PDI)) {
|
||||
if (!(p->prog_modes & PM_PDI)) {
|
||||
avrdude_message(MSG_INFO, "%s: jtag3_page_erase: not an Xmega device\n",
|
||||
progname);
|
||||
return -1;
|
||||
|
@ -1764,7 +1761,7 @@ static int jtag3_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const AVRM
|
|||
if (strcmp(m->desc, "flash") == 0) {
|
||||
PDATA(pgm)->flash_pageaddr = (unsigned long)-1L;
|
||||
cmd[3] = jtag3_memtype(pgm, p, addr);
|
||||
if (p->flags & AVRPART_HAS_PDI)
|
||||
if (p->prog_modes & PM_PDI)
|
||||
/* dynamically decide between flash/boot memtype */
|
||||
dynamic_memtype = 1;
|
||||
} else if (strcmp(m->desc, "eeprom") == 0) {
|
||||
|
@ -1783,14 +1780,14 @@ static int jtag3_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const AVRM
|
|||
free(cmd);
|
||||
return n_bytes;
|
||||
}
|
||||
cmd[3] = ( p->flags & AVRPART_HAS_PDI || p->flags & AVRPART_HAS_UPDI ) ? MTYPE_EEPROM_XMEGA : MTYPE_EEPROM_PAGE;
|
||||
cmd[3] = p->prog_modes & (PM_PDI | PM_UPDI)? MTYPE_EEPROM_XMEGA: MTYPE_EEPROM_PAGE;
|
||||
PDATA(pgm)->eeprom_pageaddr = (unsigned long)-1L;
|
||||
} else if (strcmp(m->desc, "usersig") == 0 ||
|
||||
strcmp(m->desc, "userrow") == 0) {
|
||||
cmd[3] = MTYPE_USERSIG;
|
||||
} else if (strcmp(m->desc, "boot") == 0) {
|
||||
cmd[3] = MTYPE_BOOT_FLASH;
|
||||
} else if ( p->flags & AVRPART_HAS_PDI || p->flags & AVRPART_HAS_UPDI ) {
|
||||
} else if (p->prog_modes & (PM_PDI | PM_UPDI)) {
|
||||
cmd[3] = MTYPE_FLASH;
|
||||
} else {
|
||||
cmd[3] = MTYPE_SPM;
|
||||
|
@ -1868,11 +1865,11 @@ static int jtag3_paged_load(const PROGRAMMER *pgm, const AVRPART *p, const AVRME
|
|||
|
||||
if (strcmp(m->desc, "flash") == 0) {
|
||||
cmd[3] = jtag3_memtype(pgm, p, addr);
|
||||
if (p->flags & AVRPART_HAS_PDI)
|
||||
if (p->prog_modes & PM_PDI)
|
||||
/* dynamically decide between flash/boot memtype */
|
||||
dynamic_memtype = 1;
|
||||
} else if (strcmp(m->desc, "eeprom") == 0) {
|
||||
cmd[3] = ( p->flags & AVRPART_HAS_PDI || p->flags & AVRPART_HAS_UPDI ) ? MTYPE_EEPROM : MTYPE_EEPROM_PAGE;
|
||||
cmd[3] = p->prog_modes & (PM_PDI | PM_UPDI)? MTYPE_EEPROM: MTYPE_EEPROM_PAGE;
|
||||
if (pgm->flag & PGM_FL_IS_DW)
|
||||
return -1;
|
||||
} else if (strcmp(m->desc, "prodsig") == 0) {
|
||||
|
@ -1882,9 +1879,9 @@ static int jtag3_paged_load(const PROGRAMMER *pgm, const AVRPART *p, const AVRME
|
|||
cmd[3] = MTYPE_USERSIG;
|
||||
} else if (strcmp(m->desc, "boot") == 0) {
|
||||
cmd[3] = MTYPE_BOOT_FLASH;
|
||||
} else if ( p->flags & AVRPART_HAS_PDI ) {
|
||||
} else if (p->prog_modes & PM_PDI) {
|
||||
cmd[3] = MTYPE_FLASH;
|
||||
} else if ( p->flags & AVRPART_HAS_UPDI ) {
|
||||
} else if (p->prog_modes & PM_UPDI) {
|
||||
cmd[3] = MTYPE_SRAM;
|
||||
} else {
|
||||
cmd[3] = MTYPE_SPM;
|
||||
|
@ -1949,7 +1946,7 @@ static int jtag3_read_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM
|
|||
cmd[1] = CMD3_READ_MEMORY;
|
||||
cmd[2] = 0;
|
||||
|
||||
cmd[3] = ( p->flags & AVRPART_HAS_PDI || p->flags & AVRPART_HAS_UPDI ) ? MTYPE_FLASH : MTYPE_FLASH_PAGE;
|
||||
cmd[3] = p->prog_modes & (PM_PDI | PM_UPDI)? MTYPE_FLASH: MTYPE_FLASH_PAGE;
|
||||
if (avr_mem_is_flash_type(mem)) {
|
||||
addr += mem->offset & (512 * 1024 - 1); /* max 512 KiB flash */
|
||||
pagesize = PDATA(pgm)->flash_pagesize;
|
||||
|
@ -1957,7 +1954,7 @@ static int jtag3_read_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM
|
|||
paddr_ptr = &PDATA(pgm)->flash_pageaddr;
|
||||
cache_ptr = PDATA(pgm)->flash_pagecache;
|
||||
} else if (avr_mem_is_eeprom_type(mem)) {
|
||||
if ( (pgm->flag & PGM_FL_IS_DW) || ( p->flags & AVRPART_HAS_PDI ) || ( p->flags & AVRPART_HAS_UPDI ) ) {
|
||||
if ( (pgm->flag & PGM_FL_IS_DW) || (p->prog_modes & PM_PDI) || (p->prog_modes & PM_UPDI) ) {
|
||||
cmd[3] = MTYPE_EEPROM;
|
||||
} else {
|
||||
cmd[3] = MTYPE_EEPROM_PAGE;
|
||||
|
@ -1987,7 +1984,7 @@ static int jtag3_read_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM
|
|||
unsupp = 1;
|
||||
} else if (matches(mem->desc, "fuse")) {
|
||||
cmd[3] = MTYPE_FUSE_BITS;
|
||||
if (!(p->flags & AVRPART_HAS_UPDI))
|
||||
if (!(p->prog_modes & PM_UPDI))
|
||||
addr = mem->offset & 7;
|
||||
} else if (strcmp(mem->desc, "usersig") == 0 ||
|
||||
strcmp(mem->desc, "userrow") == 0) {
|
||||
|
@ -2117,7 +2114,7 @@ static int jtag3_write_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVRME
|
|||
cmd[0] = SCOPE_AVR;
|
||||
cmd[1] = CMD3_WRITE_MEMORY;
|
||||
cmd[2] = 0;
|
||||
cmd[3] = ( p->flags & AVRPART_HAS_PDI || p->flags & AVRPART_HAS_UPDI ) ? MTYPE_FLASH : MTYPE_SPM;
|
||||
cmd[3] = p->prog_modes & (PM_PDI | PM_UPDI)? MTYPE_FLASH: MTYPE_SPM;
|
||||
if (strcmp(mem->desc, "flash") == 0) {
|
||||
cache_ptr = PDATA(pgm)->flash_pagecache;
|
||||
pagesize = PDATA(pgm)->flash_pagesize;
|
||||
|
@ -2149,7 +2146,7 @@ static int jtag3_write_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVRME
|
|||
unsupp = 1;
|
||||
} else if (matches(mem->desc, "fuse")) {
|
||||
cmd[3] = MTYPE_FUSE_BITS;
|
||||
if (!(p->flags & AVRPART_HAS_UPDI))
|
||||
if (!(p->prog_modes & PM_UPDI))
|
||||
addr = mem->offset & 7;
|
||||
} else if (strcmp(mem->desc, "usersig") == 0 ||
|
||||
strcmp(mem->desc, "userrow") == 0) {
|
||||
|
@ -2457,7 +2454,7 @@ static void jtag3_print_parms(const PROGRAMMER *pgm) {
|
|||
}
|
||||
|
||||
static unsigned char jtag3_memtype(const PROGRAMMER *pgm, const AVRPART *p, unsigned long addr) {
|
||||
if ( p->flags & AVRPART_HAS_PDI ) {
|
||||
if (p->prog_modes & PM_PDI) {
|
||||
if (addr >= PDATA(pgm)->boot_start)
|
||||
return MTYPE_BOOT_FLASH;
|
||||
else
|
||||
|
@ -2468,7 +2465,7 @@ static unsigned char jtag3_memtype(const PROGRAMMER *pgm, const AVRPART *p, unsi
|
|||
}
|
||||
|
||||
static unsigned int jtag3_memaddr(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM *m, unsigned long addr) {
|
||||
if ((p->flags & AVRPART_HAS_PDI) != 0) {
|
||||
if (p->prog_modes & PM_PDI) {
|
||||
if (addr >= PDATA(pgm)->boot_start)
|
||||
/*
|
||||
* all memories but "flash" are smaller than boot_start anyway, so
|
||||
|
@ -2479,10 +2476,9 @@ static unsigned int jtag3_memaddr(const PROGRAMMER *pgm, const AVRPART *p, const
|
|||
/* normal flash, or anything else */
|
||||
return addr;
|
||||
}
|
||||
/*
|
||||
* Non-Xmega device.
|
||||
*/
|
||||
if (p->flags & AVRPART_HAS_UPDI) {
|
||||
|
||||
// Non-Xmega device
|
||||
if (p->prog_modes & PM_UPDI) {
|
||||
if (strcmp(m->desc, "flash") == 0) {
|
||||
return addr;
|
||||
}
|
||||
|
|
|
@ -523,7 +523,7 @@ static int jtagmkI_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
unsigned char cmd[1], resp[5];
|
||||
unsigned char b;
|
||||
|
||||
if (!(p->flags & AVRPART_HAS_JTAG)) {
|
||||
if (!(p->prog_modes & PM_JTAG)) {
|
||||
avrdude_message(MSG_INFO, "%s: jtagmkI_initialize(): part %s has no JTAG interface\n",
|
||||
progname, p->desc);
|
||||
return -1;
|
||||
|
|
|
@ -882,7 +882,7 @@ static int jtagmkII_chip_erase(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
int status, len;
|
||||
unsigned char buf[6], *resp, c;
|
||||
|
||||
if (p->flags & (AVRPART_HAS_PDI | AVRPART_HAS_UPDI)) {
|
||||
if (p->prog_modes & (PM_PDI | PM_UPDI)) {
|
||||
buf[0] = CMND_XMEGA_ERASE;
|
||||
buf[1] = XMEGA_ERASE_CHIP;
|
||||
memset(buf + 2, 0, 4); /* address of area to be erased */
|
||||
|
@ -893,7 +893,7 @@ static int jtagmkII_chip_erase(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
}
|
||||
avrdude_message(MSG_NOTICE2, "%s: jtagmkII_chip_erase(): Sending %schip erase command: ",
|
||||
progname,
|
||||
(p->flags & (AVRPART_HAS_PDI | AVRPART_HAS_UPDI))? "Xmega ": "");
|
||||
p->prog_modes & (PM_PDI | PM_UPDI)? "Xmega ": "");
|
||||
jtagmkII_send(pgm, buf, len);
|
||||
|
||||
status = jtagmkII_recv(pgm, &resp);
|
||||
|
@ -919,7 +919,7 @@ static int jtagmkII_chip_erase(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (!(p->flags & (AVRPART_HAS_PDI | AVRPART_HAS_UPDI)))
|
||||
if (!(p->prog_modes & (PM_PDI | PM_UPDI)))
|
||||
pgm->initialize(pgm, p);
|
||||
|
||||
return 0;
|
||||
|
@ -966,7 +966,7 @@ static void jtagmkII_set_devdescr(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
u32_to_b4(sendbuf.dd.ulFlashSize, m->size);
|
||||
u16_to_b2(sendbuf.dd.uiFlashPageSize, m->page_size);
|
||||
u16_to_b2(sendbuf.dd.uiFlashpages, m->size / m->page_size);
|
||||
if (p->flags & AVRPART_HAS_DW) {
|
||||
if (p->prog_modes & PM_debugWIRE) {
|
||||
memcpy(sendbuf.dd.ucFlashInst, p->flash_instr, FLASH_INSTR_SIZE);
|
||||
memcpy(sendbuf.dd.ucEepromInst, p->eeprom_instr, EEPROM_INSTR_SIZE);
|
||||
}
|
||||
|
@ -975,7 +975,7 @@ static void jtagmkII_set_devdescr(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
}
|
||||
}
|
||||
sendbuf.dd.ucCacheType =
|
||||
(p->flags & (AVRPART_HAS_PDI | AVRPART_HAS_UPDI))? 0x02 /* ATxmega */: 0x00;
|
||||
p->prog_modes & (PM_PDI | PM_UPDI)? 0x02 /* ATxmega */: 0x00;
|
||||
|
||||
avrdude_message(MSG_NOTICE2, "%s: jtagmkII_set_devdescr(): "
|
||||
"Sending set device descriptor command: ",
|
||||
|
@ -1290,8 +1290,8 @@ static int jtagmkII_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
const char *ifname;
|
||||
|
||||
/* Abort and print error if programmer does not support the target microcontroller */
|
||||
if ((strncmp(pgm->type, "JTAGMKII_UPDI", strlen("JTAGMKII_UPDI")) == 0 && !(p->flags & AVRPART_HAS_UPDI)) ||
|
||||
(strncmp(ldata(lfirst(pgm->id)), "jtagmkII", strlen("jtagmkII")) == 0 && p->flags & AVRPART_HAS_UPDI)) {
|
||||
if ((strncmp(pgm->type, "JTAGMKII_UPDI", strlen("JTAGMKII_UPDI")) == 0 && !(p->prog_modes & PM_UPDI)) ||
|
||||
(strncmp(ldata(lfirst(pgm->id)), "jtagmkII", strlen("jtagmkII")) == 0 && (p->prog_modes & PM_UPDI))) {
|
||||
avrdude_message(MSG_INFO, "ERROR: programmer %s does not support target %s\n\n",
|
||||
ldata(lfirst(pgm->id)), p->desc);
|
||||
return -1;
|
||||
|
@ -1300,15 +1300,15 @@ static int jtagmkII_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
ok = 0;
|
||||
if (pgm->flag & PGM_FL_IS_DW) {
|
||||
ifname = "debugWire";
|
||||
if (p->flags & AVRPART_HAS_DW)
|
||||
if (p->prog_modes & PM_debugWIRE)
|
||||
ok = 1;
|
||||
} else if (pgm->flag & PGM_FL_IS_PDI) {
|
||||
ifname = "PDI";
|
||||
if (p->flags & (AVRPART_HAS_PDI | AVRPART_HAS_UPDI))
|
||||
if (p->prog_modes & (PM_PDI | PM_UPDI))
|
||||
ok = 1;
|
||||
} else {
|
||||
ifname = "JTAG";
|
||||
if (p->flags & AVRPART_HAS_JTAG)
|
||||
if (p->prog_modes & PM_JTAG)
|
||||
ok = 1;
|
||||
}
|
||||
|
||||
|
@ -1350,24 +1350,21 @@ static int jtagmkII_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
* mode from JTAG to JTAG_XMEGA.
|
||||
*/
|
||||
if ((pgm->flag & PGM_FL_IS_JTAG) &&
|
||||
(p->flags & (AVRPART_HAS_PDI | AVRPART_HAS_UPDI))) {
|
||||
(p->prog_modes & (PM_PDI | PM_UPDI))) {
|
||||
if (jtagmkII_getsync(pgm, EMULATOR_MODE_JTAG_XMEGA) < 0)
|
||||
return -1;
|
||||
}
|
||||
/*
|
||||
* Must set the device descriptor before entering programming mode.
|
||||
*/
|
||||
if (PDATA(pgm)->fwver >= 0x700 && (p->flags & (AVRPART_HAS_PDI | AVRPART_HAS_UPDI)) != 0)
|
||||
if (PDATA(pgm)->fwver >= 0x700 && (p->prog_modes & (PM_PDI | PM_UPDI)) != 0)
|
||||
jtagmkII_set_xmega_params(pgm, p);
|
||||
else
|
||||
jtagmkII_set_devdescr(pgm, p);
|
||||
|
||||
PDATA(pgm)->boot_start = ULONG_MAX;
|
||||
if ((p->flags & (AVRPART_HAS_PDI | AVRPART_HAS_UPDI))) {
|
||||
/*
|
||||
* Find out where the border between application and boot area
|
||||
* is.
|
||||
*/
|
||||
if ((p->prog_modes & (PM_PDI | PM_UPDI))) {
|
||||
// Find the border between application and boot area
|
||||
AVRMEM *bootmem = avr_locate_mem(p, "boot");
|
||||
AVRMEM *flashmem = avr_locate_mem(p, "flash");
|
||||
if (bootmem == NULL || flashmem == NULL) {
|
||||
|
@ -1405,7 +1402,7 @@ static int jtagmkII_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
}
|
||||
PDATA(pgm)->flash_pageaddr = PDATA(pgm)->eeprom_pageaddr = (unsigned long)-1L;
|
||||
|
||||
if (PDATA(pgm)->fwver >= 0x700 && (p->flags & (AVRPART_HAS_PDI | AVRPART_HAS_UPDI))) {
|
||||
if (PDATA(pgm)->fwver >= 0x700 && (p->prog_modes & (PM_PDI | PM_UPDI))) {
|
||||
/*
|
||||
* Work around for
|
||||
* https://savannah.nongnu.org/bugs/index.php?37942
|
||||
|
@ -1422,7 +1419,7 @@ static int jtagmkII_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
return -1;
|
||||
}
|
||||
|
||||
if ((pgm->flag & PGM_FL_IS_JTAG) && !(p->flags & (AVRPART_HAS_PDI | AVRPART_HAS_UPDI))) {
|
||||
if ((pgm->flag & PGM_FL_IS_JTAG) && !(p->prog_modes & (PM_PDI | PM_UPDI))) {
|
||||
hfuse.desc = cache_string("hfuse");
|
||||
if (jtagmkII_read_byte(pgm, p, &hfuse, 1, &b) < 0)
|
||||
return -1;
|
||||
|
@ -1887,7 +1884,7 @@ static int jtagmkII_page_erase(const PROGRAMMER *pgm, const AVRPART *p, const AV
|
|||
avrdude_message(MSG_NOTICE2, "%s: jtagmkII_page_erase(.., %s, 0x%x)\n",
|
||||
progname, m->desc, addr);
|
||||
|
||||
if (!(p->flags & (AVRPART_HAS_PDI | AVRPART_HAS_UPDI))) {
|
||||
if (!(p->prog_modes & (PM_PDI | PM_UPDI))) {
|
||||
avrdude_message(MSG_INFO, "%s: jtagmkII_page_erase: not an Xmega device\n",
|
||||
progname);
|
||||
return -1;
|
||||
|
@ -2002,7 +1999,7 @@ static int jtagmkII_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const A
|
|||
if (strcmp(m->desc, "flash") == 0) {
|
||||
PDATA(pgm)->flash_pageaddr = (unsigned long)-1L;
|
||||
cmd[1] = jtagmkII_memtype(pgm, p, addr);
|
||||
if (p->flags & (AVRPART_HAS_PDI | AVRPART_HAS_UPDI))
|
||||
if (p->prog_modes & (PM_PDI | PM_UPDI))
|
||||
/* dynamically decide between flash/boot memtype */
|
||||
dynamic_memtype = 1;
|
||||
} else if (strcmp(m->desc, "eeprom") == 0) {
|
||||
|
@ -2021,14 +2018,14 @@ static int jtagmkII_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const A
|
|||
free(cmd);
|
||||
return n_bytes;
|
||||
}
|
||||
cmd[1] = (p->flags & (AVRPART_HAS_PDI | AVRPART_HAS_UPDI)) ? MTYPE_EEPROM : MTYPE_EEPROM_PAGE;
|
||||
cmd[1] = p->prog_modes & (PM_PDI | PM_UPDI)? MTYPE_EEPROM: MTYPE_EEPROM_PAGE;
|
||||
PDATA(pgm)->eeprom_pageaddr = (unsigned long)-1L;
|
||||
} else if (strcmp(m->desc, "usersig") == 0 ||
|
||||
strcmp(m->desc, "userrow") == 0) {
|
||||
cmd[1] = MTYPE_USERSIG;
|
||||
} else if (strcmp(m->desc, "boot") == 0) {
|
||||
cmd[1] = MTYPE_BOOT_FLASH;
|
||||
} else if (p->flags & (AVRPART_HAS_PDI | AVRPART_HAS_UPDI)) {
|
||||
} else if (p->prog_modes & (PM_PDI | PM_UPDI)) {
|
||||
cmd[1] = MTYPE_FLASH;
|
||||
} else {
|
||||
cmd[1] = MTYPE_SPM;
|
||||
|
@ -2130,11 +2127,11 @@ static int jtagmkII_paged_load(const PROGRAMMER *pgm, const AVRPART *p, const AV
|
|||
cmd[0] = CMND_READ_MEMORY;
|
||||
if (strcmp(m->desc, "flash") == 0) {
|
||||
cmd[1] = jtagmkII_memtype(pgm, p, addr);
|
||||
if (p->flags & (AVRPART_HAS_PDI | AVRPART_HAS_UPDI))
|
||||
if (p->prog_modes & (PM_PDI | PM_UPDI))
|
||||
/* dynamically decide between flash/boot memtype */
|
||||
dynamic_memtype = 1;
|
||||
} else if (strcmp(m->desc, "eeprom") == 0) {
|
||||
cmd[1] = (p->flags & (AVRPART_HAS_PDI | AVRPART_HAS_UPDI)) ? MTYPE_EEPROM : MTYPE_EEPROM_PAGE;
|
||||
cmd[1] = p->prog_modes & (PM_PDI | PM_UPDI)? MTYPE_EEPROM: MTYPE_EEPROM_PAGE;
|
||||
if (pgm->flag & PGM_FL_IS_DW)
|
||||
return -1;
|
||||
} else if (strcmp(m->desc, "prodsig") == 0) {
|
||||
|
@ -2144,7 +2141,7 @@ static int jtagmkII_paged_load(const PROGRAMMER *pgm, const AVRPART *p, const AV
|
|||
cmd[1] = MTYPE_USERSIG;
|
||||
} else if (strcmp(m->desc, "boot") == 0) {
|
||||
cmd[1] = MTYPE_BOOT_FLASH;
|
||||
} else if (p->flags & (AVRPART_HAS_PDI | AVRPART_HAS_UPDI)) {
|
||||
} else if (p->prog_modes & (PM_PDI | PM_UPDI)) {
|
||||
cmd[1] = MTYPE_FLASH;
|
||||
} else {
|
||||
cmd[1] = MTYPE_SPM;
|
||||
|
@ -2230,14 +2227,14 @@ static int jtagmkII_read_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVR
|
|||
unsupp = 0;
|
||||
|
||||
addr += mem->offset;
|
||||
cmd[1] = ( p->flags & (AVRPART_HAS_PDI | AVRPART_HAS_UPDI) ) ? MTYPE_FLASH : MTYPE_FLASH_PAGE;
|
||||
cmd[1] = p->prog_modes & (PM_PDI | PM_UPDI)? MTYPE_FLASH: MTYPE_FLASH_PAGE;
|
||||
if (avr_mem_is_flash_type(mem)) {
|
||||
pagesize = PDATA(pgm)->flash_pagesize;
|
||||
paddr = addr & ~(pagesize - 1);
|
||||
paddr_ptr = &PDATA(pgm)->flash_pageaddr;
|
||||
cache_ptr = PDATA(pgm)->flash_pagecache;
|
||||
} else if (avr_mem_is_eeprom_type(mem)) {
|
||||
if ( (pgm->flag & PGM_FL_IS_DW) || ( p->flags & (AVRPART_HAS_PDI | AVRPART_HAS_UPDI) ) ) {
|
||||
if ( (pgm->flag & PGM_FL_IS_DW) || (p->prog_modes & (PM_PDI | PM_UPDI)) ) {
|
||||
/* debugWire cannot use page access for EEPROM */
|
||||
cmd[1] = MTYPE_EEPROM;
|
||||
} else {
|
||||
|
@ -2404,7 +2401,7 @@ static int jtagmkII_write_byte(const PROGRAMMER *pgm, const AVRPART *p, const AV
|
|||
|
||||
writedata = data;
|
||||
cmd[0] = CMND_WRITE_MEMORY;
|
||||
cmd[1] = ( p->flags & (AVRPART_HAS_PDI | AVRPART_HAS_UPDI) ) ? MTYPE_FLASH : MTYPE_SPM;
|
||||
cmd[1] = p->prog_modes & (PM_PDI | PM_UPDI)? MTYPE_FLASH: MTYPE_SPM;
|
||||
if (strcmp(mem->desc, "flash") == 0) {
|
||||
if ((addr & 1) == 1) {
|
||||
/* odd address = high byte */
|
||||
|
@ -2418,7 +2415,7 @@ static int jtagmkII_write_byte(const PROGRAMMER *pgm, const AVRPART *p, const AV
|
|||
if (pgm->flag & PGM_FL_IS_DW)
|
||||
unsupp = 1;
|
||||
} else if (strcmp(mem->desc, "eeprom") == 0) {
|
||||
cmd[1] = ( p->flags & (AVRPART_HAS_PDI | AVRPART_HAS_UPDI) ) ? MTYPE_EEPROM_XMEGA: MTYPE_EEPROM;
|
||||
cmd[1] = p->prog_modes & (PM_PDI | PM_UPDI)? MTYPE_EEPROM_XMEGA: MTYPE_EEPROM;
|
||||
need_progmode = 0;
|
||||
PDATA(pgm)->eeprom_pageaddr = (unsigned long)-1L;
|
||||
} else if (strcmp(mem->desc, "lfuse") == 0) {
|
||||
|
@ -2719,7 +2716,7 @@ static void jtagmkII_print_parms(const PROGRAMMER *pgm) {
|
|||
}
|
||||
|
||||
static unsigned char jtagmkII_memtype(const PROGRAMMER *pgm, const AVRPART *p, unsigned long addr) {
|
||||
if ( p->flags & (AVRPART_HAS_PDI | AVRPART_HAS_UPDI) ) {
|
||||
if (p->prog_modes & (PM_PDI | PM_UPDI)) {
|
||||
if (addr >= PDATA(pgm)->boot_start)
|
||||
return MTYPE_BOOT_FLASH;
|
||||
else
|
||||
|
@ -2734,7 +2731,7 @@ static unsigned int jtagmkII_memaddr(const PROGRAMMER *pgm, const AVRPART *p, co
|
|||
* Xmega devices handled by V7+ firmware don't want to be told their
|
||||
* m->offset within the write memory command.
|
||||
*/
|
||||
if (PDATA(pgm)->fwver >= 0x700 && (p->flags & (AVRPART_HAS_PDI | AVRPART_HAS_UPDI)) != 0) {
|
||||
if (PDATA(pgm)->fwver >= 0x700 && (p->prog_modes & (PM_PDI | PM_UPDI))) {
|
||||
if (addr >= PDATA(pgm)->boot_start)
|
||||
/*
|
||||
* all memories but "flash" are smaller than boot_start anyway, so
|
||||
|
@ -3572,7 +3569,7 @@ static int jtagmkII_paged_write32(const PROGRAMMER *pgm, const AVRPART *p, const
|
|||
}
|
||||
|
||||
// Init SMC and set clocks
|
||||
if(!(p->flags & FLAGS32_INIT_SMC)) {
|
||||
if(!(PDATA(pgm)->flags32 & FLAGS32_INIT_SMC)) {
|
||||
status = jtagmkII_smc_init32(pgm);
|
||||
if(status != 0) {lineno = __LINE__; goto eRR;} // PLL 0
|
||||
PDATA(pgm)->flags32 |= FLAGS32_INIT_SMC;
|
||||
|
|
|
@ -184,19 +184,13 @@ typedef struct opcode {
|
|||
} OPCODE;
|
||||
|
||||
|
||||
/* Any changes here, please also reflect in dev_part_strct() of developer_opts.c */
|
||||
#define AVRPART_SERIALOK 0x0001 /* part supports serial programming */
|
||||
#define AVRPART_PARALLELOK 0x0002 /* part supports parallel programming */
|
||||
#define AVRPART_PSEUDOPARALLEL 0x0004 /* part has pseudo parallel support */
|
||||
#define AVRPART_HAS_JTAG 0x0008 /* part has a JTAG i/f */
|
||||
#define AVRPART_ALLOWFULLPAGEBITSTREAM 0x0010 /* JTAG ICE mkII param. */
|
||||
#define AVRPART_ENABLEPAGEPROGRAMMING 0x0020 /* JTAG ICE mkII param. */
|
||||
#define AVRPART_HAS_DW 0x0040 /* part has a debugWire i/f */
|
||||
#define AVRPART_HAS_PDI 0x0080 /* part has PDI i/f rather than ISP (ATxmega) */
|
||||
#define AVRPART_AVR32 0x0100 /* part is in AVR32 family */
|
||||
#define AVRPART_HAS_TPI 0x0800 /* part has TPI i/f rather than ISP (ATtiny4/5/9/10) */
|
||||
#define AVRPART_IS_AT90S1200 0x1000 /* part is an AT90S1200 (needs special treatment) */
|
||||
#define AVRPART_HAS_UPDI 0x2000 /* part has UPDI i/f (AVR8X) */
|
||||
// Any changes here, please also reflect in dev_part_strct() of developer_opts.c
|
||||
#define AVRPART_SERIALOK 1 // Part supports serial programming
|
||||
#define AVRPART_PARALLELOK 2 // Part supports parallel programming
|
||||
#define AVRPART_PSEUDOPARALLEL 4 // Part has pseudo parallel support
|
||||
#define AVRPART_ALLOWFULLPAGEBITSTREAM 8 // JTAG ICE mkII param
|
||||
#define AVRPART_ENABLEPAGEPROGRAMMING 16 // JTAG ICE mkII param
|
||||
#define AVRPART_IS_AT90S1200 32 // Part is an AT90S1200, needs special treatment
|
||||
|
||||
// Programming modes for parts and programmers: reflect changes in lexer.l, developer_opts.c and config.c
|
||||
#define PM_SPM 1 // Bootloaders, self-programming with SPM opcodes or NVM Controllers
|
||||
|
|
|
@ -270,8 +270,8 @@ static void linuxspi_display(const PROGRAMMER* pgm, const char* p) {
|
|||
static int linuxspi_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
||||
int tries, ret;
|
||||
|
||||
if (p->flags & AVRPART_HAS_TPI) {
|
||||
/* We do not support tpi. This is a dedicated SPI thing */
|
||||
if (p->prog_modes & PM_TPI) {
|
||||
/* We do not support TPI. This is a dedicated SPI thing */
|
||||
avrdude_message(MSG_INFO, "%s: error: Programmer " LINUXSPI " does not support TPI\n", progname);
|
||||
return -1;
|
||||
}
|
||||
|
|
11
src/main.c
11
src/main.c
|
@ -924,7 +924,7 @@ int main(int argc, char * argv [])
|
|||
for (ln=lfirst(updates); ln; ln=lnext(ln)) {
|
||||
upd = ldata(ln);
|
||||
if (upd->memtype == NULL) {
|
||||
const char *mtype = (p->flags & AVRPART_HAS_PDI)? "application": "flash";
|
||||
const char *mtype = p->prog_modes & PM_PDI? "application": "flash";
|
||||
avrdude_message(MSG_NOTICE2, "%s: defaulting memtype in -U %c:%s option to \"%s\"\n",
|
||||
progname,
|
||||
(upd->op == DEVICE_READ)? 'r': (upd->op == DEVICE_WRITE)? 'w': 'v',
|
||||
|
@ -1062,7 +1062,7 @@ int main(int argc, char * argv [])
|
|||
* against 0xffffff / 0x000000 should ensure that the signature bytes
|
||||
* are valid.
|
||||
*/
|
||||
if(!(p->flags & AVRPART_AVR32)) {
|
||||
if(!(p->prog_modes & PM_aWire)) { // not AVR32
|
||||
int attempt = 0;
|
||||
int waittime = 10000; /* 10 ms */
|
||||
|
||||
|
@ -1071,7 +1071,7 @@ int main(int argc, char * argv [])
|
|||
if (init_ok) {
|
||||
rc = avr_signature(pgm, p);
|
||||
if (rc != LIBAVRDUDE_SUCCESS) {
|
||||
if ((rc == LIBAVRDUDE_SOFTFAIL) && (p->flags & AVRPART_HAS_UPDI) && (attempt < 1)) {
|
||||
if (rc == LIBAVRDUDE_SOFTFAIL && (p->prog_modes & PM_UPDI) && attempt < 1) {
|
||||
attempt++;
|
||||
if (pgm->read_sib) {
|
||||
// Read SIB and compare FamilyID
|
||||
|
@ -1193,8 +1193,7 @@ int main(int argc, char * argv [])
|
|||
}
|
||||
|
||||
if (uflags & UF_AUTO_ERASE) {
|
||||
if ((p->flags & AVRPART_HAS_PDI) && pgm->page_erase != NULL &&
|
||||
lsize(updates) > 0) {
|
||||
if ((p->prog_modes & PM_PDI) && pgm->page_erase && lsize(updates) > 0) {
|
||||
if (quell_progress < 2) {
|
||||
avrdude_message(MSG_INFO, "%s: NOTE: Programmer supports page erase for Xmega devices.\n"
|
||||
"%sEach page will be erased before programming it, but no chip erase is performed.\n"
|
||||
|
@ -1203,7 +1202,7 @@ int main(int argc, char * argv [])
|
|||
}
|
||||
} else {
|
||||
AVRMEM * m;
|
||||
const char *memname = (p->flags & AVRPART_HAS_PDI)? "application": "flash";
|
||||
const char *memname = p->prog_modes & PM_PDI? "application": "flash";
|
||||
|
||||
uflags &= ~UF_AUTO_ERASE;
|
||||
for (ln=lfirst(updates); ln; ln=lnext(ln)) {
|
||||
|
|
|
@ -1130,8 +1130,7 @@ retry:
|
|||
break;
|
||||
|
||||
case PGMTYPE_JTAGICE3:
|
||||
if (buf[1] == STATUS_CMD_FAILED &&
|
||||
(p->flags & AVRPART_HAS_DW) != 0) {
|
||||
if (buf[1] == STATUS_CMD_FAILED && (p->prog_modes & PM_debugWIRE)) {
|
||||
unsigned char cmd[4], *resp;
|
||||
|
||||
/* Try debugWIRE, and MONCON_DISABLE */
|
||||
|
@ -1239,16 +1238,13 @@ static int stk500v2_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
if ((PDATA(pgm)->pgmtype == PGMTYPE_STK600 ||
|
||||
PDATA(pgm)->pgmtype == PGMTYPE_AVRISP_MKII ||
|
||||
PDATA(pgm)->pgmtype == PGMTYPE_JTAGICE_MKII) != 0
|
||||
&& (p->flags & (AVRPART_HAS_PDI | AVRPART_HAS_TPI)) != 0) {
|
||||
&& (p->prog_modes & (PM_PDI | PM_TPI)) != 0) {
|
||||
/*
|
||||
* This is an ATxmega device, must use XPROG protocol for the
|
||||
* remaining actions.
|
||||
*/
|
||||
if ((p->flags & AVRPART_HAS_PDI) != 0) {
|
||||
/*
|
||||
* Find out where the border between application and boot area
|
||||
* is.
|
||||
*/
|
||||
if (p->prog_modes & PM_PDI) {
|
||||
// Find the border between application and boot area
|
||||
AVRMEM *bootmem = avr_locate_mem(p, "boot");
|
||||
AVRMEM *flashmem = avr_locate_mem(p, "flash");
|
||||
if (bootmem == NULL || flashmem == NULL) {
|
||||
|
@ -1320,8 +1316,8 @@ static int stk500v2_jtag3_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
LNODEID ln;
|
||||
AVRMEM * m;
|
||||
|
||||
if ((p->flags & AVRPART_HAS_PDI) ||
|
||||
(p->flags & AVRPART_HAS_TPI)) {
|
||||
// FIXME: condition below looks fishy, suspect the code wants !(p->prog_modes & (PM_debugWIRE | PM_JTAG))
|
||||
if (p->prog_modes & (PM_PDI | PM_TPI)) {
|
||||
avrdude_message(MSG_INFO, "%s: jtag3_initialize(): part %s has no ISP interface\n",
|
||||
progname, p->desc);
|
||||
return -1;
|
||||
|
@ -1330,7 +1326,7 @@ static int stk500v2_jtag3_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
PROGRAMMER *pgmcp = pgm_dup(pgm);
|
||||
pgmcp->cookie = PDATA(pgm)->chained_pdata;
|
||||
|
||||
if (p->flags & AVRPART_HAS_DW)
|
||||
if (p->prog_modes & PM_debugWIRE)
|
||||
parm[0] = PARM3_ARCH_TINY;
|
||||
else
|
||||
parm[0] = PARM3_ARCH_MEGA;
|
||||
|
@ -1574,7 +1570,7 @@ static void stk500v2_enable(PROGRAMMER *pgm, const AVRPART *p) {
|
|||
if((PDATA(pgm)->pgmtype == PGMTYPE_STK600 ||
|
||||
PDATA(pgm)->pgmtype == PGMTYPE_AVRISP_MKII ||
|
||||
PDATA(pgm)->pgmtype == PGMTYPE_JTAGICE_MKII) != 0
|
||||
&& (p->flags & (AVRPART_HAS_PDI | AVRPART_HAS_TPI)) != 0) {
|
||||
&& (p->prog_modes & (PM_PDI | PM_TPI)) != 0) {
|
||||
stk600_setup_xprog(pgm);
|
||||
} else {
|
||||
stk600_setup_isp(pgm);
|
||||
|
@ -3689,7 +3685,7 @@ static int stk600_xprog_program_enable(const PROGRAMMER *pgm, const AVRPART *p)
|
|||
AVRMEM *mem = NULL;
|
||||
int use_tpi;
|
||||
|
||||
use_tpi = (p->flags & AVRPART_HAS_TPI) != 0;
|
||||
use_tpi = (p->prog_modes & PM_TPI) != 0;
|
||||
|
||||
if (!use_tpi) {
|
||||
if (p->nvm_base == 0) {
|
||||
|
@ -3825,7 +3821,7 @@ static int stk600_xprog_write_byte(const PROGRAMMER *pgm, const AVRPART *p, cons
|
|||
memcode = XPRG_MEM_TYPE_LOCKBITS;
|
||||
} else if (strncmp(mem->desc, "fuse", strlen("fuse")) == 0) {
|
||||
memcode = XPRG_MEM_TYPE_FUSE;
|
||||
if (p->flags & AVRPART_HAS_TPI)
|
||||
if (p->prog_modes & PM_TPI)
|
||||
/*
|
||||
* TPI devices need a mystic erase prior to writing their
|
||||
* fuses.
|
||||
|
@ -3855,7 +3851,7 @@ static int stk600_xprog_write_byte(const PROGRAMMER *pgm, const AVRPART *p, cons
|
|||
}
|
||||
}
|
||||
|
||||
if (p->flags & AVRPART_HAS_TPI) {
|
||||
if (p->prog_modes & PM_TPI) {
|
||||
/*
|
||||
* Some TPI memories (configuration aka. fuse) require a
|
||||
* larger write block size. We record that as a blocksize in
|
||||
|
@ -4217,7 +4213,7 @@ static int stk600_xprog_chip_erase(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
AVRMEM *mem;
|
||||
unsigned int addr = 0;
|
||||
|
||||
if (p->flags & AVRPART_HAS_TPI) {
|
||||
if (p->prog_modes & PM_TPI) {
|
||||
if ((mem = avr_locate_mem(p, "flash")) == NULL) {
|
||||
avrdude_message(MSG_INFO, "%s: stk600_xprog_chip_erase(): no FLASH definition found for TPI device\n",
|
||||
progname);
|
||||
|
|
|
@ -674,7 +674,7 @@ static int usbasp_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
|
|||
else
|
||||
pdata->capabilities = 0;
|
||||
|
||||
pdata->use_tpi = (pdata->capabilities & USBASP_CAP_TPI) && (p->flags & AVRPART_HAS_TPI);
|
||||
pdata->use_tpi = (pdata->capabilities & USBASP_CAP_TPI) && (p->prog_modes & PM_TPI);
|
||||
// query support for 3 MHz SCK in UsbAsp-flash firmware
|
||||
// https://github.com/nofeletru/UsbAsp-flash
|
||||
pdata->sck_3mhz = ((pdata->capabilities & USBASP_CAP_3MHZ) != 0) ? 1 :0;
|
||||
|
|
|
@ -454,7 +454,7 @@ static int usbtiny_initialize (const PROGRAMMER *pgm, const AVRPART *p ) {
|
|||
// Let the device wake up.
|
||||
usleep(50000);
|
||||
|
||||
if (p->flags & AVRPART_HAS_TPI) {
|
||||
if (p->prog_modes & PM_TPI) {
|
||||
/* Since there is a single TPIDATA line, MOSI and MISO must be
|
||||
linked together through a 1kOhm resistor. Verify that
|
||||
everything we send on MOSI gets mirrored back on MISO. */
|
||||
|
@ -605,7 +605,7 @@ static int usbtiny_spi(const PROGRAMMER *pgm, const unsigned char *cmd, unsigned
|
|||
static int usbtiny_chip_erase(const PROGRAMMER *pgm, const AVRPART *p) {
|
||||
unsigned char res[4];
|
||||
|
||||
if (p->flags & AVRPART_HAS_TPI)
|
||||
if (p->prog_modes & PM_TPI)
|
||||
return avr_tpi_chip_erase(pgm, p);
|
||||
|
||||
if (p->op[AVR_OP_CHIP_ERASE] == NULL) {
|
||||
|
@ -773,7 +773,7 @@ static int usbtiny_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const AV
|
|||
static int usbtiny_program_enable(const PROGRAMMER *pgm, const AVRPART *p) {
|
||||
unsigned char buf[4];
|
||||
|
||||
if (p->flags & AVRPART_HAS_TPI)
|
||||
if (p->prog_modes & PM_TPI)
|
||||
return avr_tpi_program_enable(pgm, p, TPIPCR_GT_0b);
|
||||
else
|
||||
return usbtiny_avr_op(pgm, p, AVR_OP_PGM_ENABLE, buf);
|
||||
|
|
Loading…
Reference in New Issue