Skip to content

Commit

Permalink
Treat fuse and lfuse the same
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanrueger committed Aug 15, 2023
1 parent fe721ff commit e3eb816
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/fileio.c
Original file line number Diff line number Diff line change
Expand Up @@ -795,7 +795,7 @@ static int elf_mem_limits(const AVRMEM *mem, const AVRPART *p,
*highbound = 0x82ffff;
*fileoff = 2;
} else if (str_starts(mem->desc, "fuse") &&
mem->desc[4] && isxdigit(0xff & mem->desc[4]) && ¬mem->desc[5]) {
mem->desc[4] && isxdigit(0xff & mem->desc[4]) && !mem->desc[5]) {
/* Xmega or modern AVR fuseX */
*lowbound = 0x820000;
*highbound = 0x82ffff;
Expand Down
6 changes: 3 additions & 3 deletions src/jtag3.c
Original file line number Diff line number Diff line change
Expand Up @@ -1204,7 +1204,7 @@ static int jtag3_initialize(const PROGRAMMER *pgm, const AVRPART *p) {
u16_to_b2(xd.boot_size, m->size);
u32_to_b4(xd.nvm_boot_offset, m->offset);
} else if (str_eq(m->desc, "fuse1")) {
u32_to_b4(xd.nvm_fuse_offset, m->offset & ~7);
u32_to_b4(xd.nvm_fuse_offset, m->offset & ~15);
} else if (str_starts(m->desc, "lock")) {
u32_to_b4(xd.nvm_lock_offset, m->offset);
} else if (str_eq(m->desc, "usersig") ||
Expand Down Expand Up @@ -2137,7 +2137,7 @@ static int jtag3_read_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVRMEM
cache_ptr = PDATA(pgm)->eeprom_pagecache;
} else if (str_contains(mem->desc, "fuse") && strlen(mem->desc) <= 5) {
cmd[3] = MTYPE_FUSE_BITS;
if (str_eq(mem->desc, "lfuse"))
if (str_eq(mem->desc, "lfuse") || str_eq(mem->desc, "fuse"))
addr = 0;
else if (str_eq(mem->desc, "hfuse"))
addr = 1;
Expand Down Expand Up @@ -2316,7 +2316,7 @@ static int jtag3_write_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVRME
PDATA(pgm)->eeprom_pageaddr = (unsigned long)-1L;
} else if (str_contains(mem->desc, "fuse") && strlen(mem->desc) <= 5) {
cmd[3] = MTYPE_FUSE_BITS;
if (str_eq(mem->desc, "lfuse"))
if (str_eq(mem->desc, "lfuse") || str_eq(mem->desc, "fuse"))
addr = 0;
else if (str_eq(mem->desc, "hfuse"))
addr = 1;
Expand Down
4 changes: 2 additions & 2 deletions src/jtagmkI.c
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ static int jtagmkI_read_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVRM
cache_ptr = PDATA(pgm)->eeprom_pagecache;
} else if (str_contains(mem->desc, "fuse") && strlen(mem->desc) <= 5) {
cmd[1] = MTYPE_FUSE_BITS;
if (str_eq(mem->desc, "lfuse"))
if (str_eq(mem->desc, "lfuse") || str_eq(mem->desc, "fuse"))
addr = 0;
else if (str_eq(mem->desc, "hfuse"))
addr = 1;
Expand Down Expand Up @@ -983,7 +983,7 @@ static int jtagmkI_write_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVR
} else if (str_contains(mem->desc, "fuse") && strlen(mem->desc) <= 5) {
cmd[1] = MTYPE_FUSE_BITS;
need_dummy_read = 1;
if (str_eq(mem->desc, "lfuse"))
if (str_eq(mem->desc, "lfuse") || str_eq(mem->desc, "lfuse"))
addr = 0;
else if (str_eq(mem->desc, "hfuse"))
addr = 1;
Expand Down
6 changes: 3 additions & 3 deletions src/jtagmkII.c
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,7 @@ static void jtagmkII_set_xmega_params(const PROGRAMMER *pgm, const AVRPART *p) {
u16_to_b2(sendbuf.dd.boot_size, m->size);
u32_to_b4(sendbuf.dd.nvm_boot_offset, m->offset);
} else if (str_eq(m->desc, "fuse1")) {
u32_to_b4(sendbuf.dd.nvm_fuse_offset, m->offset & ~7);
u32_to_b4(sendbuf.dd.nvm_fuse_offset, m->offset & ~15);
} else if (str_starts(m->desc, "lock")) {
u32_to_b4(sendbuf.dd.nvm_lock_offset, m->offset);
} else if (str_eq(m->desc, "usersig") || str_eq(m->desc, "userrow")) {
Expand Down Expand Up @@ -2186,7 +2186,7 @@ static int jtagmkII_read_byte(const PROGRAMMER *pgm, const AVRPART *p, const AVR
}
} else if (str_contains(mem->desc, "fuse") && strlen(mem->desc) <= 5) {
cmd[1] = MTYPE_FUSE_BITS;
if (str_eq(mem->desc, "lfuse"))
if (str_eq(mem->desc, "lfuse") || str_eq(mem->desc, "fuse"))
addr = 0;
else if (str_eq(mem->desc, "hfuse"))
addr = 1;
Expand Down Expand Up @@ -2347,7 +2347,7 @@ static int jtagmkII_write_byte(const PROGRAMMER *pgm, const AVRPART *p, const AV
PDATA(pgm)->eeprom_pageaddr = (unsigned long)-1L;
} else if (str_contains(mem->desc, "fuse") && strlen(mem->desc) <= 5) {
cmd[1] = MTYPE_FUSE_BITS;
if (str_eq(mem->desc, "lfuse"))
if (str_eq(mem->desc, "lfuse") || str_eq(mem->desc, "fuse"))
addr = 0;
else if (str_eq(mem->desc, "hfuse"))
addr = 1;
Expand Down

0 comments on commit e3eb816

Please sign in to comment.