Skip to content

Commit

Permalink
Use avr_get_config_value() to determine OCDEN fuse setting
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanrueger committed Nov 23, 2023
1 parent fd1c49e commit 879ea06
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 34 deletions.
20 changes: 3 additions & 17 deletions src/jtagmkI.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,6 @@ struct pdata

#define PDATA(pgm) ((struct pdata *)(pgm->cookie))

/*
* The OCDEN fuse is bit 7 of the high fuse (hfuse). In order to
* perform memory operations on MTYPE_SPM and MTYPE_EEPROM, OCDEN
* needs to be programmed.
*
* OCDEN should probably rather be defined via the configuration, but
* if this ever changes to a different fuse byte for one MCU, quite
* some code here needs to be generalized anyway.
*/
#define OCDEN (1 << 7)

/*
* Table of baud rates supported by the mkI ICE, accompanied by their
* internal parameter value.
Expand Down Expand Up @@ -550,12 +539,9 @@ static int jtagmkI_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
if (jtagmkI_reset(pgm) < 0)
return -1;

AVRMEM *hf = avr_locate_hfuse(p);
if (!hf || jtagmkI_read_byte(pgm, p, hf, 1, &b) < 0)
return -1;
if ((b & OCDEN) != 0)
pmsg_warning("OCDEN fuse not programmed, "
"single-byte EEPROM updates not possible\n");
int ocden = 0;
if(avr_get_config_value(pgm, p, "ocden", &ocden) == 0 && ocden) // ocden == 1 means disabled
pmsg_warning("OCDEN fuse not programmed, single-byte EEPROM updates not possible\n");

return 0;
}
Expand Down
20 changes: 3 additions & 17 deletions src/jtagmkII.c
Original file line number Diff line number Diff line change
Expand Up @@ -95,17 +95,6 @@ struct pdata

#define PDATA(pgm) ((struct pdata *)(pgm->cookie))

/*
* The OCDEN fuse is bit 7 of the high fuse (hfuse). In order to
* perform memory operations on MTYPE_SPM and MTYPE_EEPROM, OCDEN
* needs to be programmed.
*
* OCDEN should probably rather be defined via the configuration, but
* if this ever changes to a different fuse byte for one MCU, quite
* some code here needs to be generalized anyway.
*/
#define OCDEN (1 << 7)

#define RC(x) { x, #x },
static struct {
unsigned int code;
Expand Down Expand Up @@ -1325,12 +1314,9 @@ static int jtagmkII_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
}

if ((pgm->flag & PGM_FL_IS_JTAG) && !(p->prog_modes & (PM_PDI | PM_UPDI))) {
AVRMEM *hf = avr_locate_hfuse(p);
if (!hf || jtagmkII_read_byte(pgm, p, hf, 1, &b) < 0)
return -1;
if ((b & OCDEN) != 0)
pmsg_warning("OCDEN fuse not programmed, "
"single-byte EEPROM updates not possible\n");
int ocden = 0;
if(avr_get_config_value(pgm, p, "ocden", &ocden) == 0 && ocden) // ocden == 1 means disabled
pmsg_warning("OCDEN fuse not programmed, single-byte EEPROM updates not possible\n");
}

if (pgm->read_chip_rev && p->prog_modes & (PM_PDI | PM_UPDI)) {
Expand Down

0 comments on commit 879ea06

Please sign in to comment.