Skip to content

Commit d47150f

Browse files
committed
Add support for new version of ChibiOS and Contrib
The Kinetis support has moved to a separate Contrib repository in the newest version of Chibios. There has also been some structure changes. So this adds support for those, while maintaining back- wards compability.
1 parent afef9b4 commit d47150f

File tree

1 file changed

+34
-8
lines changed

1 file changed

+34
-8
lines changed

tool/chibios/chibios.mk

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,20 +84,43 @@ endif
8484

8585
# Imported source files and paths
8686
CHIBIOS ?= $(TMK_DIR)/tool/chibios/chibios
87-
# Startup files.
88-
include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/startup_$(MCU_STARTUP).mk
87+
# Startup files. Try a few different locations, for compability with old versions and
88+
# for things hardware in the contrib repository
89+
STARTUP_MK = $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/startup_$(MCU_STARTUP).mk
90+
ifeq ("$(wildcard $(STARTUP_MK))","")
91+
STARTUP_MK = $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/mk/startup_$(MCU_STARTUP).mk
92+
ifeq ("$(wildcard $(STARTUP_MK))","")
93+
STARTUP_MK = $(CHIBIOS_CONTRIB)/os/common/startup/ARMCMx/compilers/GCC/mk/startup_$(MCU_STARTUP).mk
94+
endif
95+
endif
96+
include $(STARTUP_MK)
8997
# HAL-OSAL files (optional).
9098
include $(CHIBIOS)/os/hal/hal.mk
91-
include $(CHIBIOS)/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)/platform.mk
92-
ifneq ("$(wildcard $(TARGET_DIR)/boards/$(BOARD))","")
93-
include $(TARGET_DIR)/boards/$(BOARD)/board.mk
94-
else
95-
include $(CHIBIOS)/os/hal/boards/$(BOARD)/board.mk
99+
100+
PLATFORM_MK = $(CHIBIOS)/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)/platform.mk
101+
ifeq ("$(wildcard $(PLATFORM_MK))","")
102+
PLATFORM_MK = $(CHIBIOS_CONTRIB)/os/hal/ports/$(MCU_FAMILY)/$(MCU_SERIES)/platform.mk
103+
endif
104+
include $(PLATFORM_MK)
105+
106+
107+
BOARD_MK = $(TARGET_DIR)/boards/$(BOARD)
108+
ifeq ("$(wildcard $(BOARD_MK))","")
109+
BOARD_MK = $(CHIBIOS)/os/hal/boards/$(BOARD)/board.mk
110+
ifeq ("$(wildcard $(BOARD_MK))","")
111+
BOARD_MK = $(CHIBIOS_CONTRIB)/os/hal/boards/$(BOARD)/board.mk
112+
endif
96113
endif
114+
include $(BOARD_MK)
97115
include $(CHIBIOS)/os/hal/osal/rt/osal.mk
98116
# RTOS files (optional).
99117
include $(CHIBIOS)/os/rt/rt.mk
100-
include $(CHIBIOS)/os/rt/ports/ARMCMx/compilers/GCC/mk/port_v$(ARMV)m.mk
118+
# Compability with old version
119+
PORT_V = $(CHIBIOS)/os/rt/ports/ARMCMx/compilers/GCC/mk/port_v$(ARMV)m.mk
120+
ifeq ("$(wildcard $(PORT_V))","")
121+
PORT_V = $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v$(ARMV)m.mk
122+
endif
123+
include $(PORT_V)
101124
# Other files (optional).
102125

103126
# Define linker script file here
@@ -228,4 +251,7 @@ endif
228251
##############################################################################
229252

230253
RULESPATH = $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC
254+
ifeq ("$(wildcard $(RULESPATH)/rules.mk)","")
255+
RULESPATH = $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC
256+
endif
231257
include $(RULESPATH)/rules.mk

0 commit comments

Comments
 (0)