summaryrefslogtreecommitdiff
path: root/tmk_core/chibios.mk
diff options
context:
space:
mode:
Diffstat (limited to 'tmk_core/chibios.mk')
-rw-r--r--tmk_core/chibios.mk122
1 files changed, 19 insertions, 103 deletions
diff --git a/tmk_core/chibios.mk b/tmk_core/chibios.mk
index 97299b7d32..7962516a0a 100644
--- a/tmk_core/chibios.mk
+++ b/tmk_core/chibios.mk
@@ -67,9 +67,9 @@ else ifneq ("$(wildcard $(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
+else ifneq ("$(wildcard $(TOP_DIR)/platforms/chibios/boards/$(BOARD)/board/board.mk)","")
+ BOARD_PATH = $(TOP_DIR)/platforms/chibios/boards/$(BOARD)
+ BOARD_MK += $(TOP_DIR)/platforms/chibios/boards/$(BOARD)/board/board.mk
KEYBOARD_PATHS += $(BOARD_PATH)/configs
ifneq ("$(wildcard $(BOARD_PATH)/rules.mk)","")
include $(BOARD_PATH)/rules.mk
@@ -124,10 +124,10 @@ 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
+else ifneq ("$(wildcard $(TOP_DIR)/platforms/chibios/boards/$(BOARD)/configs/chconf.h)","")
+ CHCONFDIR = $(TOP_DIR)/platforms/chibios/boards/$(BOARD)/configs
+else ifneq ("$(wildcard $(TOP_DIR)/platforms/boards/chibios/common/configs/chconf.h)","")
+ CHCONFDIR = $(TOP_DIR)/platforms/chibios/boards/common/configs
endif
ifneq ("$(wildcard $(KEYBOARD_PATH_5)/halconf.h)","")
@@ -140,10 +140,10 @@ 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
+else ifneq ("$(wildcard $(TOP_DIR)/platforms/chibios/boards/$(BOARD)/configs/halconf.h)","")
+ HALCONFDIR = $(TOP_DIR)/platforms/chibios/boards/$(BOARD)/configs
+else ifneq ("$(wildcard $(TOP_DIR)/platforms/chibios/boards/common/configs/halconf.h)","")
+ HALCONFDIR = $(TOP_DIR)/platforms/chibios/boards/common/configs
endif
# HAL-OSAL files (optional).
@@ -190,10 +190,11 @@ 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/$(BOARD)/ld/$(MCU_LDSCRIPT).ld)","")
- LDSCRIPT = $(TOP_DIR)/platforms/chibios/$(BOARD)/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 $(TOP_DIR)/platforms/chibios/boards/$(BOARD)/ld/$(MCU_LDSCRIPT).ld)","")
+ LDFLAGS += -L$(TOP_DIR)/platforms/chibios/boards/$(BOARD)/ld
+ LDSCRIPT = $(TOP_DIR)/platforms/chibios/boards/$(BOARD)/ld/$(MCU_LDSCRIPT).ld
+else ifneq ("$(wildcard $(TOP_DIR)/platforms/chibios/boards/common/ld/$(MCU_LDSCRIPT).ld)","")
+ LDSCRIPT = $(TOP_DIR)/platforms/chibios/boards/common/ld/$(MCU_LDSCRIPT).ld
else ifneq ("$(wildcard $(STARTUPLD_CONTRIB)/$(MCU_LDSCRIPT).ld)","")
LDSCRIPT = $(STARTUPLD_CONTRIB)/$(MCU_LDSCRIPT).ld
USE_CHIBIOS_CONTRIB = yes
@@ -218,8 +219,8 @@ QUANTUM_LIB_SRC += $(STARTUPASM) $(PORTASM) $(OSALASM) $(PLATFORMASM)
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 \
+ $(TOP_DIR)/platforms/chibios/boards/$(BOARD)/configs \
+ $(TOP_DIR)/platforms/chibios/boards/common/configs \
$(HALCONFDIR) $(CHCONFDIR) \
$(STARTUPINC) $(KERNINC) $(PORTINC) $(OSALINC) \
$(HALINC) $(PLATFORMINC) $(BOARDINC) $(TESTINC) \
@@ -240,7 +241,7 @@ 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)","")
+else ifneq ("$(wildcard $(TOP_DIR)/platforms/chibios/boards/$(BOARD)/configs/halconf_community.h)","")
USE_CHIBIOS_CONTRIB = yes
endif
@@ -277,8 +278,6 @@ 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
@@ -325,91 +324,8 @@ 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
- if ! $(DFU_UTIL) -l | grep -q "Found DFU"; then \
- printf "$(MSG_BOOTLOADER_NOT_FOUND_QUICK_RETRY)" ;\
- sleep $(BOOTLOADER_RETRY_TIME) ;\
- while ! $(DFU_UTIL) -l | grep -q "Found DFU"; do \
- printf "." ;\
- sleep $(BOOTLOADER_RETRY_TIME) ;\
- done ;\
- printf "\n" ;\
- fi
- $(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