Skip to content

Commit c286d8c

Browse files
committed
Merge pull request #10 from fredizzimo/chibios-contrib2
Add support for new version of ChibiOS and Contrib
2 parents afef9b4 + 062d74e commit c286d8c

File tree

2 files changed

+41
-9
lines changed

2 files changed

+41
-9
lines changed

protocol/chibios/README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
### Notes
44

5-
- To use, unpack or symlink [ChibiOS] {currently 3.0.2} to `tmk_core/tool/chibios/chibios`. For Kinetis support, you'll need a fork which implements the USB driver, e.g. [this one](https://github.com/flabbergast/ChibiOS/tree/kinetis).
5+
- To use, unpack, symlink or add a submodule of [ChibiOS] {currently 3.0.2} to `tmk_core/tool/chibios/chibios`. For Kinetis support, you'll need a fork which implements the USB driver, e.g. [this one](https://github.com/flabbergast/ChibiOS/tree/kinetis).
66
- For gcc options, inspect `tmk_core/tool/chibios/chibios.mk`. For instance, I enabled `-Wno-missing-field-initializers`, because TMK common bits generated a lot of warnings on that.
77
Also pay attention to `-O0` (enabled for debugging); for deployment use `-O2`.
88
- USB string descriptors are messy. I did not find a way to cleanly generate the right structures from actual strings, so the definitions in individual keyboards' `config.h` are ugly as heck.
@@ -11,6 +11,12 @@ Also pay attention to `-O0` (enabled for debugging); for deployment use `-O2`.
1111
- Jumping to (the built-in) bootloaders on STM32 works, but it is not entirely pleasant, since it is very much MCU dependent. So, one needs to dig out the right address to jump to, and either pass it to the compiler in the `Makefile`, or better, define it in `<your_kb>/bootloader_defs.h`. Also, a patch to upstream ChibiOS is needed (supplied), because it `ResetHandler` needs adjusting.
1212
- Sleep LED works, but at the moment only on/off, i.e. no breathing.
1313

14+
### Experimental pre-ChibiOS 4 support
15+
- As an alternative to the mentioned flabbergast branch above, you can use the [master branch of ChibiOS](https://github.com/ChibiOS/ChibiOS).
16+
- Note that the Kinetis support has moved to the [ChibiOS-Contrib repository](https://github.com/ChibiOS/ChibiOS-Contrib), so you need to put that into your repository in the same way as you did for the main ChibiOS repository.
17+
- You also need to define CHIBIOS_CONTRIB in your makefile and point it to the right directory.
18+
- You need to add some new options to chconf.h, or you will get compiler errors. Just copy the new options from samples provided by the ChibiOS-Contrib repository.
19+
1420
### Immediate todo
1521

1622
- host-wakeup packet sending during suspend

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)