Piggy-back 'Do not remove trailing 0xff' onto option -D

This commit is contained in:
Stefan Rueger 2022-04-15 20:46:40 +01:00
parent 60960ba590
commit ed38456f83
3 changed files with 15 additions and 1 deletions

View File

@ -282,6 +282,16 @@ int avr_read_byte_default(PROGRAMMER * pgm, AVRPART * p, AVRMEM * mem,
int avr_mem_hiaddr(AVRMEM * mem)
{
int i, n;
static int disableffopt;
/* calling once with NULL disables any future trailing-0xff optimisation */
if(!mem) {
disableffopt = 1;
return 0;
}
if(disableffopt)
return mem->size;
/* return the highest non-0xff address regardless of how much
memory was read */

View File

@ -1594,7 +1594,10 @@ int fileio(int op, char * filename, FILEFMT format,
* if we are reading flash, just mark the size as being the
* highest non-0xff byte
*/
rc = avr_mem_hiaddr(mem);
int hiaddr = avr_mem_hiaddr(mem);
if(hiaddr < rc) /* if trailing-0xff not disabled */
rc = hiaddr;
}
}
if (format != FMT_IMM && !using_stdio) {

View File

@ -528,6 +528,7 @@ int main(int argc, char * argv [])
case 'D': /* disable auto erase */
uflags &= ~UF_AUTO_ERASE;
avr_mem_hiaddr(NULL); /* disable trailing 0xff optimisation */
break;
case 'e': /* perform a chip erase */