|
|
@ -1,32 +1,71 @@
|
|
|
|
# Arduino Make file. Refer to https://github.com/sudar/Arduino-Makefile
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#BOARD_TAG = keyboardio
|
|
|
|
# Shamelessly stolen from git's Makefile
|
|
|
|
BOARD = model01
|
|
|
|
uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
|
|
|
|
MCU = atmega32u4
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DEVICE_PORT := `ls /dev/ttyACM*`
|
|
|
|
|
|
|
|
DEVICE_PORT_BOOTLOADER := `ls /dev/ttyACM*`
|
|
|
|
|
|
|
|
ARDUINO_PATH=/usr/local/arduino
|
|
|
|
|
|
|
|
ARDUINO_LOCAL_LIB_PATH=$(HOME)/Arduino
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ifeq ($(uname_S),Darwin)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Port locations
|
|
|
|
|
|
|
|
|
|
|
|
DEVICE_PORT := `ls /dev/cu.usbmodemHID?? /dev/cu.usbmodem14*`
|
|
|
|
DEVICE_PORT := `ls /dev/cu.usbmodemHID?? /dev/cu.usbmodem14*`
|
|
|
|
DEVICE_PORT_BOOTLOADER := `ls /dev/cu.usbmodem14*`
|
|
|
|
DEVICE_PORT_BOOTLOADER := `ls /dev/cu.usbmodem14*`
|
|
|
|
ARDUINO_LIBS =
|
|
|
|
|
|
|
|
GIT_VERSION := $(shell git describe --abbrev=4 --dirty --always)
|
|
|
|
# Tools
|
|
|
|
|
|
|
|
|
|
|
|
ARDUINO_PATH=/Applications/Arduino.app/Contents/Java/
|
|
|
|
ARDUINO_PATH=/Applications/Arduino.app/Contents/Java/
|
|
|
|
|
|
|
|
ARDUINO_LOCAL_LIB_PATH=$(HOME)/Documents/Arduino
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ARDUINO_TOOLS_PATH=$(ARDUINO_PATH)/hardware/tools
|
|
|
|
ARDUINO_TOOLS_PATH=$(ARDUINO_PATH)/hardware/tools
|
|
|
|
|
|
|
|
ARDUINO_BUILDER_PATH=$(ARDUINO_PATH)/arduino-builder
|
|
|
|
|
|
|
|
AVRDUDE_PATH=$(ARDUINO_TOOLS_PATH)/avr/bin/avrdude
|
|
|
|
|
|
|
|
AVRDUDE_CONF_PATH=$(ARDUINO_TOOLS_PATH)/avr/etc/avrdude.conf
|
|
|
|
|
|
|
|
AVR_SIZE_PATH=$(ARDUINO_TOOLS_PATH)/avr/bin/avr-size
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
# Device and sketch info
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BOARD = model01
|
|
|
|
|
|
|
|
MCU = atmega32u4
|
|
|
|
FQBN=keyboardio:avr:model01
|
|
|
|
FQBN=keyboardio:avr:model01
|
|
|
|
|
|
|
|
SKETCH=KeyboardioFirmware.ino
|
|
|
|
|
|
|
|
BOOTLOADER_PATH = $(ARDUINO_LOCAL_LIB_PATH)/hardware/keyboardio/avr/bootloaders/caterina/Caterina.hex
|
|
|
|
|
|
|
|
VERBOSE= #-verbose
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
# Build
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
|
|
BUILD_PATH := $(shell mktemp -d 2>/dev/null || mktemp -d -t 'build')
|
|
|
|
BUILD_PATH := $(shell mktemp -d 2>/dev/null || mktemp -d -t 'build')
|
|
|
|
OUTPUT_PATH=./output
|
|
|
|
OUTPUT_PATH=./output
|
|
|
|
ARDUINO_LOCAL_LIB_PATH=$(HOME)/Documents/Arduino
|
|
|
|
|
|
|
|
ARDUINO_IDE_VERSION=100607
|
|
|
|
ARDUINO_IDE_VERSION=100607
|
|
|
|
VERBOSE= #-verbose
|
|
|
|
|
|
|
|
SKETCH=KeyboardioFirmware.ino
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
AVR_SIZE=$(ARDUINO_TOOLS_PATH)/avr/bin/avr-size
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
# Output
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GIT_VERSION := $(shell git describe --abbrev=4 --dirty --always)
|
|
|
|
OUTPUT_FILE_PREFIX=$(SKETCH)-$(GIT_VERSION)
|
|
|
|
OUTPUT_FILE_PREFIX=$(SKETCH)-$(GIT_VERSION)
|
|
|
|
|
|
|
|
|
|
|
|
HEX_FILE_PATH=$(OUTPUT_PATH)/$(OUTPUT_FILE_PREFIX).hex
|
|
|
|
HEX_FILE_PATH=$(OUTPUT_PATH)/$(OUTPUT_FILE_PREFIX).hex
|
|
|
|
ELF_FILE_PATH=$(OUTPUT_PATH)/$(OUTPUT_FILE_PREFIX).elf
|
|
|
|
ELF_FILE_PATH=$(OUTPUT_PATH)/$(OUTPUT_FILE_PREFIX).elf
|
|
|
|
|
|
|
|
|
|
|
|
HEX_FILE_WITH_BOOTLOADER_PATH=$(OUTPUT_PATH)/$(OUTPUT_FILE_PREFIX)-with-bootloader.hex
|
|
|
|
HEX_FILE_WITH_BOOTLOADER_PATH=$(OUTPUT_PATH)/$(OUTPUT_FILE_PREFIX)-with-bootloader.hex
|
|
|
|
|
|
|
|
|
|
|
|
# default action for `make` is `build`
|
|
|
|
# default action for `make` is `build`
|
|
|
@ -45,7 +84,7 @@ dirs:
|
|
|
|
mkdir -p $(OUTPUT_PATH)
|
|
|
|
mkdir -p $(OUTPUT_PATH)
|
|
|
|
|
|
|
|
|
|
|
|
compile: dirs
|
|
|
|
compile: dirs
|
|
|
|
$(ARDUINO_PATH)/arduino-builder \
|
|
|
|
$(ARDUINO_BUILDER_PATH) \
|
|
|
|
-hardware $(ARDUINO_PATH)/hardware \
|
|
|
|
-hardware $(ARDUINO_PATH)/hardware \
|
|
|
|
-hardware $(ARDUINO_LOCAL_LIB_PATH)/hardware \
|
|
|
|
-hardware $(ARDUINO_LOCAL_LIB_PATH)/hardware \
|
|
|
|
-tools $(ARDUINO_TOOLS_PATH) \
|
|
|
|
-tools $(ARDUINO_TOOLS_PATH) \
|
|
|
@ -63,14 +102,14 @@ compile: dirs
|
|
|
|
@echo "Have fun!\n"
|
|
|
|
@echo "Have fun!\n"
|
|
|
|
|
|
|
|
|
|
|
|
size: compile
|
|
|
|
size: compile
|
|
|
|
$(AVR_SIZE) -C --mcu=$(MCU) $(ELF_FILE_PATH)
|
|
|
|
$(AVR_SIZE_PATH) -C --mcu=$(MCU) $(ELF_FILE_PATH)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hex-with-bootloader: compile
|
|
|
|
hex-with-bootloader: compile
|
|
|
|
@cat $(HEX_FILE_PATH) | awk '/^:00000001FF/ == 0' > $(HEX_FILE_WITH_BOOTLOADER_PATH)
|
|
|
|
@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"
|
|
|
|
@echo "Using $(BOOTLOADER_PATH)"
|
|
|
|
@md5 $(ARDUINO_LOCAL_LIB_PATH)/hardware/keyboardio/avr/bootloaders/caterina/Caterina.hex
|
|
|
|
@md5 $(BOOTLOADER_PATH)
|
|
|
|
@cat $(ARDUINO_LOCAL_LIB_PATH)/hardware/keyboardio/avr/bootloaders/caterina/Caterina.hex >> $(HEX_FILE_WITH_BOOTLOADER_PATH)
|
|
|
|
@cat $(BOOTLOADER_PATH) >> $(HEX_FILE_WITH_BOOTLOADER_PATH)
|
|
|
|
@echo "Combined firmware and bootloader are now at $(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 "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"
|
|
|
|
@echo "\n\nAnd TEST THIS ON REAL HARDWARE BEFORE YOU GIVE IT TO ANYONE\n\n"
|
|
|
@ -80,8 +119,8 @@ reset-device:
|
|
|
|
|
|
|
|
|
|
|
|
flash: compile reset-device
|
|
|
|
flash: compile reset-device
|
|
|
|
sleep 3
|
|
|
|
sleep 3
|
|
|
|
$(ARDUINO_TOOLS_PATH)/avr/bin/avrdude \
|
|
|
|
$(AVRDUDE_PATH) \
|
|
|
|
-C$(ARDUINO_TOOLS_PATH)/avr/etc/avrdude.conf \
|
|
|
|
-C$(AVRDUDE_CONF_PATH) \
|
|
|
|
-v \
|
|
|
|
-v \
|
|
|
|
-p$(MCU) \
|
|
|
|
-p$(MCU) \
|
|
|
|
-cavr109 \
|
|
|
|
-cavr109 \
|
|
|
@ -91,8 +130,8 @@ flash: compile reset-device
|
|
|
|
-Uflash:w:$(HEX_FILE_PATH):i
|
|
|
|
-Uflash:w:$(HEX_FILE_PATH):i
|
|
|
|
|
|
|
|
|
|
|
|
program:
|
|
|
|
program:
|
|
|
|
$(ARDUINO_TOOLS_PATH)/avr/bin/avrdude \
|
|
|
|
$(AVRDUDE_PATH) \
|
|
|
|
-C$(ARDUINO_TOOLS_PATH)/avr/etc/avrdude.conf \
|
|
|
|
-C$(AVRDUDE_CONF_PATH) \
|
|
|
|
-v \
|
|
|
|
-v \
|
|
|
|
-p$(MCU) \
|
|
|
|
-p$(MCU) \
|
|
|
|
-cusbtiny \
|
|
|
|
-cusbtiny \
|
|
|
|