From c8fa11bb2299915b013855c0efec08a14081631c Mon Sep 17 00:00:00 2001 From: Jesse Vincent Date: Mon, 19 Sep 2016 13:25:29 +0800 Subject: [PATCH] Add support for building and including the bootloader. Clean up makefile a tiny bit --- Makefile | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 4957fae8..b64c12f0 100644 --- a/Makefile +++ b/Makefile @@ -16,9 +16,10 @@ BUILD_PATH := $(shell mktemp -d 2>/dev/null || mktemp -d -t 'build') OUTPUT_PATH=./output ARDUINO_LOCAL_LIB_PATH=$(HOME)/Documents/Arduino ARDUINO_IDE_VERSION=100607 -VERBOSE= -verbose +VERBOSE= #-verbose SKETCH=KeyboardioFirmware.ino +AVR_SIZE=$(ARDUINO_TOOLS_PATH)/avr/bin/avr-size OUTPUT_FILE_PREFIX=$(SKETCH)-$(GIT_VERSION) @@ -26,6 +27,7 @@ OUTPUT_FILE_PREFIX=$(SKETCH)-$(GIT_VERSION) HEX_FILE_PATH=$(OUTPUT_PATH)/$(OUTPUT_FILE_PREFIX).hex ELF_FILE_PATH=$(OUTPUT_PATH)/$(OUTPUT_FILE_PREFIX).elf +HEX_FILE_WITH_BOOTLOADER_PATH=$(OUTPUT_PATH)/$(OUTPUT_FILE_PREFIX)-with-bootloader.hex # default action for `make` is `build` build: compile size @@ -54,11 +56,23 @@ compile: dirs -build-path $(BUILD_PATH) \ -ide-version $(ARDUINO_IDE_VERSION) \ $(SKETCH) - cp $(BUILD_PATH)/$(SKETCH).hex $(HEX_FILE_PATH) - cp $(BUILD_PATH)/$(SKETCH).elf $(ELF_FILE_PATH) + @cp $(BUILD_PATH)/$(SKETCH).hex $(HEX_FILE_PATH) + @cp $(BUILD_PATH)/$(SKETCH).elf $(ELF_FILE_PATH) + @echo "Firmware is available at $(HEX_FILE_PATH) + @echo "Have fun!\n" size: compile - $(ARDUINO_TOOLS_PATH)/avr/bin/avr-size -C --mcu=$(MCU) $(ELF_FILE_PATH) + $(AVR_SIZE) -C --mcu=$(MCU) $(ELF_FILE_PATH) + + +hex-with-bootloader: compile + @cat $(HEX_FILE_PATH) | awk '/^:00000001FF/ == 0' > $(HEX_FILE_WITH_BOOTLOADER_PATH) + @echo "Using $(ARDUINO_LOCAL_LIB_PATH)/hardware/keyboardio/avr/bootloaders/caterina/Caterina.hex" + @md5 $(ARDUINO_LOCAL_LIB_PATH)/hardware/keyboardio/avr/bootloaders/caterina/Caterina.hex + @cat $(ARDUINO_LOCAL_LIB_PATH)/hardware/keyboardio/avr/bootloaders/caterina/Caterina.hex >> $(HEX_FILE_WITH_BOOTLOADER_PATH) + @echo "Combined firmware and bootloader are now at $(HEX_FILE_WITH_BOOTLOADER_PATH)" + @echo "Make sure you have the bootloader version you expect." + @echo "\n\nAnd TEST THIS ON REAL HARDWARE BEFORE YOU GIVE IT TO ANYONE\n\n" reset-device: stty -f $(DEVICE_PORT) 1200 ;