mirror of
https://github.com/Keychron/qmk_firmware.git
synced 2024-12-25 18:48:05 +06:00
c66df16644
* Branch point for 2020 November 28 Breaking Change * Remove matrix_col_t to allow MATRIX_ROWS > 32 (#10183) * Add support for soft serial to ATmega32U2 (#10204) * Change MIDI velocity implementation to allow direct control of velocity value (#9940) * Add ability to build a subset of all keyboards based on platform. * Actually use eeprom_driver_init(). * Make bootloader_jump weak for ChibiOS. (#10417) * Joystick 16-bit support (#10439) * Per-encoder resolutions (#10259) * Share button state from mousekey to pointing_device (#10179) * Add hotfix for chibios keyboards not wake (#10088) * Add advanced/efficient RGB Matrix Indicators (#8564) * Naming change. * Support for STM32 GPIOF,G,H,I,J,K (#10206) * Add milc as a dependency and remove the installed milc (#10563) * ChibiOS upgrade: early init conversions (#10214) * ChibiOS upgrade: configuration file migrator (#9952) * Haptic and solenoid cleanup (#9700) * XD75 cleanup (#10524) * OLED display update interval support (#10388) * Add definition based on currently-selected serial driver. (#10716) * New feature: Retro Tapping per key (#10622) * Allow for modification of output RGB values when using rgblight/rgb_matrix. (#10638) * Add housekeeping task callbacks so that keyboards/keymaps are capable of executing code for each main loop iteration. (#10530) * Rescale both ChibiOS and AVR backlighting. * Reduce Helix keyboard build variation (#8669) * Minor change to behavior allowing display updates to continue between task ticks (#10750) * Some GPIO manipulations in matrix.c change to atomic. (#10491) * qmk cformat (#10767) * [Keyboard] Update the Speedo firmware for v3.0 (#10657) * Maartenwut/Maarten namechange to evyd13/Evy (#10274) * [quantum] combine repeated lines of code (#10837) * Add step sequencer feature (#9703) * aeboards/ext65 refactor (#10820) * Refactor xelus/dawn60 for Rev2 later (#10584) * add DEBUG_MATRIX_SCAN_RATE_ENABLE to common_features.mk (#10824) * [Core] Added `add_oneshot_mods` & `del_oneshot_mods` (#10549) * update chibios os usb for the otg driver (#8893) * Remove HD44780 References, Part 4 (#10735) * [Keyboard] Add Valor FRL TKL (+refactor) (#10512) * Fix cursor position bug in oled_write_raw functions (#10800) * Fixup version.h writing when using SKIP_VERSION=yes (#10972) * Allow for certain code in the codebase assuming length of string. (#10974) * Add AT90USB support for serial.c (#10706) * Auto shift: support repeats and early registration (#9826) * Rename ledmatrix.h to match .c file (#7949) * Split RGB_MATRIX_ENABLE into _ENABLE and _DRIVER (#10231) * Split LED_MATRIX_ENABLE into _ENABLE and _DRIVER (#10840) * Merge point for 2020 Nov 28 Breaking Change
404 lines
14 KiB
Makefile
404 lines
14 KiB
Makefile
# Hey Emacs, this is a -*- makefile -*-
|
|
##############################################################################
|
|
# Architecture or project specific options
|
|
#
|
|
|
|
# Stack size to be allocated to the Cortex-M process stack. This stack is
|
|
# the stack used by the main() thread.
|
|
ifeq ($(USE_PROCESS_STACKSIZE),)
|
|
USE_PROCESS_STACKSIZE = 0x800
|
|
endif
|
|
|
|
# Stack size to the allocated to the Cortex-M main/exceptions stack. This
|
|
# stack is used for processing interrupts and exceptions.
|
|
ifeq ($(USE_EXCEPTIONS_STACKSIZE),)
|
|
USE_EXCEPTIONS_STACKSIZE = 0x400
|
|
endif
|
|
|
|
#
|
|
# Architecture or project specific options
|
|
##############################################################################
|
|
|
|
##############################################################################
|
|
# Project, sources and paths
|
|
#
|
|
|
|
# Imported source files and paths
|
|
OPT_OS = chibios
|
|
CHIBIOS = $(TOP_DIR)/lib/chibios
|
|
CHIBIOS_CONTRIB = $(TOP_DIR)/lib/chibios-contrib
|
|
# Startup files. Try a few different locations, for compability with old versions and
|
|
# for things hardware in the contrib repository
|
|
STARTUP_MK = $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/startup_$(MCU_STARTUP).mk
|
|
ifeq ("$(wildcard $(STARTUP_MK))","")
|
|
STARTUP_MK = $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/mk/startup_$(MCU_STARTUP).mk
|
|
ifeq ("$(wildcard $(STARTUP_MK))","")
|
|
STARTUP_MK = $(CHIBIOS_CONTRIB)/os/common/startup/ARMCMx/compilers/GCC/mk/startup_$(MCU_STARTUP).mk
|
|
endif
|
|
endif
|
|
include $(STARTUP_MK)
|
|
# HAL-OSAL files (optional).
|
|
include $(CHIBIOS)/os/hal/hal.mk
|
|
|
|
ifeq ("$(PLATFORM_NAME)","")
|
|
PLATFORM_NAME = platform
|
|
endif
|
|
|
|
PLATFORM_MK = $(CHIBIOS)/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)/$(PLATFORM_NAME).mk
|
|
ifeq ("$(wildcard $(PLATFORM_MK))","")
|
|
PLATFORM_MK = $(CHIBIOS_CONTRIB)/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)/$(PLATFORM_NAME).mk
|
|
endif
|
|
include $(PLATFORM_MK)
|
|
|
|
BOARD_MK :=
|
|
|
|
ifneq ("$(wildcard $(KEYBOARD_PATH_5)/boards/$(BOARD)/board.mk)","")
|
|
BOARD_PATH = $(KEYBOARD_PATH_5)
|
|
BOARD_MK += $(KEYBOARD_PATH_5)/boards/$(BOARD)/board.mk
|
|
else ifneq ("$(wildcard $(KEYBOARD_PATH_4)/boards/$(BOARD)/board.mk)","")
|
|
BOARD_PATH = $(KEYBOARD_PATH_4)
|
|
BOARD_MK += $(KEYBOARD_PATH_4)/boards/$(BOARD)/board.mk
|
|
else ifneq ("$(wildcard $(KEYBOARD_PATH_3)/boards/$(BOARD)/board.mk)","")
|
|
BOARD_PATH = $(KEYBOARD_PATH_3)
|
|
BOARD_MK += $(KEYBOARD_PATH_3)/boards/$(BOARD)/board.mk
|
|
else ifneq ("$(wildcard $(KEYBOARD_PATH_2)/boards/$(BOARD)/board.mk)","")
|
|
BOARD_PATH = $(KEYBOARD_PATH_2)
|
|
BOARD_MK += $(KEYBOARD_PATH_2)/boards/$(BOARD)/board.mk
|
|
else ifneq ("$(wildcard $(KEYBOARD_PATH_1)/boards/$(BOARD)/board.mk)","")
|
|
BOARD_PATH = $(KEYBOARD_PATH_1)
|
|
BOARD_MK += $(KEYBOARD_PATH_1)/boards/$(BOARD)/board.mk
|
|
else ifneq ("$(wildcard $(TOP_DIR)/platforms/chibios/$(BOARD)/board/board.mk)","")
|
|
BOARD_PATH = $(TOP_DIR)/platforms/chibios/$(BOARD)
|
|
BOARD_MK += $(TOP_DIR)/platforms/chibios/$(BOARD)/board/board.mk
|
|
KEYBOARD_PATHS += $(BOARD_PATH)/configs
|
|
endif
|
|
|
|
ifeq ("$(wildcard $(BOARD_MK))","")
|
|
BOARD_MK = $(CHIBIOS)/os/hal/boards/$(BOARD)/board.mk
|
|
ifeq ("$(wildcard $(BOARD_MK))","")
|
|
BOARD_MK = $(CHIBIOS_CONTRIB)/os/hal/boards/$(BOARD)/board.mk
|
|
endif
|
|
endif
|
|
|
|
# Bootloader address
|
|
ifdef STM32_BOOTLOADER_ADDRESS
|
|
OPT_DEFS += -DSTM32_BOOTLOADER_ADDRESS=$(STM32_BOOTLOADER_ADDRESS)
|
|
endif
|
|
|
|
# Work out if we need to set up the include for the bootloader definitions
|
|
ifneq ("$(wildcard $(KEYBOARD_PATH_5)/bootloader_defs.h)","")
|
|
OPT_DEFS += -include $(KEYBOARD_PATH_5)/bootloader_defs.h
|
|
else ifneq ("$(wildcard $(KEYBOARD_PATH_5)/boards/$(BOARD)/bootloader_defs.h)","")
|
|
OPT_DEFS += -include $(KEYBOARD_PATH_5)/boards/$(BOARD)/bootloader_defs.h
|
|
else ifneq ("$(wildcard $(KEYBOARD_PATH_4)/bootloader_defs.h)","")
|
|
OPT_DEFS += -include $(KEYBOARD_PATH_4)/bootloader_defs.h
|
|
else ifneq ("$(wildcard $(KEYBOARD_PATH_4)/boards/$(BOARD)/bootloader_defs.h)","")
|
|
OPT_DEFS += -include $(KEYBOARD_PATH_4)/boards/$(BOARD)/bootloader_defs.h
|
|
else ifneq ("$(wildcard $(KEYBOARD_PATH_3)/bootloader_defs.h)","")
|
|
OPT_DEFS += -include $(KEYBOARD_PATH_3)/bootloader_defs.h
|
|
else ifneq ("$(wildcard $(KEYBOARD_PATH_3)/boards/$(BOARD)/bootloader_defs.h)","")
|
|
OPT_DEFS += -include $(KEYBOARD_PATH_3)/boards/$(BOARD)/bootloader_defs.h
|
|
else ifneq ("$(wildcard $(KEYBOARD_PATH_2)/bootloader_defs.h)","")
|
|
OPT_DEFS += -include $(KEYBOARD_PATH_2)/bootloader_defs.h
|
|
else ifneq ("$(wildcard $(KEYBOARD_PATH_2)/boards/$(BOARD)/bootloader_defs.h)","")
|
|
OPT_DEFS += -include $(KEYBOARD_PATH_2)/boards/$(BOARD)/bootloader_defs.h
|
|
else ifneq ("$(wildcard $(KEYBOARD_PATH_1)/bootloader_defs.h)","")
|
|
OPT_DEFS += -include $(KEYBOARD_PATH_1)/bootloader_defs.h
|
|
else ifneq ("$(wildcard $(KEYBOARD_PATH_1)/boards/$(BOARD)/bootloader_defs.h)","")
|
|
OPT_DEFS += -include $(KEYBOARD_PATH_1)/boards/$(BOARD)/bootloader_defs.h
|
|
else ifneq ("$(wildcard $(BOARD_PATH)/configs/bootloader_defs.h)","")
|
|
OPT_DEFS += -include $(BOARD_PATH)/configs/bootloader_defs.h
|
|
endif
|
|
|
|
# Work out the config file directories
|
|
ifneq ("$(wildcard $(KEYBOARD_PATH_5)/chconf.h)","")
|
|
CHCONFDIR = $(KEYBOARD_PATH_5)
|
|
else ifneq ("$(wildcard $(KEYBOARD_PATH_4)/chconf.h)","")
|
|
CHCONFDIR = $(KEYBOARD_PATH_4)
|
|
else ifneq ("$(wildcard $(KEYBOARD_PATH_3)/chconf.h)","")
|
|
CHCONFDIR = $(KEYBOARD_PATH_3)
|
|
else ifneq ("$(wildcard $(KEYBOARD_PATH_2)/chconf.h)","")
|
|
CHCONFDIR = $(KEYBOARD_PATH_2)
|
|
else ifneq ("$(wildcard $(KEYBOARD_PATH_1)/chconf.h)","")
|
|
CHCONFDIR = $(KEYBOARD_PATH_1)
|
|
else ifneq ("$(wildcard $(TOP_DIR)/platforms/chibios/$(BOARD)/configs/chconf.h)","")
|
|
CHCONFDIR = $(TOP_DIR)/platforms/chibios/$(BOARD)/configs
|
|
else ifneq ("$(wildcard $(TOP_DIR)/platforms/chibios/common/configs/chconf.h)","")
|
|
CHCONFDIR = $(TOP_DIR)/platforms/chibios/common/configs
|
|
endif
|
|
|
|
ifneq ("$(wildcard $(KEYBOARD_PATH_5)/halconf.h)","")
|
|
HALCONFDIR = $(KEYBOARD_PATH_5)
|
|
else ifneq ("$(wildcard $(KEYBOARD_PATH_4)/halconf.h)","")
|
|
HALCONFDIR = $(KEYBOARD_PATH_4)
|
|
else ifneq ("$(wildcard $(KEYBOARD_PATH_3)/halconf.h)","")
|
|
HALCONFDIR = $(KEYBOARD_PATH_3)
|
|
else ifneq ("$(wildcard $(KEYBOARD_PATH_2)/halconf.h)","")
|
|
HALCONFDIR = $(KEYBOARD_PATH_2)
|
|
else ifneq ("$(wildcard $(KEYBOARD_PATH_1)/halconf.h)","")
|
|
HALCONFDIR = $(KEYBOARD_PATH_1)
|
|
else ifneq ("$(wildcard $(TOP_DIR)/platforms/chibios/$(BOARD)/configs/halconf.h)","")
|
|
HALCONFDIR = $(TOP_DIR)/platforms/chibios/$(BOARD)/configs
|
|
else ifneq ("$(wildcard $(TOP_DIR)/platforms/chibios/common/configs/halconf.h)","")
|
|
HALCONFDIR = $(TOP_DIR)/platforms/chibios/common/configs
|
|
endif
|
|
|
|
# HAL-OSAL files (optional).
|
|
include $(CHIBIOS)/os/hal/hal.mk
|
|
|
|
ifeq ("$(PLATFORM_NAME)","")
|
|
PLATFORM_NAME = platform
|
|
endif
|
|
|
|
PLATFORM_MK = $(CHIBIOS)/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)/$(PLATFORM_NAME).mk
|
|
ifeq ("$(wildcard $(PLATFORM_MK))","")
|
|
PLATFORM_MK = $(CHIBIOS_CONTRIB)/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)/$(PLATFORM_NAME).mk
|
|
endif
|
|
include $(PLATFORM_MK)
|
|
|
|
|
|
include $(BOARD_MK)
|
|
-include $(CHIBIOS)/os/hal/osal/rt/osal.mk # ChibiOS <= 19.x
|
|
-include $(CHIBIOS)/os/hal/osal/rt-nil/osal.mk # ChibiOS >= 20.x
|
|
# RTOS files (optional).
|
|
include $(CHIBIOS)/os/rt/rt.mk
|
|
# Compability with old version
|
|
PORT_V = $(CHIBIOS)/os/rt/ports/ARMCMx/compilers/GCC/mk/port_v$(ARMV)m.mk
|
|
ifeq ("$(wildcard $(PORT_V))","")
|
|
PORT_V = $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v$(ARMV)m.mk
|
|
endif
|
|
include $(PORT_V)
|
|
# Other files (optional).
|
|
include $(CHIBIOS)/os/hal/lib/streams/streams.mk
|
|
|
|
RULESPATH = $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC
|
|
ifeq ("$(wildcard $(RULESPATH)/rules.mk)","")
|
|
RULESPATH = $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC
|
|
endif
|
|
|
|
# Define linker script file here
|
|
ifneq ("$(wildcard $(KEYBOARD_PATH_5)/ld/$(MCU_LDSCRIPT).ld)","")
|
|
LDSCRIPT = $(KEYBOARD_PATH_5)/ld/$(MCU_LDSCRIPT).ld
|
|
else ifneq ("$(wildcard $(KEYBOARD_PATH_4)/ld/$(MCU_LDSCRIPT).ld)","")
|
|
LDSCRIPT = $(KEYBOARD_PATH_4)/ld/$(MCU_LDSCRIPT).ld
|
|
else ifneq ("$(wildcard $(KEYBOARD_PATH_3)/ld/$(MCU_LDSCRIPT).ld)","")
|
|
LDSCRIPT = $(KEYBOARD_PATH_3)/ld/$(MCU_LDSCRIPT).ld
|
|
else ifneq ("$(wildcard $(KEYBOARD_PATH_2)/ld/$(MCU_LDSCRIPT).ld)","")
|
|
LDSCRIPT = $(KEYBOARD_PATH_2)/ld/$(MCU_LDSCRIPT).ld
|
|
else ifneq ("$(wildcard $(KEYBOARD_PATH_1)/ld/$(MCU_LDSCRIPT).ld)","")
|
|
LDSCRIPT = $(KEYBOARD_PATH_1)/ld/$(MCU_LDSCRIPT).ld
|
|
else ifneq ("$(wildcard $(TOP_DIR)/platforms/chibios/common/ld/$(MCU_LDSCRIPT).ld)","")
|
|
LDSCRIPT = $(TOP_DIR)/platforms/chibios/common/ld/$(MCU_LDSCRIPT).ld
|
|
else ifneq ("$(wildcard $(STARTUPLD_CONTRIB)/$(MCU_LDSCRIPT).ld)","")
|
|
LDSCRIPT = $(STARTUPLD_CONTRIB)/$(MCU_LDSCRIPT).ld
|
|
USE_CHIBIOS_CONTRIB = yes
|
|
else
|
|
LDSCRIPT = $(STARTUPLD)/$(MCU_LDSCRIPT).ld
|
|
endif
|
|
|
|
CHIBISRC = $(STARTUPSRC) \
|
|
$(KERNSRC) \
|
|
$(PORTSRC) \
|
|
$(OSALSRC) \
|
|
$(HALSRC) \
|
|
$(PLATFORMSRC) \
|
|
$(BOARDSRC) \
|
|
$(STREAMSSRC) \
|
|
$(CHIBIOS)/os/various/syscalls.c
|
|
|
|
# Ensure the ASM files are not subjected to LTO -- it'll strip out interrupt handlers otherwise.
|
|
QUANTUM_LIB_SRC += $(STARTUPASM) $(PORTASM) $(OSALASM)
|
|
|
|
CHIBISRC := $(patsubst $(TOP_DIR)/%,%,$(CHIBISRC))
|
|
|
|
EXTRAINCDIRS += $(CHIBIOS)/os/license $(CHIBIOS)/os/oslib/include \
|
|
$(TOP_DIR)/platforms/chibios/$(BOARD)/configs \
|
|
$(TOP_DIR)/platforms/chibios/common/configs \
|
|
$(HALCONFDIR) $(CHCONFDIR) \
|
|
$(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \
|
|
$(HALINC) $(PLATFORMINC) $(BOARDINC) $(TESTINC) \
|
|
$(STREAMSINC) $(CHIBIOS)/os/various $(COMMON_VPATH)
|
|
|
|
#
|
|
# ChibiOS-Contrib
|
|
##############################################################################
|
|
|
|
# Work out if we're using ChibiOS-Contrib by checking if halconf_community.h exists
|
|
ifneq ("$(wildcard $(KEYBOARD_PATH_5)/halconf_community.h)","")
|
|
USE_CHIBIOS_CONTRIB = yes
|
|
else ifneq ("$(wildcard $(KEYBOARD_PATH_4)/halconf_community.h)","")
|
|
USE_CHIBIOS_CONTRIB = yes
|
|
else ifneq ("$(wildcard $(KEYBOARD_PATH_3)/halconf_community.h)","")
|
|
USE_CHIBIOS_CONTRIB = yes
|
|
else ifneq ("$(wildcard $(KEYBOARD_PATH_2)/halconf_community.h)","")
|
|
USE_CHIBIOS_CONTRIB = yes
|
|
else ifneq ("$(wildcard $(KEYBOARD_PATH_1)/halconf_community.h)","")
|
|
USE_CHIBIOS_CONTRIB = yes
|
|
else ifneq ("$(wildcard $(TOP_DIR)/platforms/chibios/$(BOARD)/configs/halconf_community.h)","")
|
|
USE_CHIBIOS_CONTRIB = yes
|
|
endif
|
|
|
|
ifeq ($(strip $(USE_CHIBIOS_CONTRIB)),yes)
|
|
include $(CHIBIOS_CONTRIB)/os/hal/hal.mk
|
|
CHIBISRC += $(PLATFORMSRC_CONTRIB) $(HALSRC_CONTRIB)
|
|
EXTRAINCDIRS += $(PLATFORMINC_CONTRIB) $(HALINC_CONTRIB) $(CHIBIOS_CONTRIB)/os/various
|
|
endif
|
|
|
|
#
|
|
# Project, sources and paths
|
|
##############################################################################
|
|
|
|
##############################################################################
|
|
# Injected configs
|
|
#
|
|
ifneq ("$(wildcard $(BOARD_PATH)/configs/config.h)","")
|
|
CONFIG_H += $(BOARD_PATH)/configs/config.h
|
|
endif
|
|
ifneq ("$(wildcard $(BOARD_PATH)/configs/post_config.h)","")
|
|
POST_CONFIG_H += $(BOARD_PATH)/configs/post_config.h
|
|
endif
|
|
|
|
##############################################################################
|
|
# Compiler settings
|
|
#
|
|
CC = arm-none-eabi-gcc
|
|
OBJCOPY = arm-none-eabi-objcopy
|
|
OBJDUMP = arm-none-eabi-objdump
|
|
SIZE = arm-none-eabi-size
|
|
AR = arm-none-eabi-ar
|
|
NM = arm-none-eabi-nm
|
|
HEX = $(OBJCOPY) -O $(FORMAT)
|
|
EEP =
|
|
BIN = $(OBJCOPY) -O binary
|
|
|
|
COMMON_VPATH += $(DRIVER_PATH)/chibios
|
|
|
|
THUMBFLAGS = -DTHUMB_PRESENT -mno-thumb-interwork -DTHUMB_NO_INTERWORKING -mthumb -DTHUMB
|
|
|
|
COMPILEFLAGS += -fomit-frame-pointer
|
|
COMPILEFLAGS += -falign-functions=16
|
|
COMPILEFLAGS += -ffunction-sections
|
|
COMPILEFLAGS += -fdata-sections
|
|
COMPILEFLAGS += -fno-common
|
|
COMPILEFLAGS += -fshort-wchar
|
|
COMPILEFLAGS += $(THUMBFLAGS)
|
|
|
|
# FPU options default (Cortex-M4 and Cortex-M7 single precision).
|
|
USE_FPU_OPT ?= -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant
|
|
|
|
# FPU-related options
|
|
USE_FPU ?= no
|
|
ifneq ($(USE_FPU),no)
|
|
COMPILEFLAGS += $(USE_FPU_OPT)
|
|
OPT_DEFS += -DCORTEX_USE_FPU=TRUE
|
|
else
|
|
OPT_DEFS += -DCORTEX_USE_FPU=FALSE
|
|
endif
|
|
|
|
CFLAGS += $(COMPILEFLAGS)
|
|
|
|
ASFLAGS += $(THUMBFLAGS)
|
|
|
|
CXXFLAGS += $(COMPILEFLAGS)
|
|
CXXFLAGS += -fno-rtti
|
|
|
|
LDFLAGS +=-Wl,--gc-sections
|
|
LDFLAGS +=-Wl,--no-wchar-size-warning
|
|
LDFLAGS += -mno-thumb-interwork -mthumb
|
|
LDSYMBOLS =,--defsym=__process_stack_size__=$(USE_PROCESS_STACKSIZE)
|
|
LDSYMBOLS :=$(LDSYMBOLS),--defsym=__main_stack_size__=$(USE_EXCEPTIONS_STACKSIZE)
|
|
LDFLAGS += -Wl,--script=$(LDSCRIPT)$(LDSYMBOLS)
|
|
|
|
OPT_DEFS += -DPROTOCOL_CHIBIOS
|
|
|
|
# Workaround to stop ChibiOS from complaining about new GCC -- it's been fixed for 7/8/9 already
|
|
OPT_DEFS += -DPORT_IGNORE_GCC_VERSION_CHECK=1
|
|
|
|
MCUFLAGS = -mcpu=$(MCU)
|
|
|
|
DEBUG = gdb
|
|
|
|
DFU_ARGS ?=
|
|
ifneq ("$(SERIAL)","")
|
|
DFU_ARGS += -S $(SERIAL)
|
|
endif
|
|
|
|
ST_LINK_ARGS ?=
|
|
ST_FLASH_ARGS ?=
|
|
|
|
# List any extra directories to look for libraries here.
|
|
EXTRALIBDIRS = $(RULESPATH)/ld
|
|
|
|
DFU_UTIL ?= dfu-util
|
|
ST_LINK_CLI ?= st-link_cli
|
|
ST_FLASH ?= st-flash
|
|
|
|
define EXEC_DFU_UTIL
|
|
until $(DFU_UTIL) -l | grep -q "Found DFU"; do\
|
|
printf "$(MSG_BOOTLOADER_NOT_FOUND)" ;\
|
|
sleep 5 ;\
|
|
done
|
|
$(DFU_UTIL) $(DFU_ARGS) -D $(BUILD_DIR)/$(TARGET).bin
|
|
endef
|
|
|
|
dfu-util: $(BUILD_DIR)/$(TARGET).bin cpfirmware sizeafter
|
|
$(call EXEC_DFU_UTIL)
|
|
|
|
# Legacy alias
|
|
dfu-util-wait: dfu-util
|
|
|
|
# TODO: Remove once ARM has a way to configure EECONFIG_HANDEDNESS
|
|
# within the emulated eeprom via dfu-util or another tool
|
|
ifneq (,$(filter $(MAKECMDGOALS),dfu-util-split-left))
|
|
OPT_DEFS += -DINIT_EE_HANDS_LEFT
|
|
endif
|
|
|
|
ifneq (,$(filter $(MAKECMDGOALS),dfu-util-split-right))
|
|
OPT_DEFS += -DINIT_EE_HANDS_RIGHT
|
|
endif
|
|
|
|
dfu-util-split-left: dfu-util
|
|
|
|
dfu-util-split-right: dfu-util
|
|
|
|
|
|
st-link-cli: $(BUILD_DIR)/$(TARGET).hex sizeafter
|
|
$(ST_LINK_CLI) $(ST_LINK_ARGS) -q -c SWD -p $(BUILD_DIR)/$(TARGET).hex -Rst
|
|
|
|
st-flash: $(BUILD_DIR)/$(TARGET).hex sizeafter
|
|
$(ST_FLASH) $(ST_FLASH_ARGS) --reset --format ihex write $(BUILD_DIR)/$(TARGET).hex
|
|
|
|
|
|
# Autodetect teensy loader
|
|
ifndef TEENSY_LOADER_CLI
|
|
ifneq (, $(shell which teensy-loader-cli 2>/dev/null))
|
|
TEENSY_LOADER_CLI ?= teensy-loader-cli
|
|
else
|
|
TEENSY_LOADER_CLI ?= teensy_loader_cli
|
|
endif
|
|
endif
|
|
|
|
define EXEC_TEENSY
|
|
$(TEENSY_LOADER_CLI) -mmcu=$(MCU_LDSCRIPT) -w -v $(BUILD_DIR)/$(TARGET).hex
|
|
endef
|
|
|
|
teensy: $(BUILD_DIR)/$(TARGET).hex cpfirmware sizeafter
|
|
$(call EXEC_TEENSY)
|
|
|
|
bin: $(BUILD_DIR)/$(TARGET).bin sizeafter
|
|
$(COPY) $(BUILD_DIR)/$(TARGET).bin $(TARGET).bin;
|
|
|
|
|
|
flash: $(BUILD_DIR)/$(TARGET).bin cpfirmware sizeafter
|
|
ifneq ($(strip $(PROGRAM_CMD)),)
|
|
$(PROGRAM_CMD)
|
|
else ifeq ($(strip $(BOOTLOADER)),kiibohd)
|
|
$(call EXEC_DFU_UTIL)
|
|
else ifeq ($(strip $(MCU_FAMILY)),KINETIS)
|
|
$(call EXEC_TEENSY)
|
|
else ifeq ($(strip $(MCU_FAMILY)),STM32)
|
|
$(call EXEC_DFU_UTIL)
|
|
else
|
|
$(PRINT_OK); $(SILENT) || printf "$(MSG_FLASH_BOOTLOADER)"
|
|
endif
|