Only send write flash cmd to STK500v2 programmers if page not empty

... except if it's for a bootloader: they might need to know about
0xff pages if they use an SPM page erase command and therefore
memory does not look like NOR-memory.

This is a slight optimisation for all parts (as writing 0xff pages
on NOR-memory flash is a NOP), but more importantly, prevents a
firmware error to surface for those parts that need to carry out
value polling to determine when writing the page has finished on
the device.
This commit is contained in:
Stefan Rueger 2023-01-09 14:14:40 +00:00
parent a8931a4eb1
commit 8150930958
No known key found for this signature in database
GPG Key ID: B0B4F1FD86B1EC55
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); 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) { if (result < 0) {
pmsg_error("write command failed\n"); pmsg_error("write command failed\n");
return -1; return -1;