xref: /btstack/port/stm32-l451-miromico-sx1280/Makefile (revision 6bdecec7ba8f55d805af8d13b9f45c3a7f6d5810)
1##########################################################################################################################
2# File automatically-generated by tool: [projectgenerator] version: [3.7.1] date: [Mon Jun 29 18:40:02 CEST 2020]
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 = sx1280-ble
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
34# BTstack Repo
35BTSTACK_ROOT ?= ../..
36
37# VPATH to find .gatt files
38VPATH += ${BTSTACK_ROOT}/example
39
40######################################
41# source
42######################################
43# C sources
44C_SOURCES =  \
45${BTSTACK_ROOT}/3rd-party/micro-ecc/uECC.c \
46${BTSTACK_ROOT}/3rd-party/rijndael/rijndael.c \
47${BTSTACK_ROOT}/3rd-party/segger-rtt/SEGGER_RTT.c \
48${BTSTACK_ROOT}/3rd-party/segger-rtt/SEGGER_RTT_printf.c \
49${BTSTACK_ROOT}/3rd-party/segger-rtt/SEGGER_RTT_Syscalls_GCC.c \
50${BTSTACK_ROOT}/platform/embedded/btstack_run_loop_embedded.c \
51${BTSTACK_ROOT}/src/ad_parser.c \
52${BTSTACK_ROOT}/src/ble/ancs_client.c \
53${BTSTACK_ROOT}/src/ble/att_db.c \
54${BTSTACK_ROOT}/src/ble/att_dispatch.c \
55${BTSTACK_ROOT}/src/ble/att_server.c \
56${BTSTACK_ROOT}/src/ble/gatt-service/battery_service_client.c \
57${BTSTACK_ROOT}/src/ble/gatt-service/battery_service_server.c \
58${BTSTACK_ROOT}/src/ble/gatt-service/device_information_service_client.c \
59${BTSTACK_ROOT}/src/ble/gatt-service/device_information_service_server.c \
60${BTSTACK_ROOT}/src/ble/gatt-service/hids_device.c \
61${BTSTACK_ROOT}/src/ble/gatt_client.c \
62${BTSTACK_ROOT}/src/ble/le_device_db_memory.c \
63${BTSTACK_ROOT}/src/ble/le_device_db_tlv.c \
64${BTSTACK_ROOT}/src/ble/sm.c \
65${BTSTACK_ROOT}/src/btstack_audio.c \
66${BTSTACK_ROOT}/src/btstack_crypto.c \
67${BTSTACK_ROOT}/src/btstack_hid_parser.c \
68${BTSTACK_ROOT}/src/btstack_linked_list.c \
69${BTSTACK_ROOT}/src/btstack_linked_queue.c \
70${BTSTACK_ROOT}/src/btstack_memory.c \
71${BTSTACK_ROOT}/src/btstack_memory_pool.c \
72${BTSTACK_ROOT}/src/btstack_resample.c \
73${BTSTACK_ROOT}/src/btstack_ring_buffer.c \
74${BTSTACK_ROOT}/src/btstack_run_loop.c \
75${BTSTACK_ROOT}/src/btstack_run_loop_base.c \
76${BTSTACK_ROOT}/src/btstack_tlv.c \
77${BTSTACK_ROOT}/src/btstack_tlv_none.c \
78${BTSTACK_ROOT}/src/btstack_util.c \
79${BTSTACK_ROOT}/src/hci.c \
80${BTSTACK_ROOT}/src/hci_cmd.c \
81${BTSTACK_ROOT}/src/hci_dump.c \
82${BTSTACK_ROOT}/src/hci_transport_h4.c \
83${BTSTACK_ROOT}/src/l2cap.c \
84${BTSTACK_ROOT}/src/l2cap_signaling.c \
85${BTSTACK_ROOT}/chipset/sx128x/controller.c \
86${BTSTACK_ROOT}/chipset/sx128x/hci_event.c \
87${BTSTACK_ROOT}/chipset/sx128x//hopping.c \
88${BTSTACK_ROOT}/chipset/sx128x//ll_sx1280.c \
89${BTSTACK_ROOT}/chipset/sx128x/SMTC_Drivers/sx1280-driver-c/sx1280-hal.c \
90${BTSTACK_ROOT}/chipset/sx128x/SMTC_Drivers/sx1280-driver-c/sx1280.c \
91Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal.c \
92Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_cortex.c \
93Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma.c \
94Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_dma_ex.c \
95Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_exti.c \
96Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash.c \
97Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ex.c \
98Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_flash_ramfunc.c \
99Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_gpio.c \
100Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c.c \
101Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_i2c_ex.c \
102Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_lptim.c \
103Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr.c \
104Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_pwr_ex.c \
105Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc.c \
106Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_rcc_ex.c \
107Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_spi.c \
108Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_spi_ex.c \
109Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim.c \
110Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_tim_ex.c \
111port/hal_timer.c \
112port/btstack_port.c \
113Src/main.c \
114Src/stm32l4xx_hal_msp.c \
115Src/stm32l4xx_it.c \
116Src/system_stm32l4xx.c \
117
118# ${BTSTACK_ROOT}/platform/embedded/hal_flash_bank_memory.c \
119# ${BTSTACK_ROOT}/platform/embedded/btstack_tlv_flash_bank.c \
120
121
122# ASM sources
123ASM_SOURCES =  \
124startup_stm32l451xx.s
125
126
127#######################################
128# binaries
129#######################################
130PREFIX = arm-none-eabi-
131# The gcc compiler bin path can be either defined in make command via GCC_PATH variable (> make GCC_PATH=xxx)
132# either it can be added to the PATH environment variable.
133ifdef GCC_PATH
134CC = $(GCC_PATH)/$(PREFIX)gcc
135AS = $(GCC_PATH)/$(PREFIX)gcc -x assembler-with-cpp
136CP = $(GCC_PATH)/$(PREFIX)objcopy
137SZ = $(GCC_PATH)/$(PREFIX)size
138else
139CC = $(PREFIX)gcc
140AS = $(PREFIX)gcc -x assembler-with-cpp
141CP = $(PREFIX)objcopy
142SZ = $(PREFIX)size
143endif
144HEX = $(CP) -O ihex
145BIN = $(CP) -O binary -S
146
147#######################################
148# CFLAGS
149#######################################
150# cpu
151CPU = -mcpu=cortex-m4
152
153# fpu
154FPU = -mfpu=fpv4-sp-d16
155
156# float-abi
157FLOAT-ABI = -mfloat-abi=hard
158
159# mcu
160MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI)
161
162# macros for gcc
163# AS defines
164AS_DEFS =
165
166# C defines
167C_DEFS =  \
168-DUSE_HAL_DRIVER \
169-DSTM32L451xx
170
171
172# AS includes
173AS_INCLUDES =
174
175# C includes
176C_INCLUDES =  \
177-I $(BUILD_DIR) \
178-I ${BTSTACK_ROOT}/3rd-party/micro-ecc \
179-I ${BTSTACK_ROOT}/3rd-party/rijndael \
180-I ${BTSTACK_ROOT}/3rd-party/segger-rtt \
181-I ${BTSTACK_ROOT}/platform/embedded \
182-I ${BTSTACK_ROOT}/src \
183-I ${BTSTACK_ROOT}/src/ble \
184-I ${BTSTACK_ROOT}/src/ble/gatt-service \
185-I ${BTSTACK_ROOT}/chipset/sx128x \
186-I ${BTSTACK_ROOT}/chipset/sx128x/SMTC_Drivers/ \
187-I ${BTSTACK_ROOT}/chipset/sx128x/SMTC_Drivers/sx1280-driver-c/ \
188-I controller \
189-I Drivers/CMSIS/Device/ST/STM32L4xx/Include \
190-I Drivers/CMSIS/Include \
191-I Drivers/STM32L4xx_HAL_Driver/Inc \
192-I Drivers/STM32L4xx_HAL_Driver/Inc/Legacy \
193-I Inc \
194-I port \
195-I .
196
197# compile gcc flags
198ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
199
200CFLAGS = $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
201
202ifeq ($(DEBUG), 1)
203CFLAGS += -g -gdwarf-2
204endif
205
206
207# Generate dependency information
208CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)"
209
210
211#######################################
212# LDFLAGS
213#######################################
214# link script
215LDSCRIPT = STM32L451REIx_FLASH.ld
216
217# libraries
218LIBS = -lc -lm -lnosys
219LIBDIR =
220LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections
221
222# default action: build all
223EXAMPLES = 					\
224	gatt_counter            \
225	gatt_streamer_server    \
226#	hog_keyboard_demo       \
227#	hog_mouse_demo          \
228
229GATT_FILES = \
230	gatt_counter.gatt \
231	gatt_streamer_server.gatt \
232	hog_keyboard_demo.gatt \
233	hog_mouse_demo.gatt \
234
235# default action: build all
236all: \
237	$(OBJECTS) \
238	$(addprefix $(BUILD_DIR)/,$(GATT_FILES:.gatt=.h)) \
239	$(addprefix $(BUILD_DIR)/,$(EXAMPLES:=.elf)) \
240	$(addprefix $(BUILD_DIR)/,$(EXAMPLES:=.hex)) \
241	$(addprefix $(BUILD_DIR)/,$(EXAMPLES:=.bin)) \
242	$(addprefix $(BUILD_DIR)/,$(EXAMPLES:=.jdebug)) \
243
244#######################################
245# build the application
246#######################################
247# list of objects
248OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
249vpath %.c $(sort $(dir $(C_SOURCES)))
250# list of ASM program objects
251OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
252vpath %.s $(sort $(dir $(ASM_SOURCES)))
253
254$(BUILD_DIR)/%.h: %.gatt | $(BUILD_DIR)
255	python3 ${BTSTACK_ROOT}/tool/compile_gatt.py $< $@
256
257$(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)
258	$(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@
259
260$(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
261	$(AS) -c $(CFLAGS) $< -o $@
262
263$(BUILD_DIR)/%.elf: Makefile $(OBJECTS) $(BUILD_DIR)/%.o
264	$(CC) $(filter-out Makefile,$^)  $(LDFLAGS) -o $@
265	$(SZ) $@
266
267$(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
268	$(HEX) $< $@
269
270$(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
271	$(BIN) $< $@
272
273$(BUILD_DIR)/%.jdebug: ozone.jdebug | $(BUILD_DIR)
274	sed -e "s|EXAMPLE|$(basename $(notdir $@))|" $<  > $@
275
276$(BUILD_DIR):
277	mkdir $@
278
279#######################################
280# clean up
281#######################################
282clean:
283	-rm -fR $(BUILD_DIR)
284
285#######################################
286# dependencies
287#######################################
288-include $(wildcard $(BUILD_DIR)/*.d)
289
290# *** EOF ***
291