Submitted by Martin Thierer:

patch #10017: uspasp / tpi: Automatically clear configuration byte (fuse) before writing it
* usbasp.c (usbasp_tpi_paged_write): clear fuse region before writing it



git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1468 81a1dc3b-b13d-400b-aceb-764788c761c2
This commit is contained in:
Joerg Wunsch
2021-11-07 20:10:24 +00:00
parent 62a00cedc7
commit 91948428a6
3 changed files with 25 additions and 0 deletions

View File

@@ -1156,6 +1156,24 @@ static int usbasp_tpi_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
pr = addr + m->offset;
writed = 0;
/* must erase fuse first */
if(strcmp(m->desc, "fuse") == 0)
{
/* Set PR */
usbasp_tpi_send_byte(pgm, TPI_OP_SSTPR(0));
usbasp_tpi_send_byte(pgm, (pr & 0xFF) | 1 );
usbasp_tpi_send_byte(pgm, TPI_OP_SSTPR(1));
usbasp_tpi_send_byte(pgm, (pr >> 8) );
/* select SECTION_ERASE */
usbasp_tpi_send_byte(pgm, TPI_OP_SOUT(NVMCMD));
usbasp_tpi_send_byte(pgm, NVMCMD_SECTION_ERASE);
/* dummy write */
usbasp_tpi_send_byte(pgm, TPI_OP_SST_INC);
usbasp_tpi_send_byte(pgm, 0x00);
usbasp_tpi_nvm_waitbusy(pgm);
}
/* Set PR to flash */
usbasp_tpi_send_byte(pgm, TPI_OP_SSTPR(0));
usbasp_tpi_send_byte(pgm, (pr & 0xFF) | 1 );