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