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