From e505ab0df1cb4c31b171dde285fa4361d1e89df2 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Fri, 30 Nov 2018 22:22:42 -0500 Subject: [PATCH] samd21: Add support for flashing an application via the bossac tool Signed-off-by: Kevin O'Connor --- docs/Bootloaders.md | 8 ++++++-- src/samd21/Makefile | 12 +++++++++--- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/docs/Bootloaders.md b/docs/Bootloaders.md index 079ad164..77f3ad3b 100755 --- a/docs/Bootloaders.md +++ b/docs/Bootloaders.md @@ -195,8 +195,12 @@ SAMD21. One comes standard with the "Arduino Zero" and the other comes standard with the "Arduino M0". The Arduino Zero uses an 8KiB bootloader (the application must be -compiled with a start address of 8KiB). This document does not cover -the flashing mechanism for this bootloader. +compiled with a start address of 8KiB). One can enter the bootloader +by double clicking the reset button. To flash an application use +something like: +``` +bossac -U -p "$(FLASH_DEVICE)" --offset=0x2000 -w out/klipper.bin -v -b -R +``` The Arduino M0 uses a 16KiB bootloader (the application must be compiled with a start address of 16KiB). To flash an application, diff --git a/src/samd21/Makefile b/src/samd21/Makefile index 34de8e48..abe21013 100644 --- a/src/samd21/Makefile +++ b/src/samd21/Makefile @@ -42,6 +42,12 @@ $(OUT)klipper.elf.hex: $(OUT)klipper.elf @echo " Creating hex file $@" $(Q)$(OBJCOPY) -j .text -j .relocate -O ihex $< $@ -flash: $(OUT)klipper.bin - @echo "" - @echo " The SAMD21 build does not currently support 'make flash'" +# Flash rules +lib/bossac/bin/bossac: + @echo " Building bossac" + $(Q)make -C lib/bossac bin/bossac + +flash: $(OUT)klipper.bin lib/bossac/bin/bossac + @echo " Flashing $^ to $(FLASH_DEVICE) via bossac" + $(Q)if [ -z $(FLASH_DEVICE) ]; then echo "Please specify FLASH_DEVICE"; exit 1; fi + $(Q)lib/bossac/bin/bossac -U -p "$(FLASH_DEVICE)" --offset=0x2000 -w $(OUT)klipper.bin -v -b -R