forked from thomask77/drquad32
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
340 lines (273 loc) · 8.1 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
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
# Optimization level, can be [0, 1, 2, 3, s].
# 0 = turn off optimization. s = optimize for size.
#
OPT = -O2 -flto
# OPT = -O1 # for debugging
BOARD ?= REV_A
# Object files directory
# Warning: this will be removed by make clean!
#
OBJDIR = obj_app
# Target file name (without extension)
TARGET = $(OBJDIR)/drquad
# Define all C source files (dependencies are generated automatically)
#
INCDIRS += .
INCDIRS += Source
SOURCES += Source/main.c
SOURCES += Source/gpn_foo.c
SOURCES += Source/flight_ctrl.c
SOURCES += Source/bldc_driver.c
SOURCES += Source/bldc_task.c
SOURCES += Source/i2c_driver.c
SOURCES += Source/i2c_mpu9150.c
SOURCES += Source/i2c_ak8975.c
SOURCES += Source/i2c_bmp180.c
SOURCES += Source/sensors.c
SOURCES += Source/debug_dac.c
SOURCES += Source/dma_io_driver.c
SOURCES += Source/dma_io_ws2812.c
SOURCES += Source/dma_io_servo_in.c
SOURCES += Source/dma_io_servo_out.c
SOURCES += Source/rc_input.c
SOURCES += Source/rc_ppm.c
SOURCES += Source/rc_sbus.c
SOURCES += Source/rc_dsm2.c
SOURCES += Source/tetris.c
SOURCES += Source/board.c
SOURCES += Source/syscalls.c
SOURCES += Source/ustime.c
SOURCES += Source/term_xbee.c
SOURCES += Source/term_usb.c
SOURCES += Source/attitude.c
SOURCES += Source/command.c
SOURCES += Source/fault_handler.c
SOURCES += Source/led_task.c
SOURCES += Source/param_table.c
SOURCES += Source/parameter.c
SOURCES += Source/readline.c
SOURCES += Source/shell_task.c
SOURCES += Source/util.c
SOURCES += Source/filter.c
SOURCES += Source/watchdog.c
SOURCES += Source/version.c
SOURCES += Shared/cobsr.c
SOURCES += Shared/errors.c
SOURCES += Shared/crc16.c
SOURCES += Shared/crc32.c
# FatFS
#
FATFS_DIR = Libraries/FatFs-0.10c/src
INCDIRS += $(FATFS_DIR)
SOURCES += $(FATFS_DIR)/ff.c
# FreeRTOS
#
FREERTOS_BASE = Libraries/FreeRTOSV8.1.2
FREERTOS_DIR = $(FREERTOS_BASE)/FreeRTOS/Source
INCDIRS += $(FREERTOS_DIR)/include
INCDIRS += $(FREERTOS_DIR)/portable/GCC/ARM_CM4F
SOURCES += $(FREERTOS_DIR)/tasks.c
SOURCES += $(FREERTOS_DIR)/queue.c
SOURCES += $(FREERTOS_DIR)/list.c
SOURCES += $(FREERTOS_DIR)/croutine.c
SOURCES += $(FREERTOS_DIR)/portable/GCC/ARM_CM4F/port.c
# Tracealyzer
#
TRACE_DIR = $(FREERTOS_BASE)/FreeRTOS-Plus/Source/FreeRTOS-Plus-Trace
INCDIRS += $(TRACE_DIR)/Include
SOURCES += $(TRACE_DIR)/trcBase.c
SOURCES += $(TRACE_DIR)/trcKernel.c
SOURCES += $(TRACE_DIR)/trcUser.c
SOURCES += $(TRACE_DIR)/trcHardwarePort.c
SOURCES += $(TRACE_DIR)/trcKernelPort.c
# USB library stuff
#
USB_VCP_DIR = Libraries/STM32_USB_Device_VCP-1.1.0
INCDIRS += $(USB_VCP_DIR)/inc
SOURCES += $(USB_VCP_DIR)/src/usbd_desc.c
SOURCES += $(USB_VCP_DIR)/src/usbd_usr.c
USB_DEVICE_DIR = Libraries/STM32_USB_Device_Library-1.1.0
INCDIRS += $(USB_DEVICE_DIR)/Class/cdc/inc
SOURCES += $(USB_DEVICE_DIR)/Class/cdc/src/usbd_cdc_core.c
INCDIRS += $(USB_DEVICE_DIR)/Core/inc
SOURCES += $(USB_DEVICE_DIR)/Core/src/usbd_core.c
SOURCES += $(USB_DEVICE_DIR)/Core/src/usbd_ioreq.c
SOURCES += $(USB_DEVICE_DIR)/Core/src/usbd_req.c
USB_DRIVER_DIR = Libraries/STM32_USB_OTG_Driver-2.1.0
INCDIRS += $(USB_DRIVER_DIR)/inc
SOURCES += $(USB_DRIVER_DIR)/src/usb_core.c
SOURCES += $(USB_DRIVER_DIR)/src/usb_dcd.c
SOURCES += $(USB_DRIVER_DIR)/src/usb_dcd_int.c
# Standard peripheral library
#
CPPFLAGS += -DUSE_STDPERIPH_DRIVER
CPPFLAGS += -DUSE_FULL_ASSERT
STDPERIPH_DIR = Libraries/STM32F4xx_StdPeriph_Driver-1.4.0
INCDIRS += $(STDPERIPH_DIR)/inc
SOURCES += $(STDPERIPH_DIR)/src/misc.c
SOURCES += $(STDPERIPH_DIR)/src/stm32f4xx_spi.c
SOURCES += $(STDPERIPH_DIR)/src/stm32f4xx_i2c.c
SOURCES += $(STDPERIPH_DIR)/src/stm32f4xx_dma.c
SOURCES += $(STDPERIPH_DIR)/src/stm32f4xx_adc.c
SOURCES += $(STDPERIPH_DIR)/src/stm32f4xx_dac.c
SOURCES += $(STDPERIPH_DIR)/src/stm32f4xx_exti.c
SOURCES += $(STDPERIPH_DIR)/src/stm32f4xx_iwdg.c
SOURCES += $(STDPERIPH_DIR)/src/stm32f4xx_rcc.c
SOURCES += $(STDPERIPH_DIR)/src/stm32f4xx_usart.c
SOURCES += $(STDPERIPH_DIR)/src/stm32f4xx_gpio.c
SOURCES += $(STDPERIPH_DIR)/src/stm32f4xx_flash.c
SOURCES += $(STDPERIPH_DIR)/src/stm32f4xx_tim.c
# CMSIS-Library
#
CMSIS_DIR = Libraries/CMSIS-3.2.0
INCDIRS += $(CMSIS_DIR)/Include
INCDIRS += $(CMSIS_DIR)/Device/ST/STM32F4xx/Include
SOURCES += $(CMSIS_DIR)/Device/ST/STM32F4xx/Source/startup_stm32f40_41xxx.s
# Board support
#
ifeq ($(BOARD), DISCOVERY)
CPPFLAGS += -DBOARD_DISCOVERY
CPPFLAGS += -DHSE_VALUE=8000000
SOURCES += $(CMSIS_DIR)/Device/ST/STM32F4xx/Source/system_stm32f4xx_8_168.c
else
ifeq ($(BOARD), OLIMEX)
CPPFLAGS += -DBOARD_REV_A
CPPFLAGS += -DHSE_VALUE=12000000
SOURCES += $(CMSIS_DIR)/Device/ST/STM32F4xx/Source/system_stm32f4xx_12_168.c
else
ifeq ($(BOARD), REV_A)
CPPFLAGS += -DBOARD_REV_A
CPPFLAGS += -DHSE_VALUE=16000000
SOURCES += $(CMSIS_DIR)/Device/ST/STM32F4xx/Source/system_stm32f4xx_16_168.c
else
$(error Unknown BOARD type: must be DISCOVERY or REV_A)
endif
endif
endif
CPPFLAGS += -DSTM32F40_41xxx
LDSCRIPT = Source/stm32f4xx_app.ld
#============================================================================
#
OBJECTS += $(addprefix $(OBJDIR)/,$(addsuffix .o,$(basename $(SOURCES))))
CPPFLAGS += $(addprefix -I,$(INCDIRS))
#---------------- Preprocessor Options ----------------
# -fsingle... make better use of the single-precision FPU
# -g generate debugging information
# -save-temps preserve .s and .i-files
#
CPPFLAGS += -fsingle-precision-constant
CPPFLAGS += -g
# CPPFLAGS += -save-temps=obj
#---------------- C Compiler Options ----------------
# -O* optimization level
# -f... tuning, see GCC documentation
# -Wall... warning level
#
CFLAGS += $(OPT)
CFLAGS += -std=gnu11
CFLAGS += -ffunction-sections
CFLAGS += -fdata-sections
CFLAGS += -Wall
CFLAGS += -Wstrict-prototypes
CFLAGS += -Wsign-compare
#CFLAGS += -Wextra
#CFLAGS += -Wpointer-arith
#CFLAGS += -Winline
#CFLAGS += -Wunreachable-code
#CFLAGS += -Wundef
# Use a friendly C dialect
CPPFLAGS += -fno-strict-aliasing
CPPFLAGS += -fwrapv
#---------------- C++ Compiler Options ----------------
#
CXXFLAGS += $(OPT)
CXXFLAGS += -ffunction-sections
CXXFLAGS += -fdata-sections
CXXFLAGS += -Wall
#---------------- Assembler Options ----------------
# -Wa,... tell GCC to pass this to the assembler
#
#---------------- Linker Options ----------------
# -Wl,... tell GCC to pass this to linker
# -Map create map file
# --cref add cross reference to map file
#
LDFLAGS += $(OPT)
LDFLAGS += -lm
LDFLAGS += -Wl,-Map=$(TARGET).map,--cref
LDFLAGS += -Wl,--gc-sections
# LDFLAGS += -specs=nano.specs -u _printf_float -u _scanf_float
LDFLAGS += -T$(LDSCRIPT)
#============================================================================
# Define programs and commands
#
TOOLCHAIN = arm-none-eabi-
CC = $(TOOLCHAIN)gcc
OBJCOPY = $(TOOLCHAIN)objcopy
OBJDUMP = $(TOOLCHAIN)objdump
SIZE = $(TOOLCHAIN)size
NM = $(TOOLCHAIN)nm
MKDIR = mkdir
DOXYGEN = doxygen
STLINK = Tools/st-link/ST-LINK_CLI.exe
POSTLD = Tools/add_version_info.py # -q
# Compiler flags to generate dependency files
#
GENDEPFLAGS = -MMD -MP
# Combine all necessary flags and optional flags
# Add target processor to flags.
#
CPU = -mthumb -mcpu=cortex-m4 -mfloat-abi=hard -mfpu=fpv4-sp-d16
CFLAGS += $(CPU)
CXXFLAGS += $(CPU)
ASFLAGS += $(CPU)
LDFLAGS += $(CPU)
# Default target
#
all: gccversion build showsize
build: elf hex bin lss sym
elf: $(TARGET).elf
hex: $(TARGET).hex
bin: $(TARGET).bin
lss: $(TARGET).lss
sym: $(TARGET).sym
doxygen:
@echo
@echo Creating Doxygen documentation
@$(DOXYGEN)
boot:
$(MAKE) -f Bootloader/Makefile
boot_clean:
$(MAKE) -f Bootloader/Makefile clean
boot_flash:
$(MAKE) -f Bootloader/Makefile flash
# Display compiler version information
#
gccversion:
@$(CC) --version
# Show the final program size
#
showsize: build
@echo
@$(SIZE) $(TARGET).elf 2>/dev/null
# Flash the device
#
flash: build showsize
$(STLINK) -c SWD -P $(TARGET).hex -Run
# Target: clean project
#
clean:
@echo Cleaning project:
rm -rf $(OBJDIR)
# Include the base rules
#
include base.mak
# Include the dependency files
#
-include $(OBJECTS:.o=.d)
# Listing of phony targets
#
.PHONY: all build flash clean \
boot boot_clean boot_flash \
doxygen elf lss sym \
showsize gccversion