From 52734bafc6af7cfc4b72824629159900ee88f6a6 Mon Sep 17 00:00:00 2001
From: Stefan Rueger <stefan.rueger@open.ac.uk>
Date: Thu, 28 Apr 2022 17:29:06 +0100
Subject: [PATCH] Add option -A to separately disable trailing-0xff removal

---
 src/main.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/main.c b/src/main.c
index 526ae35f..f5381834 100644
--- a/src/main.c
+++ b/src/main.c
@@ -110,7 +110,8 @@ static void usage(void)
  "  -B <bitclock>              Specify JTAG/STK500v2 bit clock period (us).\n"
  "  -C <config-file>           Specify location of configuration file.\n"
  "  -c <programmer>            Specify programmer type.\n"
- "  -D                         Disable auto erase for flash memory\n"
+ "  -A                         Disable trailing-0xff removal from file and AVR read.\n"
+ "  -D                         Disable auto erase for flash memory; implies -A.\n"
  "  -i <delay>                 ISP Clock Delay [in microseconds]\n"
  "  -P <port>                  Specify connection port.\n"
  "  -F                         Override invalid signature check.\n"
@@ -442,7 +443,7 @@ int main(int argc, char * argv [])
   /*
    * process command line arguments
    */
-  while ((ch = getopt(argc,argv,"?b:B:c:C:DeE:Fi:l:np:OP:qstU:uvVx:yY:")) != -1) {
+  while ((ch = getopt(argc,argv,"?Ab:B:c:C:DeE:Fi:l:np:OP:qstU:uvVx:yY:")) != -1) {
 
     switch (ch) {
       case 'b': /* override default programmer baud rate */
@@ -528,6 +529,9 @@ int main(int argc, char * argv [])
 
       case 'D': /* disable auto erase */
         uflags &= ~UF_AUTO_ERASE;
+        /* fall through */
+
+      case 'A': /* explicit disabling of trailing-0xff removal */
         disable_trailing_ff_removal();
         break;