Relax uniqueness check of mcuid for parts that might be variants

Two parts are considered variants here if one part name starts with the name
of the other, flash memory sizes are the same, flash page sizes are the same
and the number of interrupts are the same.
This commit is contained in:
Stefan Rueger 2022-08-31 11:59:19 +01:00
parent fc970226b6
commit 602fab481c
No known key found for this signature in database
GPG Key ID: B0B4F1FD86B1EC55
1 changed files with 12 additions and 3 deletions

View File

@ -861,11 +861,20 @@ void cfg_update_mcuid(AVRPART *part) {
} }
} }
// None have the same name: an entry with part->mcuid is an error // None have the same name: an entry with part->mcuid might be an error
for(int i=0; i < sizeof uP_table/sizeof *uP_table; i++) for(int i=0; i < sizeof uP_table/sizeof *uP_table; i++)
if(part->mcuid == (int) uP_table[i].mcuid) { if(part->mcuid == (int) uP_table[i].mcuid) {
// Complain unless it can be considered a variant, eg, ATmega32L and ATmega32
AVRMEM *flash = avr_locate_mem(part, "flash");
if(flash) {
size_t l1 = strlen(part->desc), l2 = strlen(uP_table[i].name);
if(strncasecmp(part->desc, uP_table[i].name, l1 < l2? l1: l2) ||
flash->size != uP_table[i].flashsize ||
flash->page_size != uP_table[i].pagesize ||
part->n_interrupts != uP_table[i].ninterrupts)
yywarning("mcuid %d is reserved for %s, use a free number >= %d", yywarning("mcuid %d is reserved for %s, use a free number >= %d",
part->mcuid, uP_table[i].name, sizeof uP_table/sizeof *uP_table); part->mcuid, uP_table[i].name, sizeof uP_table/sizeof *uP_table);
}
return; return;
} }