aboutsummaryrefslogtreecommitdiff
path: root/builddefs/bootloader.mk
diff options
context:
space:
mode:
Diffstat (limited to 'builddefs/bootloader.mk')
-rw-r--r--builddefs/bootloader.mk163
1 files changed, 163 insertions, 0 deletions
diff --git a/builddefs/bootloader.mk b/builddefs/bootloader.mk
new file mode 100644
index 000000000..ccb92392d
--- /dev/null
+++ b/builddefs/bootloader.mk
@@ -0,0 +1,163 @@
1# Copyright 2017 Jack Humbert
2#
3# This program is free software: you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation, either version 2 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program. If not, see <http://www.gnu.org/licenses/>.
15
16# If it's possible that multiple bootloaders can be used for one project,
17# you can leave this unset, and the correct size will be selected
18# automatically.
19#
20# Sets the bootloader defined in the keyboard's/keymap's rules.mk
21# Current options:
22#
23# AVR:
24# halfkay PJRC Teensy
25# caterina Pro Micro (Sparkfun/generic)
26# atmel-dfu Atmel factory DFU
27# lufa-dfu LUFA DFU
28# qmk-dfu QMK DFU (LUFA + blinkenlight)
29# qmk-hid QMK HID (LUFA + blinkenlight)
30# bootloadhid HIDBootFlash compatible (ATmega32A)
31# usbasploader USBaspLoader (ATmega328P)
32# ARM:
33# kiibohd Input:Club Kiibohd bootloader (only used on their boards)
34# stm32duino STM32Duino (STM32F103x8)
35# stm32-dfu STM32 USB DFU in ROM
36# apm32-dfu APM32 USB DFU in ROM
37# RISC-V:
38# gd32v-dfu GD32V USB DFU in ROM
39#
40# BOOTLOADER_SIZE can still be defined manually, but it's recommended
41# you add any possible configuration to this list
42
43ifeq ($(strip $(BOOTLOADER)), atmel-dfu)
44 OPT_DEFS += -DBOOTLOADER_ATMEL_DFU
45 OPT_DEFS += -DBOOTLOADER_DFU
46 ifneq (,$(filter $(MCU), at90usb162 atmega16u2 atmega32u2 atmega16u4 atmega32u4 at90usb646 at90usb647))
47 BOOTLOADER_SIZE = 4096
48 endif
49 ifneq (,$(filter $(MCU), at90usb1286 at90usb1287))
50 BOOTLOADER_SIZE = 8192
51 endif
52endif
53ifeq ($(strip $(BOOTLOADER)), lufa-dfu)
54 OPT_DEFS += -DBOOTLOADER_LUFA_DFU
55 OPT_DEFS += -DBOOTLOADER_DFU
56 ifneq (,$(filter $(MCU), at90usb162 atmega16u2 atmega32u2 atmega16u4 atmega32u4 at90usb646 at90usb647))
57 BOOTLOADER_SIZE ?= 4096
58 endif
59 ifneq (,$(filter $(MCU), at90usb1286 at90usb1287))
60 BOOTLOADER_SIZE ?= 8192
61 endif
62endif
63ifeq ($(strip $(BOOTLOADER)), qmk-dfu)
64 OPT_DEFS += -DBOOTLOADER_QMK_DFU
65 OPT_DEFS += -DBOOTLOADER_DFU
66 ifneq (,$(filter $(MCU), at90usb162 atmega16u2 atmega32u2 atmega16u4 atmega32u4 at90usb646 at90usb647))
67 BOOTLOADER_SIZE ?= 4096
68 endif
69 ifneq (,$(filter $(MCU), at90usb1286 at90usb1287))
70 BOOTLOADER_SIZE ?= 8192
71 endif
72endif
73ifeq ($(strip $(BOOTLOADER)), qmk-hid)
74 OPT_DEFS += -DBOOTLOADER_QMK_HID
75 OPT_DEFS += -DBOOTLOADER_HID
76 BOOTLOADER_SIZE ?= 4096
77endif
78ifeq ($(strip $(BOOTLOADER)), halfkay)
79 OPT_DEFS += -DBOOTLOADER_HALFKAY
80 ifeq ($(strip $(MCU)), atmega32u4)
81 BOOTLOADER_SIZE = 512
82 endif
83 ifeq ($(strip $(MCU)), at90usb1286)
84 BOOTLOADER_SIZE = 1024
85 endif
86endif
87ifeq ($(strip $(BOOTLOADER)), caterina)
88 OPT_DEFS += -DBOOTLOADER_CATERINA
89 BOOTLOADER_SIZE = 4096
90endif
91ifneq (,$(filter $(BOOTLOADER), bootloadhid bootloadHID))
92 OPT_DEFS += -DBOOTLOADER_BOOTLOADHID
93 BOOTLOADER_SIZE = 4096
94endif
95ifneq (,$(filter $(BOOTLOADER), usbasploader USBasp))
96 OPT_DEFS += -DBOOTLOADER_USBASP
97 BOOTLOADER_SIZE = 4096
98endif
99ifeq ($(strip $(BOOTLOADER)), lufa-ms)
100 OPT_DEFS += -DBOOTLOADER_MS
101 BOOTLOADER_SIZE ?= 8192
102 FIRMWARE_FORMAT = bin
103cpfirmware: lufa_warning
104.INTERMEDIATE: lufa_warning
105lufa_warning: $(FIRMWARE_FORMAT)
106 $(info @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@)
107 $(info LUFA MASS STORAGE Bootloader selected)
108 $(info DO NOT USE THIS BOOTLOADER IN NEW PROJECTS!)
109 $(info It is extremely prone to bricking, and is only included to support existing boards.)
110 $(info @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@)
111endif
112ifdef BOOTLOADER_SIZE
113 OPT_DEFS += -DBOOTLOADER_SIZE=$(strip $(BOOTLOADER_SIZE))
114endif
115
116ifeq ($(strip $(BOOTLOADER)), stm32-dfu)
117 OPT_DEFS += -DBOOTLOADER_STM32_DFU
118
119 # Options to pass to dfu-util when flashing
120 DFU_ARGS ?= -d 0483:DF11 -a 0 -s 0x08000000:leave
121 DFU_SUFFIX_ARGS ?= -v 0483 -p DF11
122endif
123ifeq ($(strip $(BOOTLOADER)), apm32-dfu)
124 OPT_DEFS += -DBOOTLOADER_APM32_DFU
125
126 # Options to pass to dfu-util when flashing
127 DFU_ARGS ?= -d 314B:0106 -a 0 -s 0x08000000:leave
128 DFU_SUFFIX_ARGS ?= -v 314B -p 0106
129endif
130ifeq ($(strip $(BOOTLOADER)), gd32v-dfu)
131 OPT_DEFS += -DBOOTLOADER_GD32V_DFU
132
133 # Options to pass to dfu-util when flashing
134 DFU_ARGS ?= -d 28E9:0189 -a 0 -s 0x08000000:leave
135 DFU_SUFFIX_ARGS ?= -v 28E9 -p 0189
136endif
137ifeq ($(strip $(BOOTLOADER)), kiibohd)
138 OPT_DEFS += -DBOOTLOADER_KIIBOHD
139 ifeq ($(strip $(MCU_ORIG)), MK20DX128)
140 MCU_LDSCRIPT = MK20DX128BLDR4
141 endif
142 ifeq ($(strip $(MCU_ORIG)), MK20DX256)
143 MCU_LDSCRIPT = MK20DX256BLDR8
144 endif
145
146 # Options to pass to dfu-util when flashing
147 DFU_ARGS = -d 1C11:B007
148 DFU_SUFFIX_ARGS = -v 1C11 -p B007
149endif
150ifeq ($(strip $(BOOTLOADER)), stm32duino)
151 OPT_DEFS += -DBOOTLOADER_STM32DUINO
152 MCU_LDSCRIPT = STM32F103x8_stm32duino_bootloader
153 BOARD = STM32_F103_STM32DUINO
154 # STM32F103 does NOT have an USB bootloader in ROM (only serial), so setting anything here does not make much sense
155 STM32_BOOTLOADER_ADDRESS = 0x80000000
156
157 # Options to pass to dfu-util when flashing
158 DFU_ARGS = -d 1EAF:0003 -a 2 -R
159 DFU_SUFFIX_ARGS = -v 1EAF -p 0003
160endif
161ifeq ($(strip $(BOOTLOADER)), tinyuf2)
162 OPT_DEFS += -DBOOTLOADER_TINYUF2
163endif