From db37c9d2862b1229a91cb325ff70496d19d3ff10 Mon Sep 17 00:00:00 2001 From: Stefan Rueger Date: Tue, 19 Jul 2022 20:00:17 +0100 Subject: [PATCH] Extend rather than reset memory entries in avrdude.conf This commit changes the philosophy whenever avrdude.conf encounters the same memory of a part for the second time or whenever a memory is described that, through inheritance, already existed: AVRDUDE no longer zaps the memory, it rather extends it. Therefore, avrdude.conf.in's entry for ATmega128RFA1, which inherits from the ATmega2561, needs a line `load_ext_addr = NULL;` in its flash memory description to zap the inherited load_ext_addr SPI command. Other than this, avrdude.conf.in needs no other change in order to effect the same internal representation proving earlier updates to the .conf.in file correct that manually ensured inheritance of memory contents. --- src/avrdude.conf.in | 2 ++ src/config_gram.y | 36 ++++++++++++++++-------------------- 2 files changed, 18 insertions(+), 20 deletions(-) diff --git a/src/avrdude.conf.in b/src/avrdude.conf.in index 8fc67080..3b8c5a6e 100644 --- a/src/avrdude.conf.in +++ b/src/avrdude.conf.in @@ -11845,6 +11845,8 @@ part parent "m2561" " a7 x x x x x x x", " x x x x x x x x"; + load_ext_addr = NULL; + mode = 0x41; delay = 20; blocksize = 256; diff --git a/src/config_gram.y b/src/config_gram.y index 6f6f8765..7a8cb7eb 100644 --- a/src/config_gram.y +++ b/src/config_gram.y @@ -1304,31 +1304,27 @@ part_parm : */ K_MEMORY TKN_STRING - { - current_mem = avr_new_memtype(); - if (current_mem == NULL) { - yyerror("could not create mem instance"); - free_token($2); - YYABORT; + { /* select memory for extension or create if not there */ + AVRMEM *mem = avr_locate_mem_noalias(current_part, $2->value.string); + if(!mem) { + if(!(mem = avr_new_memtype())) { + yyerror("could not create mem instance"); + free_token($2); + YYABORT; + } + strncpy(mem->desc, $2->value.string, AVR_MEMDESCLEN - 1); + mem->desc[AVR_MEMDESCLEN-1] = 0; + ladd(current_part->mem, mem); } - strncpy(current_mem->desc, $2->value.string, AVR_MEMDESCLEN - 1); - current_mem->desc[AVR_MEMDESCLEN-1] = 0; + current_mem = mem; free_token($2); } mem_specs - { - AVRMEM * existing_mem; - - existing_mem = avr_locate_mem_noalias(current_part, current_mem->desc); - if (existing_mem != NULL) { - lrmv_d(current_part->mem, existing_mem); - avr_free_mem(existing_mem); - } - if (is_alias) { - avr_free_mem(current_mem); // alias mem has been already entered below + { + if (is_alias) { // alias mem has been already entered + lrmv_d(current_part->mem, current_mem); + avr_free_mem(current_mem); is_alias = false; - } else { - ladd(current_part->mem, current_mem); } current_mem = NULL; } |