xref: /btstack/port/stm32-f4discovery-usb/Makefile (revision d20c764cf7101fbf842ceeacaa4e9dd0eed2991d)
1##########################################################################################################################
2# File automatically-generated by tool: [projectgenerator] version: [3.11.0-B13] date: [Sun Jan 17 23:15:13 CET 2021]
3##########################################################################################################################
4
5# ------------------------------------------------
6# Generic Makefile (based on gcc)
7#
8# ChangeLog :
9#	2017-02-10 - Several enhancements + project update mode
10#   2015-07-22 - first version
11# ------------------------------------------------
12
13######################################
14# target
15######################################
16TARGET = stm32-f4discovery-usb-blog
17
18
19######################################
20# building variables
21######################################
22# debug build?
23DEBUG = 1
24# optimization
25OPT = -Og
26
27
28#######################################
29# paths
30#######################################
31# Build path
32BUILD_DIR = build
33
34BTSTACK_ROOT ?= ../..
35VPATH += ${BTSTACK_ROOT}/example
36
37######################################
38# source
39######################################
40# C sources
41C_SOURCES =  \
42${BTSTACK_ROOT}/3rd-party/hxcmod-player/hxcmod.c \
43${BTSTACK_ROOT}/3rd-party/hxcmod-player/mods/nao-deceased_by_disease.c \
44${BTSTACK_ROOT}/3rd-party/micro-ecc/uECC.c \
45${BTSTACK_ROOT}/3rd-party/segger-rtt/SEGGER_RTT.c \
46${BTSTACK_ROOT}/3rd-party/segger-rtt/SEGGER_RTT_printf.c \
47${BTSTACK_ROOT}/3rd-party/segger-rtt/SEGGER_RTT_Syscalls_GCC.c \
48${BTSTACK_ROOT}/3rd-party/yxml/yxml.c \
49${BTSTACK_ROOT}/3rd-party/md5/md5.c \
50${BTSTACK_ROOT}/chipset/cc256x/btstack_chipset_cc256x.c \
51${BTSTACK_ROOT}/example/sco_demo_util.c \
52${BTSTACK_ROOT}/platform/embedded/btstack_audio_embedded.c \
53${BTSTACK_ROOT}/platform/embedded/btstack_run_loop_embedded.c \
54${BTSTACK_ROOT}/platform/embedded/btstack_stdin_embedded.c \
55${BTSTACK_ROOT}/platform/embedded/btstack_tlv_flash_bank.c \
56${BTSTACK_ROOT}/platform/embedded/btstack_uart_block_embedded.c \
57${BTSTACK_ROOT}/src/ad_parser.c \
58${BTSTACK_ROOT}/src/ble/ancs_client.c \
59${BTSTACK_ROOT}/src/ble/att_db.c \
60${BTSTACK_ROOT}/src/ble/att_dispatch.c \
61${BTSTACK_ROOT}/src/ble/att_server.c \
62${BTSTACK_ROOT}/src/ble/gatt-service/battery_service_server.c \
63${BTSTACK_ROOT}/src/ble/gatt-service/device_information_service_server.c \
64${BTSTACK_ROOT}/src/ble/gatt-service/hids_device.c \
65${BTSTACK_ROOT}/src/ble/gatt_client.c \
66${BTSTACK_ROOT}/src/ble/le_device_db_memory.c \
67${BTSTACK_ROOT}/src/ble/le_device_db_tlv.c \
68${BTSTACK_ROOT}/src/ble/sm.c \
69${BTSTACK_ROOT}/src/btstack_audio.c \
70${BTSTACK_ROOT}/src/btstack_crypto.c \
71${BTSTACK_ROOT}/src/btstack_hid_parser.c \
72${BTSTACK_ROOT}/src/btstack_linked_list.c \
73${BTSTACK_ROOT}/src/btstack_memory.c \
74${BTSTACK_ROOT}/src/btstack_memory_pool.c \
75${BTSTACK_ROOT}/src/btstack_resample.c \
76${BTSTACK_ROOT}/src/btstack_ring_buffer.c \
77${BTSTACK_ROOT}/src/btstack_run_loop.c \
78${BTSTACK_ROOT}/src/btstack_tlv.c \
79${BTSTACK_ROOT}/src/btstack_util.c \
80${BTSTACK_ROOT}/src/classic/a2dp_sink.c \
81${BTSTACK_ROOT}/src/classic/a2dp_source.c \
82${BTSTACK_ROOT}/src/classic/avdtp.c \
83${BTSTACK_ROOT}/src/classic/avdtp_acceptor.c \
84${BTSTACK_ROOT}/src/classic/avdtp_initiator.c \
85${BTSTACK_ROOT}/src/classic/avdtp_sink.c \
86${BTSTACK_ROOT}/src/classic/avdtp_source.c \
87${BTSTACK_ROOT}/src/classic/avdtp_util.c \
88${BTSTACK_ROOT}/src/classic/avrcp.c \
89${BTSTACK_ROOT}/src/classic/avrcp_browsing_controller.c \
90${BTSTACK_ROOT}/src/classic/avrcp_controller.c \
91${BTSTACK_ROOT}/src/classic/avrcp_media_item_iterator.c \
92${BTSTACK_ROOT}/src/classic/avrcp_target.c \
93${BTSTACK_ROOT}/src/classic/bnep.c \
94${BTSTACK_ROOT}/src/classic/btstack_cvsd_plc.c \
95${BTSTACK_ROOT}/src/classic/btstack_link_key_db_tlv.c \
96${BTSTACK_ROOT}/src/classic/btstack_sbc_decoder_bluedroid.c \
97${BTSTACK_ROOT}/src/classic/btstack_sbc_encoder_bluedroid.c \
98${BTSTACK_ROOT}/src/classic/btstack_sbc_plc.c \
99${BTSTACK_ROOT}/src/classic/device_id_server.c \
100${BTSTACK_ROOT}/src/classic/goep_client.c \
101${BTSTACK_ROOT}/src/classic/hfp.c \
102${BTSTACK_ROOT}/src/classic/hfp_ag.c \
103${BTSTACK_ROOT}/src/classic/hfp_gsm_model.c \
104${BTSTACK_ROOT}/src/classic/hfp_hf.c \
105${BTSTACK_ROOT}/src/classic/hfp_msbc.c \
106${BTSTACK_ROOT}/src/classic/hid_device.c \
107${BTSTACK_ROOT}/src/classic/hsp_ag.c \
108${BTSTACK_ROOT}/src/classic/hsp_hs.c \
109${BTSTACK_ROOT}/src/classic/obex_iterator.c \
110${BTSTACK_ROOT}/src/classic/obex_message_builder.c \
111${BTSTACK_ROOT}/src/classic/pan.c \
112${BTSTACK_ROOT}/src/classic/pbap_client.c \
113${BTSTACK_ROOT}/src/classic/rfcomm.c \
114${BTSTACK_ROOT}/src/classic/sdp_client.c \
115${BTSTACK_ROOT}/src/classic/sdp_client_rfcomm.c \
116${BTSTACK_ROOT}/src/classic/sdp_server.c \
117${BTSTACK_ROOT}/src/classic/sdp_util.c \
118${BTSTACK_ROOT}/src/classic/spp_server.c \
119${BTSTACK_ROOT}/src/hci.c \
120${BTSTACK_ROOT}/src/hci_cmd.c \
121${BTSTACK_ROOT}/src/hci_dump.c \
122${BTSTACK_ROOT}/src/hci_transport_h4.c \
123${BTSTACK_ROOT}/src/l2cap.c \
124${BTSTACK_ROOT}/src/l2cap_signaling.c \
125${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/def.c \
126${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/inet_chksum.c \
127${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/init.c \
128${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ip.c \
129${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/mem.c \
130${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/memp.c \
131${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/netif.c \
132${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/pbuf.c \
133${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/tcp.c \
134${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/tcp_in.c \
135${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/tcp_out.c \
136${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/timeouts.c \
137${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/udp.c \
138${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/acd.c \
139${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/dhcp.c \
140${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/etharp.c \
141${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/icmp.c \
142${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/ip4.c \
143${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/ip4_addr.c \
144${BTSTACK_ROOT}/3rd-party/lwip/core/src/core/ipv4/ip4_frag.c \
145${BTSTACK_ROOT}/3rd-party/lwip/core/src/netif/ethernet.c \
146${BTSTACK_ROOT}/3rd-party/lwip/core/src/apps/http/altcp_proxyconnect.c \
147${BTSTACK_ROOT}/3rd-party/lwip/core/src/apps/http/fs.c \
148${BTSTACK_ROOT}/3rd-party/lwip/core/src/apps/http/httpd.c \
149${BTSTACK_ROOT}/3rd-party/lwip/dhcp-server/dhserver.c \
150${BTSTACK_ROOT}/platform/lwip/port/sys_arch.c \
151${BTSTACK_ROOT}/platform/lwip/bnep_lwip.c \
152port/port.c \
153port/usbh_bluetooth.c \
154port/hci_transport_h2_stm32.c \
155port/hal_flash_bank_stm32.c \
156Core/Src/main.c \
157Core/Src/stm32f4xx_it.c \
158Core/Src/stm32f4xx_hal_msp.c \
159Core/Src/system_stm32f4xx.c \
160USB_HOST/App/usb_host.c \
161USB_HOST/Target/usbh_conf.c \
162USB_HOST/Target/usbh_platform.c \
163Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c \
164Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c \
165Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c \
166Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c \
167Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c \
168Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c \
169Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c \
170Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c \
171Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c \
172Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c \
173Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c \
174Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c \
175Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c \
176Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c \
177Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c \
178Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_exti.c \
179Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_hcd.c \
180Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_ll_usb.c \
181Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_core.c \
182Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_ctlreq.c \
183Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_ioreq.c \
184Middlewares/ST/STM32_USB_Host_Library/Core/Src/usbh_pipes.c \
185
186# ASM sources
187ASM_SOURCES =  \
188startup_stm32f407xx.s
189
190
191#######################################
192# binaries
193#######################################
194PREFIX = arm-none-eabi-
195# The gcc compiler bin path can be either defined in make command via GCC_PATH variable (> make GCC_PATH=xxx)
196# either it can be added to the PATH environment variable.
197ifdef GCC_PATH
198CC = $(GCC_PATH)/$(PREFIX)gcc
199AS = $(GCC_PATH)/$(PREFIX)gcc -x assembler-with-cpp
200CP = $(GCC_PATH)/$(PREFIX)objcopy
201SZ = $(GCC_PATH)/$(PREFIX)size
202else
203CC = $(PREFIX)gcc
204AS = $(PREFIX)gcc -x assembler-with-cpp
205CP = $(PREFIX)objcopy
206SZ = $(PREFIX)size
207endif
208HEX = $(CP) -O ihex
209BIN = $(CP) -O binary -S
210
211#######################################
212# CFLAGS
213#######################################
214# cpu
215CPU = -mcpu=cortex-m4
216
217# fpu
218FPU = -mfpu=fpv4-sp-d16
219
220# float-abi
221FLOAT-ABI = -mfloat-abi=hard
222
223# mcu
224MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI)
225
226# macros for gcc
227# AS defines
228AS_DEFS =
229
230# C defines
231C_DEFS =  \
232-DUSE_HAL_DRIVER \
233-DSTM32F407xx
234
235
236# AS includes
237AS_INCLUDES =
238
239# C includes
240C_INCLUDES =  \
241-ICore/Inc \
242-IDrivers/STM32F4xx_HAL_Driver/Inc \
243-IDrivers/STM32F4xx_HAL_Driver/Inc/Legacy \
244-IDrivers/CMSIS/Device/ST/STM32F4xx/Include \
245-IDrivers/CMSIS/Include \
246-IMiddlewares/ST/STM32_USB_Host_Library/Core/Inc \
247-IMiddlewares/ST/STM32_USB_Host_Library/Class/HID/Inc \
248
249C_INCLUDES += -I$(BUILD_DIR)
250C_INCLUDES += -I${BTSTACK_ROOT}/src/ble
251C_INCLUDES += -I${BTSTACK_ROOT}/src/ble/gatt-service
252C_INCLUDES += -I${BTSTACK_ROOT}/src/classic
253C_INCLUDES += -I${BTSTACK_ROOT}/src
254C_INCLUDES += -I${BTSTACK_ROOT}/3rd-party/micro-ecc
255C_INCLUDES += -I${BTSTACK_ROOT}/3rd-party/bluedroid/decoder/include
256C_INCLUDES += -I${BTSTACK_ROOT}/3rd-party/bluedroid/encoder/include
257C_INCLUDES += -I${BTSTACK_ROOT}/3rd-party/hxcmod-player
258C_INCLUDES += -I${BTSTACK_ROOT}/3rd-party/hxcmod-player/mods
259C_INCLUDES += -I${BTSTACK_ROOT}/3rd-party/lwip/core/src/include
260C_INCLUDES += -I${BTSTACK_ROOT}/3rd-party/lwip/dhcp-server
261C_INCLUDES += -I${BTSTACK_ROOT}/3rd-party/md5
262C_INCLUDES += -I${BTSTACK_ROOT}/3rd-party/yxml
263C_INCLUDES += -I${BTSTACK_ROOT}/3rd-party/segger-rtt
264C_INCLUDES += -I${BTSTACK_ROOT}/platform/embedded
265C_INCLUDES += -I${BTSTACK_ROOT}/platform/lwip
266C_INCLUDES += -I${BTSTACK_ROOT}/platform/lwip/port
267
268C_INCLUDES += -I bsp
269C_INCLUDES += -I pdm
270C_INCLUDES += -I port
271C_INCLUDES += -I Core/Src
272C_INCLUDES += -I USB_HOST/Target
273C_INCLUDES += -I USB_HOST/App
274
275# compile gcc flags
276ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
277
278CFLAGS = $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
279
280ifeq ($(DEBUG), 1)
281CFLAGS += -g -gdwarf-2
282endif
283
284
285# Generate dependency information
286CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)"
287
288
289#######################################
290# LDFLAGS
291#######################################
292# link script
293LDSCRIPT = STM32F407VGTx_FLASH.ld
294
295# libraries
296LIBS = -lc -lm -lnosys
297LIBDIR =
298LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections
299
300# default action: build all
301EXAMPLES = 					\
302	audio_duplex            \
303	a2dp_sink_demo			\
304	a2dp_source_demo        \
305	ancs_client_demo		\
306	dut_mode_classic        \
307	gap_dedicated_bonding	\
308	gap_inquiry 			\
309	gap_le_advertisements   \
310	gatt_battery_query		\
311	gatt_browser            \
312	gatt_counter            \
313	gatt_streamer_server    \
314	hfp_ag_demo             \
315	hfp_hf_demo             \
316	hid_host_demo           \
317	hid_keyboard_demo 	    \
318	hid_mouse_demo          \
319	hog_keyboard_demo       \
320	hog_mouse_demo          \
321	hsp_ag_demo             \
322	hsp_hs_demo             \
323	mod_player              \
324	le_streamer_client      \
325	pan_lwip_http_server    \
326	pbap_client_demo		\
327	sdp_bnep_query 			\
328	sdp_general_query		\
329	sdp_rfcomm_query		\
330	sine_player             \
331	sm_pairing_central      \
332	sm_pairing_peripheral   \
333	spp_and_gatt_counter 		\
334	spp_and_gatt_streamer     \
335	spp_counter 			\
336	spp_streamer			\
337	spp_streamer_client     \
338
339GATT_FILES = \
340	ancs_client_demo.gatt \
341	gatt_counter.gatt \
342	gatt_streamer_server.gatt \
343	gatt_browser.gatt \
344	gatt_battery_query.gatt \
345	hog_keyboard_demo.gatt \
346	hog_mouse_demo.gatt \
347	sm_pairing_peripheral.gatt \
348	sm_pairing_central.gatt \
349	spp_and_gatt_counter.gatt \
350	spp_and_gatt_streamer.gatt \
351
352# SBC codec
353include ${BTSTACK_ROOT}/3rd-party/bluedroid/decoder/Makefile.inc
354include ${BTSTACK_ROOT}/3rd-party/bluedroid/encoder/Makefile.inc
355VPATH += ${BTSTACK_ROOT}/3rd-party/bluedroid/decoder/srce
356VPATH += ${BTSTACK_ROOT}/3rd-party/bluedroid/encoder/srce
357C_SOURCES += ${SBC_ENCODER}
358C_SOURCES += ${SBC_DECODER}
359
360
361#######################################
362# build the application
363#######################################
364# list of objects
365OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
366vpath %.c $(sort $(dir $(C_SOURCES)))
367# list of ASM program objects
368OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
369vpath %.s $(sort $(dir $(ASM_SOURCES)))
370all: \
371	$(OBJECTS) \
372	$(addprefix $(BUILD_DIR)/,$(GATT_FILES:.gatt=.h)) \
373	$(addprefix $(BUILD_DIR)/,$(EXAMPLES:=.elf)) \
374	$(addprefix $(BUILD_DIR)/,$(EXAMPLES:=.hex)) \
375	$(addprefix $(BUILD_DIR)/,$(EXAMPLES:=.bin)) \
376	$(addprefix $(BUILD_DIR)/,$(EXAMPLES:=.jdebug)) \
377
378
379$(BUILD_DIR)/%.h: %.gatt
380	python3 ${BTSTACK_ROOT}/tool/compile_gatt.py $< $@
381
382
383$(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)
384	$(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@
385
386$(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
387	$(AS) -c $(CFLAGS) $< -o $@
388$(BUILD_DIR)/%.elf: Makefile $(OBJECTS) $(BUILD_DIR)/%.o
389	$(CC) $(filter-out Makefile,$^)  $(LDFLAGS) -o $@
390	$(SZ) $@
391
392$(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
393	$(HEX) $< $@
394
395$(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
396	$(BIN) $< $@
397
398$(BUILD_DIR)/%.jdebug: ozone.jdebug | $(BUILD_DIR)
399	sed -e "s|EXAMPLE|$(basename $(notdir $@))|" $<  > $@
400
401$(BUILD_DIR):
402	mkdir $@
403
404#######################################
405# clean up
406#######################################
407clean:
408	-rm -fR $(BUILD_DIR)
409
410#######################################
411# dependencies
412#######################################
413-include $(wildcard $(BUILD_DIR)/*.d)
414
415# *** EOF ***
416