Add libavrdude functions avr_mem_is_flash_type() and avr_mem_is_eeprom_type()

This commit is contained in:
Stefan Rueger
2022-08-15 14:57:04 +01:00
parent e332ecf0b4
commit dfef8bb0a8
7 changed files with 29 additions and 21 deletions

View File

@@ -295,10 +295,7 @@ int avr_mem_hiaddr(AVRMEM * mem)
return mem->size;
/* if the memory is not a flash-type memory do not remove trailing 0xff */
if(strcasecmp(mem->desc, "flash") &&
strcasecmp(mem->desc, "application") &&
strcasecmp(mem->desc, "apptable") &&
strcasecmp(mem->desc, "boot"))
if(!avr_mem_is_flash_type(mem))
return mem->size;
/* return the highest non-0xff address regardless of how much
@@ -1253,6 +1250,18 @@ void avr_add_mem_order(const char *str) {
exit(1);
}
int avr_mem_is_flash_type(AVRMEM *mem) {
return
strcmp(mem->desc, "flash") == 0 ||
strcmp(mem->desc, "application") == 0 ||
strcmp(mem->desc, "apptable") == 0 ||
strcmp(mem->desc, "boot") == 0;
}
int avr_mem_is_eeprom_type(AVRMEM *mem) {
return strcmp(mem->desc, "eeprom") == 0;
}
int avr_mem_is_known(const char *str) {
if(str && *str)
for(size_t i=0; i < sizeof avr_mem_order/sizeof *avr_mem_order; i++)