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