-
Notifications
You must be signed in to change notification settings - Fork 548
/
Makefile
249 lines (193 loc) · 7.71 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
#
# Common Makefile for the PX4 bootloaders
#
#
# Paths to common dependencies
#
export BUILD_DIR_ROOT ?= build
export BL_BASE ?= $(wildcard .)
export LIBOPENCM3 ?= $(wildcard libopencm3)
export LIBKINETIS ?= $(wildcard lib/kinetis/NXP_Kinetis_Bootloader_2_0_0)
MKFLAGS=--no-print-directory
SRC_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
COLOR_BLUE = \033[0;94m
NO_COLOR = \033[m
define colorecho
+@echo -e '${COLOR_BLUE}${1} ${NO_COLOR}'
endef
#
# Tools
#
export CC = arm-none-eabi-gcc
export OBJCOPY = arm-none-eabi-objcopy
#
# Common configuration
#
export FLAGS = -std=gnu99 \
-Os \
-g \
-Wundef \
-Wall \
-fno-builtin \
-I$(BL_BASE)/$(LIBOPENCM3)/include \
-I$(BL_BASE)/. \
-ffunction-sections \
-nostartfiles \
-lnosys \
-Wl,-gc-sections \
-Wl,-g \
-Werror
ifneq ($(CRYPTO_HAL),)
include crypto_hal/$(CRYPTO_HAL)/Makefile.include
endif
export COMMON_SRCS = bl.c $(CRYPTO_SRCS)
export ARCH_SRCS = cdcacm.c usart.c
#
# Bootloaders to build
# Note: px4fmuv3_bl is the same as px4fmuv2_bl except for a different USB device
# string
#
TARGETS = \
aerofcv1_bl \
auavx2v1_bl \
avx_v1_bl \
crazyflie21_bl \
crazyflie_bl \
cube_f4_bl \
fmuk66e_bl \
fmuk66v3_bl \
kakutef7_bl \
mindpxv2_bl \
modalai_fc_v1_bl \
modalai_voxl2_io_bl \
omnibusf4sd_bl \
pix32v5_bl \
px4aerocore_bl \
px4discovery_bl \
px4flow_bl \
px4fmu_bl \
px4fmuv2_bl \
px4fmuv3_bl \
px4fmuv4_bl \
px4fmuv4pro_bl \
px4fmuv5_bl \
px4fmuv5x_bl \
px4io_bl \
px4iov3_bl \
smartap_airlink_bl \
smartap_pro_bl \
tapv1_bl \
uvify_core_bl \
atl_mantis_edu_bl \
thepeach_k1_bl \
thepeach_r1_bl
all: $(TARGETS) sizes
clean:
cd libopencm3 && make --no-print-directory clean && cd ..
rm -f *.elf *.bin *.map # Remove any elf or bin files contained directly in the Bootloader directory
rm -rf build # Remove build directories
#
# Specific bootloader targets.
#
fmuk66v3_bl: $(MAKEFILE_LIST) $(LIBKINETIS)
${MAKE} ${MKFLAGS} -f Makefile.k66 TARGET_HW=FMUK66_V3 LINKER_FILE=kinetisk66.ld TARGET_FILE_NAME=$@
fmuk66e_bl: $(MAKEFILE_LIST) $(LIBKINETIS)
${MAKE} ${MKFLAGS} -f Makefile.k66 TARGET_HW=FMUK66_E LINKER_FILE=kinetisk66.ld TARGET_FILE_NAME=$@
auavx2v1_bl: $(MAKEFILE_LIST) $(LIBOPENCM3)
${MAKE} ${MKFLAGS} -f Makefile.f4 TARGET_HW=AUAV_X2V1 LINKER_FILE=stm32f4.ld TARGET_FILE_NAME=$@
kakutef7_bl: $(MAKEFILE_LIST) $(LIBOPENCM3)
${MAKE} ${MKFLAGS} -f Makefile.f7 TARGET_HW=KAKUTEF7 LINKER_FILE=stm32f7.ld TARGET_FILE_NAME=$@
pix32v5_bl:$(MAKEFILE_LIST) $(LIBOPENCM3)
${MAKE} ${MKFLAGS} -f Makefile.f7 TARGET_HW=HOLYBRO_PIX32_V5 LINKER_FILE=stm32f7.ld TARGET_FILE_NAME=$@
px4fmu_bl: $(MAKEFILE_LIST) $(LIBOPENCM3)
${MAKE} ${MKFLAGS} -f Makefile.f4 TARGET_HW=PX4_FMU_V1 LINKER_FILE=stm32f4.ld TARGET_FILE_NAME=$@
px4fmuv2_bl: $(MAKEFILE_LIST) $(LIBOPENCM3)
${MAKE} ${MKFLAGS} -f Makefile.f4 TARGET_HW=PX4_FMU_V2 LINKER_FILE=stm32f4.ld TARGET_FILE_NAME=$@
px4fmuv3_bl: $(MAKEFILE_LIST) $(LIBOPENCM3)
${MAKE} ${MKFLAGS} -f Makefile.f4 TARGET_HW=PX4_FMU_V3 LINKER_FILE=stm32f4.ld TARGET_FILE_NAME=$@
px4fmuv4_bl: $(MAKEFILE_LIST) $(LIBOPENCM3)
${MAKE} ${MKFLAGS} -f Makefile.f4 TARGET_HW=PX4_FMU_V4 LINKER_FILE=stm32f4.ld TARGET_FILE_NAME=$@
px4fmuv4pro_bl:$(MAKEFILE_LIST) $(LIBOPENCM3)
${MAKE} ${MKFLAGS} -f Makefile.f4 TARGET_HW=PX4_FMU_V4_PRO LINKER_FILE=stm32f4.ld TARGET_FILE_NAME=$@ EXTRAFLAGS=-DSTM32F469
px4fmuv5_bl:$(MAKEFILE_LIST) $(LIBOPENCM3)
${MAKE} ${MKFLAGS} -f Makefile.f7 TARGET_HW=PX4_FMU_V5 LINKER_FILE=stm32f7.ld TARGET_FILE_NAME=$@
px4fmuv5x_bl:$(MAKEFILE_LIST) $(LIBOPENCM3)
${MAKE} ${MKFLAGS} -f Makefile.f7 TARGET_HW=PX4_FMU_V5X LINKER_FILE=stm32f7.ld TARGET_FILE_NAME=$@
mindpxv2_bl: $(MAKEFILE_LIST) $(LIBOPENCM3)
${MAKE} ${MKFLAGS} -f Makefile.f4 TARGET_HW=MINDPX_V2 LINKER_FILE=stm32f4.ld TARGET_FILE_NAME=$@
px4discovery_bl: $(MAKEFILE_LIST) $(LIBOPENCM3)
${MAKE} ${MKFLAGS} -f Makefile.f4 TARGET_HW=PX4_DISCOVERY_V1 LINKER_FILE=stm32f4.ld TARGET_FILE_NAME=$@
px4flow_bl: $(MAKEFILE_LIST) $(LIBOPENCM3)
${MAKE} ${MKFLAGS} -f Makefile.f4 TARGET_HW=PX4_FLOW_V1 LINKER_FILE=stm32f4.ld TARGET_FILE_NAME=$@
px4aerocore_bl: $(MAKEFILE_LIST) $(LIBOPENCM3)
${MAKE} ${MKFLAGS} -f Makefile.f4 TARGET_HW=PX4_AEROCORE_V1 LINKER_FILE=stm32f4.ld TARGET_FILE_NAME=$@
crazyflie_bl: $(MAKEFILE_LIST) $(LIBOPENCM3)
${MAKE} ${MKFLAGS} -f Makefile.f4 TARGET_HW=CRAZYFLIE LINKER_FILE=stm32f4.ld TARGET_FILE_NAME=$@
crazyflie21_bl: $(MAKEFILE_LIST) $(LIBOPENCM3)
${MAKE} ${MKFLAGS} -f Makefile.f4 TARGET_HW=CRAZYFLIE21 LINKER_FILE=stm32f4.ld TARGET_FILE_NAME=$@
omnibusf4sd_bl: $(MAKEFILE_LIST) $(LIBOPENCM3)
${MAKE} ${MKFLAGS} -f Makefile.f4 TARGET_HW=OMNIBUSF4SD LINKER_FILE=stm32f4.ld TARGET_FILE_NAME=$@
cube_f4_bl: $(MAKEFILE_LIST) $(LIBOPENCM3)
${MAKE} ${MKFLAGS} -f Makefile.f4 TARGET_HW=CUBE_F4 LINKER_FILE=stm32f4.ld TARGET_FILE_NAME=$@
cube_f7_bl:$(MAKEFILE_LIST) $(LIBOPENCM3)
${MAKE} ${MKFLAGS} -f Makefile.f7 TARGET_HW=CUBE_F7 LINKER_FILE=stm32f7.ld TARGET_FILE_NAME=$@
avx_v1_bl:$(MAKEFILE_LIST) $(LIBOPENCM3)
${MAKE} ${MKFLAGS} -f Makefile.f7 TARGET_HW=AV_X_V1 LINKER_FILE=stm32f7.ld TARGET_FILE_NAME=$@
smartap_airlink_bl:$(MAKEFILE_LIST) $(LIBOPENCM3)
${MAKE} ${MKFLAGS} -f Makefile.f7 TARGET_HW=SMARTAP_AIRLINK LINKER_FILE=stm32f7.ld TARGET_FILE_NAME=$@
smartap_pro_bl:$(MAKEFILE_LIST) $(LIBOPENCM3)
${MAKE} ${MKFLAGS} -f Makefile.f7 TARGET_HW=SMARTAP_PRO LINKER_FILE=stm32f7.ld TARGET_FILE_NAME=$@
modalai_fc_v1_bl:$(MAKEFILE_LIST) $(LIBOPENCM3)
${MAKE} ${MKFLAGS} -f Makefile.f7 TARGET_HW=MODALAI_FC_V1 LINKER_FILE=stm32f7.ld TARGET_FILE_NAME=$@
modalai_voxl2_io_bl: $(MAKEFILE_LIST) $(LIBOPENCM3)
${MAKE} ${MKFLAGS} -f Makefile.f1 TARGET_HW=MODALAI_VOXL2_IO LINKER_FILE=stm32f1.ld TARGET_FILE_NAME=$@
uvify_core_bl:$(MAKEFILE_LIST) $(LIBOPENCM3)
${MAKE} ${MKFLAGS} -f Makefile.f4 TARGET_HW=UVIFY_CORE LINKER_FILE=stm32f4.ld TARGET_FILE_NAME=$@
thepeach_k1_bl: $(MAKEFILE_LIST) $(LIBOPENCM3)
${MAKE} ${MKFLAGS} -f Makefile.f4 TARGET_HW=THE_PEACH_K1 LINKER_FILE=stm32f4.ld TARGET_FILE_NAME=$@
thepeach_r1_bl: $(MAKEFILE_LIST) $(LIBOPENCM3)
${MAKE} ${MKFLAGS} -f Makefile.f4 TARGET_HW=THE_PEACH_R1 LINKER_FILE=stm32f4.ld TARGET_FILE_NAME=$@
# Default bootloader delay is *very* short, just long enough to catch
# the board for recovery but not so long as to make restarting after a
# brownout problematic.
#
px4io_bl: $(MAKEFILE_LIST) $(LIBOPENCM3)
${MAKE} ${MKFLAGS} -f Makefile.f1 TARGET_HW=PX4_PIO_V1 LINKER_FILE=stm32f1.ld TARGET_FILE_NAME=$@
px4iov3_bl: $(MAKEFILE_LIST) $(LIBOPENCM3)
${MAKE} ${MKFLAGS} -f Makefile.f3 TARGET_HW=PX4_PIO_V3 LINKER_FILE=stm32f3.ld TARGET_FILE_NAME=$@
tapv1_bl: $(MAKEFILE_LIST) $(LIBOPENCM3)
${MAKE} ${MKFLAGS} -f Makefile.f4 TARGET_HW=TAP_V1 LINKER_FILE=stm32f4.ld TARGET_FILE_NAME=$@
aerofcv1_bl: $(MAKEFILE_LIST) $(LIBOPENCM3)
${MAKE} ${MKFLAGS} -f Makefile.f4 TARGET_HW=AEROFC_V1 LINKER_FILE=stm32f4.ld TARGET_FILE_NAME=$@
atl_mantis_edu_bl: $(MAKEFILE_LIST) $(LIBOPENCM3)
${MAKE} ${MKFLAGS} -f Makefile.f7 TARGET_HW=ATL_MANTIS_EDU LINKER_FILE=stm32f7.ld TARGET_FILE_NAME=$@
#
# Show sizes
#
.PHONY: sizes
sizes:
@-find build/*/ -name '*.elf' -type f | xargs size 2> /dev/null || :
#
# Binary management
#
.PHONY: deploy
deploy:
zip -j Bootloader.zip build/*/*.bin
#
# Submodule management
#
$(LIBOPENCM3): checksubmodules
${MAKE} -C $(LIBOPENCM3) lib
.PHONY: checksubmodules
checksubmodules:
$(Q) ($(BL_BASE)/Tools/check_submodules.sh)
# Astyle
# --------------------------------------------------------------------
.PHONY: check_format format
check_format:
$(call colorecho,'Checking formatting with astyle')
@$(SRC_DIR)/Tools/check_code_style_all.sh
@cd $(SRC_DIR) && git diff --check
format:
$(call colorecho,'Formatting with astyle')
@$(SRC_DIR)/Tools/check_code_style_all.sh --fix