Merge pull request #1273 from stefanrueger/stk500_value_polling

Only send write flash cmd to STK500v2 programmers if page not empty
This commit is contained in:
Stefan Rueger 2023-01-14 14:29:59 +00:00 committed by GitHub
commit 65686c7fed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 1 deletions

View File

@ -2279,7 +2279,11 @@ static int stk500v2_paged_write(const PROGRAMMER *pgm, const AVRPART *p, const A
memcpy(buf+10,m->buf+addr, block_size);
result = stk500v2_command(pgm,buf,block_size+10, sizeof(buf));
// Do not send request to write empty flash pages except for bootloaders (fixes Issue #425)
unsigned char *p = m->buf+addr;
result = (pgm->prog_modes & PM_SPM) || !addrshift || *p != 0xff || memcmp(p, p+1, block_size-1)?
stk500v2_command(pgm, buf, block_size+10, sizeof buf): 0;
if (result < 0) {
pmsg_error("write command failed\n");
return -1;