From 538d6ac3a278ae7e3f7ff55ea67c17012d063733 Mon Sep 17 00:00:00 2001
From: Kevin O'Connor <kevin@koconnor.net>
Date: Sat, 26 Oct 2019 18:33:00 -0400
Subject: [PATCH] flash_usb: Use "-s" option to specify flash offset on atsamd

Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
---
 scripts/flash_usb.py | 4 +---
 src/atsamd/Makefile  | 2 +-
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/scripts/flash_usb.py b/scripts/flash_usb.py
index 9bad50408..13fa51b3c 100755
--- a/scripts/flash_usb.py
+++ b/scripts/flash_usb.py
@@ -135,7 +135,7 @@ def flash_atsam4(options, binfile):
         sys.exit(-1)
 
 def flash_atsamd(options, binfile):
-    extra_flags = ["--offset=" + options.offset, "-b", "-R"]
+    extra_flags = ["--offset=0x%x" % (options.start,), "-b", "-R"]
     try:
         flash_bossac(options.device, binfile, extra_flags)
     except error as e:
@@ -228,8 +228,6 @@ def main():
                     help="micro-controller type")
     opts.add_option("-d", "--device", type="string", dest="device",
                     help="serial port device")
-    opts.add_option("-o", "--offset", type="string", dest="offset",
-                    help="flash offset")
     opts.add_option("-s", "--start", type="int", dest="start",
                     help="start address in flash")
     opts.add_option("--no-sudo", action="store_false", dest="sudo",
diff --git a/src/atsamd/Makefile b/src/atsamd/Makefile
index d856376f0..658c5ad6a 100644
--- a/src/atsamd/Makefile
+++ b/src/atsamd/Makefile
@@ -54,4 +54,4 @@ BOSSAC_OFFSET-$(CONFIG_MACH_SAMD51) := 0x4000
 
 flash: $(OUT)klipper.bin lib/bossac/bin/bossac
 	@echo "  Flashing $< to $(FLASH_DEVICE)"
-	$(Q)$(PYTHON) ./scripts/flash_usb.py -t atsamd -d "$(FLASH_DEVICE)" -o $(BOSSAC_OFFSET-y) $(OUT)klipper.bin
+	$(Q)$(PYTHON) ./scripts/flash_usb.py -t atsamd -d "$(FLASH_DEVICE)" -s "$(BOSSAC_OFFSET-y)" $(OUT)klipper.bin