From e3eb81630375998460a96e686d798db2910e4aa8 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Tue, 15 Aug 2023 20:41:05 +0100 Subject: [PATCH] Treat fuse and lfuse the same --- src/fileio.c | 2 +- src/jtag3.c | 6 +++--- src/jtagmkI.c | 4 ++-- src/jtagmkII.c | 6 +++--- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/fileio.c b/src/fileio.c index 4d42a1eba..f29cd1c73 100644 --- a/src/fileio.c +++ b/src/fileio.c @@ -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; diff --git a/src/jtag3.c b/src/jtag3.c index df9070124..691c8600a 100644 --- a/src/jtag3.c +++ b/src/jtag3.c @@ -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") || @@ -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; @@ -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; diff --git a/src/jtagmkI.c b/src/jtagmkI.c index b71216a33..621d45c1d 100644 --- a/src/jtagmkI.c +++ b/src/jtagmkI.c @@ -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; @@ -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; diff --git a/src/jtagmkII.c b/src/jtagmkII.c index 002b78ed7..3dd13a1a9 100644 --- a/src/jtagmkII.c +++ b/src/jtagmkII.c @@ -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")) { @@ -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; @@ -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;