-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
417 lines (354 loc) · 12.4 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
##########################################################################################################################
# File automatically-generated by tool: [projectgenerator] version: [4.2.0-B44] date: [Wed Jan 24 17:11:25 CET 2024]
##########################################################################################################################
# ------------------------------------------------
# Generic Makefile (based on gcc)
#
# ChangeLog :
# 2017-02-10 - Several enhancements + project update mode
# 2015-07-22 - first version
# ------------------------------------------------
current_makefile := $(firstword $(MAKEFILE_LIST))
current_repo_status := $(shell if !(git status --porcelain); then echo ''; fi)
current_repo_commit := $(shell if !(git log -1 --format="%h"); then echo 'unknow'; fi)
######################################
# target
######################################
TARGET = argos-smd-at-kineis-firmware
######################################
# building variables
######################################
# debug build?
DEBUG = 1
VERBOSE = 0
USE_BAREMETAL = 1
# Select APPlication. Can be:
# * STDLN: for the standalone application sending one message at startup
# * GUI: for the application using the AT commands from UART link
APP = GUI
# Select Kineis stack MAC profile. Can be:
# * BASIC: basic profile, sending message once immediately
# * BLIND: blind profile, sending message sevral times periodically
MAC_PRFL = BASIC
# LPM: depest low power mode supported can be:
# NONE, SLEEP, STOP, STANDBY, SHUTDOWN
LPM = NONE
# * KRD board: choose between: KRD_FW_LP, KRD_FW_MP
KRD_BOARD = KRD_FW_MP
# optimization
ifeq ($(DEBUG), 1)
OPT = -Og
else
OPT =
endif
#######################################
# paths
#######################################
# Kineis related
KINEIS_DIR = Kineis
KINEIS_VERSION = v1.0.0
# Build path
BUILD_DIR = build
BUILD_INFO_FILE = build_info.c
BUILD_VERSION :=
# doc/doxygen related
DOC_DIR = $(KINEIS_DIR)/Doc/krd_fw
DOXY_WARN_LOGFILE = $(KINEIS_DIR)/doxy_warn_log_file.txt
#######################################
# includes
#######################################
# include *.mk makefiles here if needed as impacted by variables above
#include kineis_sw/Make/libknsrf_wl.mk
######################################
# source
######################################
# C sources
C_SOURCES = \
Core/Src/main.c \
Core/Src/stm32wlxx_it.c \
Core/Src/stm32wlxx_hal_msp.c \
Drivers/STM32WLxx_HAL_Driver/Src/stm32wlxx_hal_rcc.c \
Drivers/STM32WLxx_HAL_Driver/Src/stm32wlxx_hal_rcc_ex.c \
Drivers/STM32WLxx_HAL_Driver/Src/stm32wlxx_hal_flash.c \
Drivers/STM32WLxx_HAL_Driver/Src/stm32wlxx_hal_flash_ex.c \
Drivers/STM32WLxx_HAL_Driver/Src/stm32wlxx_hal_gpio.c \
Drivers/STM32WLxx_HAL_Driver/Src/stm32wlxx_hal_i2c.c \
Drivers/STM32WLxx_HAL_Driver/Src/stm32wlxx_hal_i2c_ex.c \
Drivers/STM32WLxx_HAL_Driver/Src/stm32wlxx_hal_dma.c \
Drivers/STM32WLxx_HAL_Driver/Src/stm32wlxx_hal_dma_ex.c \
Drivers/STM32WLxx_HAL_Driver/Src/stm32wlxx_hal_pwr.c \
Drivers/STM32WLxx_HAL_Driver/Src/stm32wlxx_hal_pwr_ex.c \
Drivers/STM32WLxx_HAL_Driver/Src/stm32wlxx_hal_cortex.c \
Drivers/STM32WLxx_HAL_Driver/Src/stm32wlxx_hal.c \
Drivers/STM32WLxx_HAL_Driver/Src/stm32wlxx_hal_exti.c \
Drivers/STM32WLxx_HAL_Driver/Src/stm32wlxx_hal_subghz.c \
Drivers/STM32WLxx_HAL_Driver/Src/stm32wlxx_hal_tim.c \
Drivers/STM32WLxx_HAL_Driver/Src/stm32wlxx_hal_tim_ex.c \
Drivers/STM32WLxx_HAL_Driver/Src/stm32wlxx_hal_uart.c \
Drivers/STM32WLxx_HAL_Driver/Src/stm32wlxx_hal_uart_ex.c \
Core/Src/system_stm32wlxx.c \
Core/Src/gpio.c \
Core/Src/i2c.c \
Core/Src/usart.c \
Core/Src/subghz.c \
Core/Src/tim.c \
Core/Src/rtc.c \
Drivers/STM32WLxx_HAL_Driver/Src/stm32wlxx_hal_rtc.c \
Drivers/STM32WLxx_HAL_Driver/Src/stm32wlxx_hal_rtc_ex.c
C_SOURCES += \
$(BUILD_INFO_FILE) \
$(KINEIS_DIR)/Extdep/Conf/kns_assert.c \
$(KINEIS_DIR)/Extdep/Conf/kns_cs.c \
$(KINEIS_DIR)/Extdep/Conf/kns_q_conf.c \
$(KINEIS_DIR)/Extdep/MGR_LOG/Src/mgr_log.c \
$(KINEIS_DIR)/Extdep/MGR_LOG/Src/mgr_log_rtc.c \
$(KINEIS_DIR)/Extdep/Mcu/Src/mcu_misc.c \
$(KINEIS_DIR)/Extdep/Mcu/Src/mcu_aes.c \
$(KINEIS_DIR)/Extdep/Mcu/Src/aes.c \
$(KINEIS_DIR)/Extdep/Mcu/Src/mcu_nvm.c \
$(KINEIS_DIR)/Extdep/Mcu/Src/mcu_tim.c \
$(KINEIS_DIR)/App/Kineis_os/KNS_Q/Src/kns_q.c \
$(KINEIS_DIR)/App/Kineis_os/KNS_OS/Src/kns_os.c \
$(KINEIS_DIR)/App/kns_app.c \
$(KINEIS_DIR)/App/Mcu/Src/mcu_at_console.c \
$(KINEIS_DIR)/App/Managers/MGR_AT_CMD/Src/mgr_at_cmd.c \
$(KINEIS_DIR)/App/Managers/MGR_AT_CMD/Src/mgr_at_cmd_common.c \
$(KINEIS_DIR)/App/Managers/MGR_AT_CMD/Src/mgr_at_cmd_list.c \
$(KINEIS_DIR)/App/Managers/MGR_AT_CMD/Src/mgr_at_cmd_list_user_data.c \
$(KINEIS_DIR)/App/Managers/MGR_AT_CMD/Src/mgr_at_cmd_list_general.c \
$(KINEIS_DIR)/App/Managers/MGR_AT_CMD/Src/mgr_at_cmd_list_mac.c \
$(KINEIS_DIR)/App/Managers/MGR_AT_CMD/Src/mgr_at_cmd_list_certif.c \
$(KINEIS_DIR)/App/Managers/MGR_AT_CMD/Src/mgr_at_cmd_list_previpass.c \
$(KINEIS_DIR)/App/Libs/STRUTIL/Src/strutil_lib.c \
$(KINEIS_DIR)/App/Libs/USERDATA/Src/user_data.c \
$(KINEIS_DIR)/Lpm/Src/mgr_lpm.c \
$(KINEIS_DIR)/Lpm/Src/lpm.c \
$(KINEIS_DIR)/Lpm/Src/lpm_cli_kstk.c \
$(KINEIS_DIR)/Lib/libkineis_info.c \
$(KINEIS_DIR)/Lib/libknsrf_wl_info.c
C_SOURCES += #$(libknsrf_wl_SOURCES)
# ASM sources
ASM_SOURCES = \
startup_stm32wl55xx_cm4.s
#######################################
# binaries
#######################################
PREFIX = arm-none-eabi-
# The gcc compiler bin path can be either defined in make command via GCC_PATH variable (> make GCC_PATH=xxx)
# either it can be added to the PATH environment variable.
ifdef GCC_PATH
CC = $(GCC_PATH)/$(PREFIX)gcc
AS = $(GCC_PATH)/$(PREFIX)gcc -x assembler-with-cpp
CP = $(GCC_PATH)/$(PREFIX)objcopy
SZ = $(GCC_PATH)/$(PREFIX)size
else
CC = $(PREFIX)gcc
AS = $(PREFIX)gcc -x assembler-with-cpp
CP = $(PREFIX)objcopy
SZ = $(PREFIX)size
endif
HEX = $(CP) -O ihex
BIN = $(CP) -O binary -S
#######################################
# CFLAGS
#######################################
# cpu
CPU = -mcpu=cortex-m4
# fpu
# NONE for Cortex-M0/M0+/M3
# float-abi
# mcu
MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI)
# macros for gcc
# AS defines
AS_DEFS =
# C defines
C_DEFS += \
-DCORE_CM4 \
-DUSE_HAL_DRIVER \
-DSTM32WL55xx \
-DUSE_LOCAL_PRINTF \
-DUSE_USERDATA_TX \
-DLPM_$(LPM)_ENABLED \
-D$(KRD_BOARD)
ifeq ($(USE_BAREMETAL), 1)
C_DEFS += \
-DUSE_BAREMETAL
endif
C_DEFS += #$(libknsrf_wl_C_DEFS)
ifeq ($(DEBUG), 1)
C_DEFS += \
-DDEBUG
BUILD_VERSION := $(BUILD_VERSION)D
endif
ifeq ($(VERBOSE), 1)
C_DEFS += \
-DVERBOSE
BUILD_VERSION := $(BUILD_VERSION)V
endif
# NONE, SLEEP, STOP, STANDBY, SHUTDOWN
ifeq ($(LPM), SLEEP)
BUILD_VERSION := $(BUILD_VERSION)Slp
endif
ifeq ($(LPM), STOP)
BUILD_VERSION := $(BUILD_VERSION)Stp
endif
ifeq ($(LPM), STANDBY)
BUILD_VERSION := $(BUILD_VERSION)Stdb
endif
ifeq ($(LPM), SHUTDOWN)
BUILD_VERSION := $(BUILD_VERSION)Shtdwn
endif
ifeq ($(KRD_BOARD),KRD_FW_MP)
BUILD_VERSION := $(BUILD_VERSION)Mp
endif
ifeq ($(KRD_BOARD),KRD_FW_LP)
BUILD_VERSION := $(BUILD_VERSION)Lp
endif
ifeq ($(APP),STDLN)
C_DEFS += \
-DUSE_STDALONE_APP
BUILD_VERSION := $(BUILD_VERSION)_stdln
endif
ifeq ($(APP),GUI)
C_DEFS += \
-DUSE_GUI_APP
BUILD_VERSION := $(BUILD_VERSION)_gui
endif
ifeq ($(MAC_PRFL), BASIC)
C_DEFS += \
-DUSE_MAC_PRFL_BASIC
BUILD_VERSION := $(BUILD_VERSION)_basic
endif
ifeq ($(MAC_PRFL), BLIND)
C_DEFS += \
-DUSE_MAC_PRFL_BLIND
BUILD_VERSION := $(BUILD_VERSION)_blind
endif
#######################################
# includes
#######################################
# AS includes
AS_INCLUDES =
# C includes
C_INCLUDES = \
-I. \
-ICore/Inc \
-IDrivers/STM32WLxx_HAL_Driver/Inc \
-IDrivers/STM32WLxx_HAL_Driver/Inc/Legacy \
-IDrivers/CMSIS/Device/ST/STM32WLxx/Include \
-IDrivers/CMSIS/Include \
-Ikineis_sw \
-I$(KINEIS_DIR)/Lib \
-I$(KINEIS_DIR)/Extdep/Conf \
-I$(KINEIS_DIR)/Extdep/Mcu/Inc \
-I$(KINEIS_DIR)/Extdep/MGR_LOG/Inc \
-I$(KINEIS_DIR)/Appconf \
-I$(KINEIS_DIR)/App/Kineis_os/KNS_Q/Inc \
-I$(KINEIS_DIR)/App/Kineis_os/KNS_OS/Inc \
-I$(KINEIS_DIR)/App/. \
-I$(KINEIS_DIR)/App/Managers/MGR_AT_CMD/Inc \
-I$(KINEIS_DIR)/App/Mcu/Inc \
-I$(KINEIS_DIR)/App/Libs/STRUTIL/Inc \
-I$(KINEIS_DIR)/App/Libs/USERDATA/Inc \
-I$(KINEIS_DIR)/Lpm/Inc
C_INCLUDES += #$(libknsrf_wl_INCLUDES)
# compile gcc flags
ASFLAGS += $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -Wextra -Wno-unused-parameter -Wimplicit-fallthrough=1 -Werror -Wtype-limits -fdata-sections -Wwrite-strings -ffunction-sections -fstack-usage
CFLAGS += $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -Wextra -Wno-unused-parameter -Wimplicit-fallthrough=1 -Werror -Wtype-limits -fdata-sections -Wwrite-strings -ffunction-sections -fstack-usage
ifeq ($(DEBUG), 1)
CFLAGS += -g -gdwarf-2
endif
# Generate dependency information
CFLAGS += -MD -MP -MF"$(@:%.o=%.d)"
#######################################
# LDFLAGS
#######################################
# link script
LDSCRIPT = STM32WL55XX_FLASH_CM4.ld
# libraries
LIBS = -lc -lm -lnosys
LIBDIR =
LDFLAGS = $(MCU) -specs=nano.specs -T$(LDSCRIPT) $(LIBDIR) $(LIBS) -Wl,-Map=$(BUILD_DIR)/$(TARGET).map,--cref -Wl,--gc-sections -static
ifneq ($(DEBUG), 1)
LDFLAGS += -s
endif
#######################################
# rules
#######################################
# default action: build all
all: $(BUILD_DIR)/$(TARGET).elf $(BUILD_DIR)/$(TARGET).hex $(BUILD_DIR)/$(TARGET).bin
@echo '==== Build with libkineis.a and libknsrf_wl.a completed ===='
# generate SW version of the firmware from GIT commit ID
$(BUILD_INFO_FILE):
@echo '#include "build_info.h"' > $(BUILD_INFO_FILE)
@echo '' >> $(BUILD_INFO_FILE)
@echo -n 'const char uc_fw_vers_commit_id[] = "' >> $(BUILD_INFO_FILE)
@echo -n '$(current_repo_commit)' >> $(BUILD_INFO_FILE)
@echo "!$(current_repo_status)!"
@if [ -n "$(current_repo_status)" ]; then \
echo -n '*' >> $(BUILD_INFO_FILE); \
fi
@if [ -n "$(BUILD_VERSION)" ]; then \
echo -n '_$(BUILD_VERSION)' >> $(BUILD_INFO_FILE); \
fi
@echo '";' >> $(BUILD_INFO_FILE)
# generate doc (doxygen framework), configure some dynamic parameters from Makefile
doc: Doxyfile $(DOC_DIR)
(cat $< ; \
echo $(CFLAGS) | xargs -n1 echo | grep "^-D" | sed 's/-D//' | xargs echo PREDEFINED= ; \
echo PROJECT_NUMBER= $(KINEIS_VERSION); \
echo OUTPUT_DIRECTORY=$(DOC_DIR) ; \
echo INPUT= Core/Src/main.c $(KINEIS_DIR)/README.md $(subst -I,,$(C_INCLUDES)) ; \
echo EXCLUDE=$(DOC_DIR) ; \
echo EXCLUDE_PATTERNS=*/UnitTest*/* */IntegrationTest*/* */extra_inc/* */extra_src/* */FreeRTOS/*; \
echo EXCLUDE_PATTERNS+=*/Tools/*; \
echo EXCLUDE_PATTERNS+=*/Kineis/Indep/*; \
echo EXCLUDE_PATTERNS+=*/kineis_sw/*; \
echo EXCLUDE_PATTERNS+=*/Drivers/STM32*/* */Drivers/CMSIS*/* */Core/*; \
echo USE_MDFILE_AS_MAINPAGE= $(KINEIS_DIR)/README.md; \
echo WARN_LOGFILE=$(DOXY_WARN_LOGFILE)) \
| doxygen -
-(git log -n 1 > $(DOC_DIR)/doc_version.txt)
@echo "==== Doc generated for firmware package ===="
#######################################
# build the application
#######################################
# list of objects
OBJECTS = $(addprefix $(BUILD_DIR)/,$(notdir $(C_SOURCES:.c=.o)))
vpath %.c $(sort $(dir $(C_SOURCES)))
# list of ASM program objects
OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o)))
vpath %.s $(sort $(dir $(ASM_SOURCES)))
$(BUILD_DIR)/%.o: %.c $(current_makefile) | $(BUILD_DIR)
$(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@
$(BUILD_DIR)/%.o: %.s $(current_makefile) | $(BUILD_DIR)
$(AS) -c $(CFLAGS) $< -o $@
$(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) $(current_makefile)
$(CC) $(OBJECTS) -L$(KINEIS_DIR)/Lib/. -Wl,--whole-archive -lkineis -lknsrf_wl -Wl,--no-whole-archive $(LDFLAGS) -o $@
$(SZ) -t $@
$(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
$(HEX) $< $@
$(BUILD_DIR)/%.bin: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
$(BIN) $< $@
$(KINEIS_DIR) $(BUILD_DIR) $(DOC_DIR):
mkdir -p $@
#######################################
# clean up
#######################################
clean: #libknsrf_wl_clean
-rm -fR $(BUILD_INFO_FILE)
-rm -fR $(BUILD_DIR)
doc_clean:
-rm -fR $(DOC_DIR)
-rm -f $(DOXY_WARN_LOGFILE)
#######################################
# dependencies
#######################################
-include $(wildcard $(BUILD_DIR)/*.d)
.PHONY: doc doc_clean
#######################################
# force empty target
#######################################
.DEFAULT_GOAL := all
# *** EOF ***