From 9267f9435d34cf22bbd462c5d58e3be5ef3f2c00 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Tue, 6 Jun 2023 14:53:01 +0100 Subject: [PATCH] Provide programmer arduino_as_isp --- src/avrdude.conf.in | 15 +++++++++++++++ src/stk500.c | 5 +++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/avrdude.conf.in b/src/avrdude.conf.in index 1cc82043..c9f92103 100644 --- a/src/avrdude.conf.in +++ b/src/avrdude.conf.in @@ -1339,6 +1339,21 @@ programmer connection_type = serial; ; +#------------------------------------------------------------ +# arduino_as_isp +#------------------------------------------------------------ + +# Not to be confused with arduinoISP, this is the same as `-c stk500v1` +# but treats EEPROM r/w correctly for arduino_as_isp programmers + +programmer + id = "arduino_as_isp"; + desc = "Arduino board as programmer using arduino as ISP firmware"; + type = "stk500"; + prog_modes = PM_ISP; + connection_type = serial; +; + #------------------------------------------------------------ # mib510 #------------------------------------------------------------ diff --git a/src/stk500.c b/src/stk500.c index 32c99f27..ccbb5004 100644 --- a/src/stk500.c +++ b/src/stk500.c @@ -966,8 +966,9 @@ static int set_memtype_a_div(const PROGRAMMER *pgm, const AVRPART *p, const AVRM if(avr_mem_is_eeprom_type(m)) { *memtypep = 'E'; - // Word addr for bootloaders where part is a "classic" part (eg, optiboot, arduinoisp, ...), byte addr otherwise - *a_divp = (pgm->prog_modes & PM_SPM) && !(p->prog_modes & (PM_UPDI | PM_PDI))? 2: 1; + // Word addr for bootloaders or Arduino as ISP if part is a "classic" part, byte addr otherwise + *a_divp = ((pgm->prog_modes & PM_SPM) || str_caseeq(ldata(lfirst(pgm->id)), "arduino_as_isp")) \ + && !(p->prog_modes & (PM_UPDI | PM_PDI))? 2: 1; return 0; }