-
Notifications
You must be signed in to change notification settings - Fork 145
/
Makefile
394 lines (356 loc) · 13.3 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
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
TARGET = libdaisy
MODULE_DIR=src
C_MODULES = \
sys/dma \
hid/audio \
per/gpio \
per/sai \
per/sdmmc \
util/bsp_sd_diskio \
util/oled_fonts \
util/sd_diskio \
util/unique_id \
util/usbh_diskio \
sys/system_stm32h7xx \
usbd/usbd_cdc_if \
usbd/usbd_desc \
usbd/usbd_conf \
usbh/usbh_conf
CPP_MODULES = \
daisy_seed \
daisy_pod \
daisy_patch \
daisy_petal \
daisy_field \
daisy_versio \
daisy_legio \
daisy_patch_sm \
sys/fatfs \
sys/system \
dev/sr_595 \
dev/codec_ak4556 \
dev/codec_pcm3060 \
dev/codec_wm8731 \
dev/lcd_hd44780 \
dev/sdram \
hid/ctrl \
hid/encoder \
hid/gatein \
hid/led \
hid/midi \
hid/midi_parser \
hid/parameter \
hid/rgb_led \
hid/switch \
hid/usb \
hid/usb_midi \
hid/wavplayer \
hid/logger \
hid/usb_host \
per/adc \
per/dac \
per/gpio \
per/i2c \
per/rng \
per/qspi \
per/spi \
per/spiMultislave \
per/tim \
per/uart \
ui/UI \
ui/AbstractMenu \
ui/FullScreenItemMenu \
util/color \
util/MappedValue \
util/WaveTableLoader \
######################################
# building variables
######################################
DEBUG = 0
OPT = -O3
#######################################
# paths
#######################################
# Build path
BUILD_DIR = build
######################################
# source
######################################
# manually adding necessary HAL files
# generated by `find Drivers/STM32H7xx_HAL_Driver/**/*.c -print`
C_SOURCES =
C_SOURCES += \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_adc.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_adc_ex.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_cec.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_comp.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_cordic.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_cortex.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_crc.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_crc_ex.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_cryp.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_cryp_ex.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_dac.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_dac_ex.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_dcmi.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_dfsdm.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_dfsdm_ex.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_dma.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_dma_ex.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_dma2d.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_dsi.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_dts.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_eth.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_eth_ex.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_exti.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_fdcan.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_flash.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_flash_ex.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_fmac.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_gfxmmu.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_gpio.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_hash.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_hash_ex.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_hcd.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_hrtim.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_hsem.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2c.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2c_ex.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2s.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2s_ex.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_irda.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_iwdg.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_jpeg.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_lptim.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_ltdc.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_ltdc_ex.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_mdios.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_mdma.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_mmc.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_mmc_ex.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_nand.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_nor.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_opamp.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_opamp_ex.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_ospi.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_otfdec.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_pcd.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_pcd_ex.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_pssi.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_pwr.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_pwr_ex.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_qspi.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_ramecc.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_rcc.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_rcc_ex.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_rng.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_rng_ex.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_rtc.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_rtc_ex.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_sai.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_sai_ex.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_sd.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_sd_ex.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_sdram.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_smartcard.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_smartcard_ex.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_smbus.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_smbus_ex.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_spdifrx.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_spi.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_spi_ex.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_sram.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_swpmi.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_tim.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_tim_ex.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_uart.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_uart_ex.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_usart.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_usart_ex.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_wwdg.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_adc.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_bdma.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_comp.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_cordic.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_crc.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_crs.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_dac.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_delayblock.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_dma.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_dma2d.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_exti.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_fmac.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_fmc.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_gpio.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_hrtim.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_i2c.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_lptim.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_lpuart.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_mdma.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_opamp.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_pwr.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_rcc.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_rng.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_rtc.c \
Drivers/Patched/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_sdmmc.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_spi.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_swpmi.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_tim.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_usart.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_usb.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_ll_utils.c
# Middleware sources
C_SOURCES += \
Middlewares/Patched/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c \
Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_core.c \
Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ctlreq.c \
Middlewares/ST/STM32_USB_Device_Library/Core/Src/usbd_ioreq.c \
Middlewares/Third_Party/FatFs/src/diskio.c \
Middlewares/Third_Party/FatFs/src/ff.c \
Middlewares/Third_Party/FatFs/src/ff_gen_drv.c \
Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Src/usbh_msc_bot.c \
Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Src/usbh_msc_scsi.c \
Middlewares/ST/STM32_USB_Host_Library/Class/MSC/Src/usbh_msc.c \
Middlewares/ST/STM32_USB_Host_Library/Class/MIDI/Src/usbh_midi.c \
Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_core.c \
Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_ctlreq.c \
Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_ioreq.c \
Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_pipes.c
# C++ Source
CPP_SOURCES += $(addsuffix .cpp, $(addprefix $(MODULE_DIR)/, $(CPP_MODULES)))
# C sources
C_SOURCES += $(addsuffix .c, $(addprefix $(MODULE_DIR)/, $(C_MODULES)))
C_SOURCES += core/startup_stm32h750xx.c
#STARTUP_PATH = Drivers/CMSIS/Device/ST/STM32H7xx/Source/Templates/gcc
# ASM sources
#ASM_SOURCES = \
#$(STARTUP_PATH)/startup_stm32h750xx.s
#######################################
# binaries
#######################################
PREFIX = arm-none-eabi-
# The gcc compiler bin path can be either defined in make command via GCC_PATH variable (> make GCC_PATH=xxx)
# either it can be added to the PATH environment variable.
ifdef GCC_PATH
CC = $(GCC_PATH)/$(PREFIX)gcc
CXX = $(GCC_PATH)/$(PREFIX)g++
AS = $(GCC_PATH)/$(PREFIX)gcc -x assembler-with-cpp
CP = $(GCC_PATH)/$(PREFIX)objcopy
SZ = $(GCC_PATH)/$(PREFIX)size
AR = $(GCC_PATH)/$(PREFIX)ar
GDB = $(GCC_PATH)/$(PREFIX)gdb
else
CC = $(PREFIX)gcc
CXX = $(PREFIX)g++
AS = $(PREFIX)gcc -x assembler-with-cpp
CP = $(PREFIX)objcopy
SZ = $(PREFIX)size
AR = $(PREFIX)ar
GDB = $(PREFIX)gdb
endif
HEX = $(CP) -O ihex
BIN = $(CP) -O binary -S
#######################################
# CFLAGS
#######################################
# cpu
CPU = -mcpu=cortex-m7
# fpu
FPU = -mfpu=fpv5-d16
# float-abi
FLOAT-ABI = -mfloat-abi=hard
# mcu
MCU = -mthumb $(FLOAT-ABI) $(FPU) $(CPU)
# macros for gcc
# AS defines
AS_DEFS =
# C defines
C_DEFS = \
-DCORE_CM7 \
-DSTM32H750xx \
-DSTM32H750IB \
-DARM_MATH_CM7 \
-Dflash_layout \
-DHSE_VALUE=16000000 \
-DUSE_HAL_DRIVER \
-DUSE_FULL_LL_DRIVER \
-DDATA_IN_D2_SRAM
# ^ added for easy startup access
C_INCLUDES = \
-I$(MODULE_DIR) \
-I$(MODULE_DIR)/sys \
-I$(MODULE_DIR)/usbd \
-I$(MODULE_DIR)/usbh \
-IDrivers/CMSIS_5/CMSIS/Core/Include \
-IDrivers/CMSIS-Device/ST/STM32H7xx/Include \
-IDrivers/STM32H7xx_HAL_Driver/Inc \
-IDrivers/STM32H7xx_HAL_Driver/Inc/Legacy \
-IMiddlewares/ST/STM32_USB_Device_Library/Core/Inc \
-IMiddlewares/Patched/ST/STM32_USB_Device_Library/Class/CDC/Inc \
-IMiddlewares/ST/STM32_USB_Host_Library/Core/Inc \
-IMiddlewares/ST/STM32_USB_Host_Library/Class/MSC/Inc \
-IMiddlewares/ST/STM32_USB_Host_Library/Class/MIDI/Inc \
-IMiddlewares/Third_Party/FatFs/src \
-I$(MODULE_DIR) \
-I.
# suppressions for warnings introduced by HAL/FatFS
WARNINGS += -Wall -Wno-attributes -Wno-strict-aliasing -Wno-maybe-uninitialized -Wno-missing-attributes -Wno-stringop-overflow #-Werror
CPP_WARNINGS += -Wno-register
# compile gcc flags
ASFLAGS = $(MCU) $(AS_INCLUDES) $(AS_DEFS) -ggdb $(WARNINGS) $(OPT) -fdata-sections -ffunction-sections
CFLAGS = $(MCU) $(C_INCLUDES) $(C_DEFS) -ggdb $(WARNINGS) $(OPT) -fasm -fdata-sections -ffunction-sections
ifeq ($(DEBUG), 1)
CFLAGS += -g -ggdb
OPT = -O0
C_DEFS += -DDEBUG=1
else
C_DEFS += -DNDEBUG=1 -DRELEASE=1
endif
CFLAGS += \
-finline-functions
# C++ Flags
CPPFLAGS = $(CFLAGS) $(CPP_WARNINGS)
CPPFLAGS += \
-fno-exceptions \
-fno-rtti
C_STANDARD = -std=gnu11
CPP_STANDARD += -std=gnu++14
# default action: build all
all: $(BUILD_DIR)/$(TARGET).a
#######################################
# build the application
#######################################
# list of C program objects
OBJECTS = $(addprefix $(BUILD_DIR)/,$(C_SOURCES:.c=.o))
vpath %.c $(sort $(dir $(C_SOURCES)))
# list of CPP program objects
OBJECTS += $(addprefix $(BUILD_DIR)/,$(CPP_SOURCES:.cpp=.o))
vpath %.cpp $(sort $(dir $(CPP_SOURCES)))
# list of ASM program objects
OBJECTS += $(addprefix $(BUILD_DIR)/,$(ASM_SOURCES:.s=.o))
vpath %.s $(sort $(dir $(ASM_SOURCES)))
# Prunes duplicates, and orders lexically (for archive build)
SORTED_OBJECTS = $(sort $(OBJECTS))
$(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)
mkdir -p $(@D)
$(CC) $(CFLAGS) $(C_STANDARD) -c $< -o $@ -MD -MP -MF $(BUILD_DIR)/$(notdir $(<:.c=.dep))
$(BUILD_DIR)/%.o: %.cpp Makefile | $(BUILD_DIR)
mkdir -p $(@D)
$(CXX) $(CPPFLAGS) $(CPP_STANDARD) -c $< -o $@ -MD -MP -MF $(BUILD_DIR)/$(notdir $(<:.cpp=.dep))
$(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
mkdir -p $(@D)
$(AS) -c $(ASFLAGS) $< -o $@ -MD -MP -MF $(BUILD_DIR)/$(notdir $(<:.s =.dep))
$(BUILD_DIR)/$(TARGET).a: $(SORTED_OBJECTS) Makefile
$(AR) -r $@ $(SORTED_OBJECTS)
$(BUILD_DIR):
mkdir $@
#######################################
# clean up
#######################################
clean:
-rm -fR $(BUILD_DIR)
#######################################
# dependencies
#######################################
-include $(wildcard $(BUILD_DIR)/*.dep)