diff --git a/ChangeLog b/ChangeLog
index c933a6ef..9ca7cae8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2021-11-07  Joerg Wunsch <j.gnu@uriah.heep.sax.de>
+
+	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
+
 2021-11-07  Joerg Wunsch <j.gnu@uriah.heep.sax.de>
 
 	Submitted by Michael Petersen:
diff --git a/NEWS b/NEWS
index 482c593f..11e50114 100644
--- a/NEWS
+++ b/NEWS
@@ -102,6 +102,7 @@ Current:
     patch #9744: Patch for ATMega324A support
     patch #10000: Add support for extended UPDI device context
     patch #9697: Add iseavrprog support
+    patch #10017: uspasp / tpi: Automatically clear configuration byte (fuse) before writing it
 
   * Internals:
     - New avrdude.conf keyword "family_id", used to verify SIB attributes
diff --git a/usbasp.c b/usbasp.c
index 101a4a3a..62483bc8 100644
--- a/usbasp.c
+++ b/usbasp.c
@@ -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 );