xref: /btstack/port/stm32-l476rg-nucleo-sx1280/Makefile (revision 755c0732ebd94ff8e946ea8b138fa599ff3146a7)
1##########################################################################################################################
2# File automatically-generated by tool: [projectgenerator] version: [3.11.0-B13] date: [Fri Apr 30 00:25:48 CEST 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-l476rg-nucleo-sx1280
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_tlv.c \
76${BTSTACK_ROOT}/src/btstack_tlv_none.c \
77${BTSTACK_ROOT}/src/btstack_util.c \
78${BTSTACK_ROOT}/src/hci.c \
79${BTSTACK_ROOT}/src/hci_cmd.c \
80${BTSTACK_ROOT}/src/hci_dump.c \
81${BTSTACK_ROOT}/src/hci_event.c \
82${BTSTACK_ROOT}/src/hci_event_builder.c \
83${BTSTACK_ROOT}/src/hci_transport_h4.c \
84${BTSTACK_ROOT}/src/l2cap.c \
85${BTSTACK_ROOT}/src/l2cap_signaling.c \
86${BTSTACK_ROOT}/chipset/cinnamon/controller.c \
87${BTSTACK_ROOT}/chipset/cinnamon/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 \
111Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart.c \
112Drivers/STM32L4xx_HAL_Driver/Src/stm32l4xx_hal_uart_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_stm32l476xx.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-DSTM32L476xx
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-IDrivers/STM32L4xx_HAL_Driver/Inc \
194-IDrivers/STM32L4xx_HAL_Driver/Inc/Legacy \
195-I Inc \
196-I port \
197-I . \
198-IInc \
199-IDrivers/CMSIS/Device/ST/STM32L4xx/Include \
200-IDrivers/CMSIS/Include
201
202# compile gcc flags
203ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
204
205CFLAGS = $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
206
207ifeq ($(DEBUG), 1)
208CFLAGS += -g -gdwarf-2
209endif
210
211
212# Generate dependency information
213CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)"
214
215
216#######################################
217# LDFLAGS
218#######################################
219# link script
220LDSCRIPT = STM32L476RGTx_FLASH.ld
221
222# libraries
223LIBS = -lc -lm -lnosys
224LIBDIR =
225LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections
226
227# default action: build all
228EXAMPLES = 					\
229	gatt_counter            \
230	gatt_streamer_server    \
231	hog_keyboard_demo       \
232	hog_mouse_demo          \
233
234GATT_FILES = \
235	gatt_counter.gatt \
236	gatt_streamer_server.gatt \
237	hog_keyboard_demo.gatt \
238	hog_mouse_demo.gatt \
239
240# default action: build all
241all: \
242	$(OBJECTS) \
243	$(addprefix $(BUILD_DIR)/,$(GATT_FILES:.gatt=.h)) \
244	$(addprefix $(BUILD_DIR)/,$(EXAMPLES:=.elf)) \
245	$(addprefix $(BUILD_DIR)/,$(EXAMPLES:=.hex)) \
246	$(addprefix $(BUILD_DIR)/,$(EXAMPLES:=.bin)) \
247	$(addprefix $(BUILD_DIR)/,$(EXAMPLES:=.jdebug)) \
248
249#######################################
250# build the application
251#######################################
252# list of objects
253OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
254vpath %.c $(sort $(dir $(C_SOURCES)))
255# list of ASM program objects
256OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
257vpath %.s $(sort $(dir $(ASM_SOURCES)))
258
259$(BUILD_DIR)/%.h: %.gatt | $(BUILD_DIR)
260	python3 ${BTSTACK_ROOT}/tool/compile_gatt.py $< $@
261
262$(BUILD_DIR)/%.o: %.c Makefile | $(BUILD_DIR)
263	$(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@
264
265$(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
266	$(AS) -c $(CFLAGS) $< -o $@
267
268$(BUILD_DIR)/%.elf: Makefile $(OBJECTS) $(BUILD_DIR)/%.o
269	$(CC) $(filter-out Makefile,$^)  $(LDFLAGS) -o $@
270	$(SZ) $@
271
272$(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
273	$(HEX) $< $@
274
275$(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
276	$(BIN) $< $@
277
278$(BUILD_DIR)/%.jdebug: ozone.jdebug | $(BUILD_DIR)
279	sed -e "s|EXAMPLE|$(basename $(notdir $@))|" $<  > $@
280
281$(BUILD_DIR):
282	mkdir $@
283
284#######################################
285# clean up
286#######################################
287clean:
288	-rm -fR $(BUILD_DIR)
289
290#######################################
291# dependencies
292#######################################
293-include $(wildcard $(BUILD_DIR)/*.d)
294
295# *** EOF ***
296