Add support for building and including the bootloader. Clean up makefile a tiny bit

pull/19/head
Jesse Vincent 8 years ago
parent 04e7d78c58
commit c8fa11bb22

@ -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 ;

Loading…
Cancel
Save