From 95da7a137bf7f39406d64f92b76c80276c251829 Mon Sep 17 00:00:00 2001
From: Joerg Wunsch <j@uriah.heep.sax.de>
Date: Thu, 20 Nov 2014 09:20:44 +0000
Subject: [PATCH] bug #41561: AVRDUDE 6.0.1/USBasp doesn't write first bytes of
 flash page * usbasp.c (usbasp_spi_paged_write): Remove USBASP_BLOCKFLAG_LAST.
 It is no longer needed, as we always write full pages now in paged write
 mode.

This prevents each flash page from being written twice, where the
second attempt on older devices (ATmega64/128) signalled an immediate
"ready" condition when polling (likely a silicon bug) even though they
were still in progress.  This caused the USBasp firmware to proceed,
and fill the page buffer anew which eventually caused the data
corruption.



git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1343 81a1dc3b-b13d-400b-aceb-764788c761c2
---
 ChangeLog | 8 ++++++++
 NEWS      | 2 ++
 usbasp.c  | 1 -
 3 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 7ebaf04b..fccde052 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2014-11-20  Joerg Wunsch <j.gnu@uriah.heep.sax.de>
+
+	bug #41561: AVRDUDE 6.0.1/USBasp doesn't write first bytes of
+	flash page
+	* usbasp.c (usbasp_spi_paged_write): Remove USBASP_BLOCKFLAG_LAST.
+	It is no longer needed, as we always write full pages now in paged
+	write mode.
+
 2014-11-19  Joerg Wunsch <j.gnu@uriah.heep.sax.de>
 
 	bug #43626: Inconsistent timeouts in stk500v2
diff --git a/NEWS b/NEWS
index e952b983..ea8cf844 100644
--- a/NEWS
+++ b/NEWS
@@ -24,6 +24,8 @@ Current:
     - bug #22248: Read efuse error (partial fix)
     - bug #42267: jtag3isp fails to read lock and fuse bytes directly
                   after changing lock byte
+    - bug #41561: AVRDUDE 6.0.1/USBasp doesn't write first bytes of
+                  flash page
 
   * Internals:
     - ...
diff --git a/usbasp.c b/usbasp.c
index 5058cd80..e75eed1d 100644
--- a/usbasp.c
+++ b/usbasp.c
@@ -795,7 +795,6 @@ static int usbasp_spi_paged_write(PROGRAMMER * pgm, AVRPART * p, AVRMEM * m,
 
     if (wbytes <= blocksize) {
       blocksize = wbytes;
-      blockflags |= USBASP_BLOCKFLAG_LAST;
     }
     wbytes -= blocksize;