-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
347 lines (315 loc) · 11.8 KB
/
Copy pathMakefile
File metadata and controls
347 lines (315 loc) · 11.8 KB
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
# Project_STD Makefile
# 参照 .eide/eide.yml Debug 目标配置生成
# ---- Toolchain ----
TOOLCHAIN ?= gcc
ifeq ($(TOOLCHAIN),gcc)
CC = arm-none-eabi-gcc
LD = arm-none-eabi-gcc
TC_FLAGS =
SPECS = --specs=nano.specs --specs=nosys.specs
else
CC = clang
LD = arm-none-eabi-gcc
TC_FLAGS = --target=arm-none-eabi --sysroot=/usr/arm-none-eabi
SPECS = --specs=nano.specs --specs=nosys.specs
endif
OBJCOPY = arm-none-eabi-objcopy
SIZE = arm-none-eabi-size
# ---- Directories ----
CONFIG ?= Debug
BUILD_DIR = build/$(CONFIG)
# ---- MCU Flags ----
CPU = -mcpu=cortex-m4
FPU = -mfpu=fpv4-sp-d16
FLOAT-ABI = -mfloat-abi=hard
MCU_FLAGS = $(CPU) -mthumb $(FPU) $(FLOAT-ABI)
# ---- Common Flags ----
DEFINES = -DUSE_HAL_DRIVER -DSTM32F407xx
INC_DIRS = \
-I Application/Inc \
-I Application/Inc/IAP \
-I Application/Inc/LDI \
-I Application/Inc/AH_MQTT \
-I Application/Inc/Channel \
-I Device/Inc \
-I Platform/Inc \
-I Kernel/Inc \
-I Core/Inc \
-I Drivers/CMSIS/Include \
-I Drivers/CMSIS/Device/ST/STM32F4xx/Include \
-I Drivers/STM32F4xx_HAL_Driver/Inc \
-I Middlewares/Third_Party/SEGGER_RTT \
-I Middlewares/Third_Party/LwIP/src/include \
-I Middlewares/Third_Party/LwIP/system \
-I Middlewares/Third_Party/FreeRTOS/Source/include \
-I Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2 \
-I Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F \
-I Compiler
# ---- C Flags ----
CFLAGS = $(MCU_FLAGS) $(DEFINES) $(INC_DIRS) $(TC_FLAGS)
CFLAGS += -std=gnu23
CFLAGS += -Og -g
CFLAGS += -Wall -Wextra
CFLAGS += -ffunction-sections -fdata-sections
CFLAGS += -fno-common
CFLAGS += -fno-exceptions
CFLAGS += -fshort-enums
# ---- LDFLAGS ----
LDSCRIPT = Compiler/STM32F407XX_FLASH.ld
LDFLAGS = $(MCU_FLAGS)
LDFLAGS += -T $(LDSCRIPT)
LDFLAGS += -Wl,-Map=$(BUILD_DIR)/Project_STD.map,--cref
LDFLAGS += -Wl,--gc-sections
LDFLAGS += $(SPECS)
LDFLAGS += -u _printf_float
LDFLAGS += -lm
# ---- Source Files ----
# Core/Application
SRC_CORE = \
Core/Src/main.c \
Core/Src/stm32f4xx_it.c \
Core/Src/syscalls.c \
Core/Src/sysmem.c \
Core/Src/adc.c \
Core/Src/dma.c \
Core/Src/gpio.c \
Core/Src/iwdg.c \
Core/Src/rtc.c \
Core/Src/spi.c \
Core/Src/stm32f4xx_hal_msp.c \
Core/Src/stm32f4xx_hal_timebase_tim.c \
Core/Src/system_stm32f4xx.c \
Core/Src/tim.c \
Core/Src/usart.c \
Core/Src/crc.c \
# LWIP
# STM32 HAL Driver
SRC_HAL = \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_adc_ex.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_cortex.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_dma_ex.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_eth.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_exti.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ex.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_flash_ramfunc.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_gpio.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_iwdg.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr_ex.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rcc_ex.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rtc.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_rtc_ex.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_spi.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_tim_ex.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_uart.c \
Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_crc.c
# BSP (旧协议层依赖 display/render/text_cvt,等协议迁移完成后移除)
# display/render 已迁移至 dev_display + app_render; text_cvt 已移至 Kernel
# BSP Protocol
# RTT
SRC_RTT = \
Middlewares/Third_Party/SEGGER_RTT/SEGGER_RTT.c \
Middlewares/Third_Party/SEGGER_RTT/SEGGER_RTT_printf.c \
Middlewares/Third_Party/SEGGER_RTT/SEGGER_RTT_Syscalls_GCC.c
# LwIP Middleware
# LwIP Middleware
SRC_LWIP = \
Middlewares/Third_Party/LwIP/system/OS/sys_arch.c \
Middlewares/Third_Party/LwIP/src/api/api_lib.c \
Middlewares/Third_Party/LwIP/src/api/api_msg.c \
Middlewares/Third_Party/LwIP/src/api/err.c \
Middlewares/Third_Party/LwIP/src/api/if_api.c \
Middlewares/Third_Party/LwIP/src/api/netbuf.c \
Middlewares/Third_Party/LwIP/src/api/netdb.c \
Middlewares/Third_Party/LwIP/src/api/netifapi.c \
Middlewares/Third_Party/LwIP/src/api/sockets.c \
Middlewares/Third_Party/LwIP/src/api/tcpip.c \
Middlewares/Third_Party/LwIP/src/core/altcp.c \
Middlewares/Third_Party/LwIP/src/core/altcp_alloc.c \
Middlewares/Third_Party/LwIP/src/core/altcp_tcp.c \
Middlewares/Third_Party/LwIP/src/core/def.c \
Middlewares/Third_Party/LwIP/src/core/dns.c \
Middlewares/Third_Party/LwIP/src/core/inet_chksum.c \
Middlewares/Third_Party/LwIP/src/core/init.c \
Middlewares/Third_Party/LwIP/src/core/ip.c \
Middlewares/Third_Party/LwIP/src/core/mem.c \
Middlewares/Third_Party/LwIP/src/core/memp.c \
Middlewares/Third_Party/LwIP/src/core/netif.c \
Middlewares/Third_Party/LwIP/src/core/pbuf.c \
Middlewares/Third_Party/LwIP/src/core/raw.c \
Middlewares/Third_Party/LwIP/src/core/stats.c \
Middlewares/Third_Party/LwIP/src/core/sys.c \
Middlewares/Third_Party/LwIP/src/core/tcp.c \
Middlewares/Third_Party/LwIP/src/core/tcp_in.c \
Middlewares/Third_Party/LwIP/src/core/tcp_out.c \
Middlewares/Third_Party/LwIP/src/core/timeouts.c \
Middlewares/Third_Party/LwIP/src/core/udp.c \
Middlewares/Third_Party/LwIP/src/core/ipv4/autoip.c \
Middlewares/Third_Party/LwIP/src/core/ipv4/dhcp.c \
Middlewares/Third_Party/LwIP/src/core/ipv4/etharp.c \
Middlewares/Third_Party/LwIP/src/core/ipv4/icmp.c \
Middlewares/Third_Party/LwIP/src/core/ipv4/igmp.c \
Middlewares/Third_Party/LwIP/src/core/ipv4/ip4.c \
Middlewares/Third_Party/LwIP/src/core/ipv4/ip4_addr.c \
Middlewares/Third_Party/LwIP/src/core/ipv4/ip4_frag.c \
Middlewares/Third_Party/LwIP/src/core/ipv6/dhcp6.c \
Middlewares/Third_Party/LwIP/src/core/ipv6/ethip6.c \
Middlewares/Third_Party/LwIP/src/core/ipv6/icmp6.c \
Middlewares/Third_Party/LwIP/src/core/ipv6/inet6.c \
Middlewares/Third_Party/LwIP/src/core/ipv6/ip6.c \
Middlewares/Third_Party/LwIP/src/core/ipv6/ip6_addr.c \
Middlewares/Third_Party/LwIP/src/core/ipv6/ip6_frag.c \
Middlewares/Third_Party/LwIP/src/core/ipv6/mld6.c \
Middlewares/Third_Party/LwIP/src/core/ipv6/nd6.c \
Middlewares/Third_Party/LwIP/src/apps/mqtt/mqtt.c \
Middlewares/Third_Party/LwIP/src/netif/bridgeif.c \
Middlewares/Third_Party/LwIP/src/netif/bridgeif_fdb.c \
Middlewares/Third_Party/LwIP/src/netif/ethernet.c \
Middlewares/Third_Party/LwIP/src/netif/lowpan6.c \
Middlewares/Third_Party/LwIP/src/netif/lowpan6_ble.c \
Middlewares/Third_Party/LwIP/src/netif/lowpan6_common.c \
Middlewares/Third_Party/LwIP/src/netif/slipif.c \
Middlewares/Third_Party/LwIP/src/netif/zepif.c \
Middlewares/Third_Party/LwIP/src/netif/ppp/auth.c \
Middlewares/Third_Party/LwIP/src/netif/ppp/ccp.c \
Middlewares/Third_Party/LwIP/src/netif/ppp/chap_ms.c \
Middlewares/Third_Party/LwIP/src/netif/ppp/chap-md5.c \
Middlewares/Third_Party/LwIP/src/netif/ppp/chap-new.c \
Middlewares/Third_Party/LwIP/src/netif/ppp/demand.c \
Middlewares/Third_Party/LwIP/src/netif/ppp/eap.c \
Middlewares/Third_Party/LwIP/src/netif/ppp/ecp.c \
Middlewares/Third_Party/LwIP/src/netif/ppp/eui64.c \
Middlewares/Third_Party/LwIP/src/netif/ppp/fsm.c \
Middlewares/Third_Party/LwIP/src/netif/ppp/ipcp.c \
Middlewares/Third_Party/LwIP/src/netif/ppp/ipv6cp.c \
Middlewares/Third_Party/LwIP/src/netif/ppp/lcp.c \
Middlewares/Third_Party/LwIP/src/netif/ppp/magic.c \
Middlewares/Third_Party/LwIP/src/netif/ppp/mppe.c \
Middlewares/Third_Party/LwIP/src/netif/ppp/multilink.c \
Middlewares/Third_Party/LwIP/src/netif/ppp/ppp.c \
Middlewares/Third_Party/LwIP/src/netif/ppp/pppapi.c \
Middlewares/Third_Party/LwIP/src/netif/ppp/pppcrypt.c \
Middlewares/Third_Party/LwIP/src/netif/ppp/pppoe.c \
Middlewares/Third_Party/LwIP/src/netif/ppp/pppol2tp.c \
Middlewares/Third_Party/LwIP/src/netif/ppp/pppos.c \
Middlewares/Third_Party/LwIP/src/netif/ppp/upap.c \
Middlewares/Third_Party/LwIP/src/netif/ppp/utils.c \
Middlewares/Third_Party/LwIP/src/netif/ppp/vj.c
# FreeRTOS
SRC_FREERTOS = \
Middlewares/Third_Party/FreeRTOS/Source/croutine.c \
Middlewares/Third_Party/FreeRTOS/Source/event_groups.c \
Middlewares/Third_Party/FreeRTOS/Source/list.c \
Middlewares/Third_Party/FreeRTOS/Source/queue.c \
Middlewares/Third_Party/FreeRTOS/Source/stream_buffer.c \
Middlewares/Third_Party/FreeRTOS/Source/tasks.c \
Middlewares/Third_Party/FreeRTOS/Source/timers.c \
Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.c \
Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c \
Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_4.c
# Startup
SRC_STARTUP = \
Compiler/startup.c
# Kernel
SRC_KERNEL = \
Kernel/Src/initcall.c \
Kernel/Src/ring_buffer.c \
Kernel/Src/bit_utils.c \
Kernel/Src/crc_utils.c \
Kernel/Src/text_cvt.c
# Platform(仅含无冲突的文件,其他在 Phase 3 逐步加入)
SRC_PLATFORM = \
Platform/Src/pl_gpio.c \
Platform/Src/pl_rtt.c \
Platform/Src/pl_exti.c \
Platform/Src/pl_net.c \
Platform/Src/pl_eth.c \
Platform/Src/pl_crc.c \
Platform/Src/pl_iwdg.c \
Platform/Src/pl_dma.c \
Platform/Src/pl_dwt.c \
Platform/Src/pl_tim.c \
Platform/Src/pl_rtc.c \
Platform/Src/pl_sys.c \
Platform/Src/pl_flash.c \
Platform/Src/pl_hub75.c \
Platform/Src/pl_adc.c \
Platform/Src/pl_spi.c \
Platform/Src/pl_uart.c
# Device (仅 Project_STD 新模块,resend dev_* 等 Phase 6 Platform 集成后加入)
SRC_DEVICE = \
Device/IO/dev_io_ctrl.c \
Device/IO/dev_key.c \
Device/Display/dev_display.c \
Device/Display/dev_display_p20.c \
Device/IO/dev_light_sensor.c \
Device/Storage/dev_w25qxx.c \
Device/Storage/dev_flash_int.c \
Device/Network/dev_dp83848.c \
Device/Network/dev_eth.c \
Device/Comm/dev_rs485.c \
Device/Comm/dev_rs232.c
# Application (Project_STD 新模块,resend app_* 等 Phase 7 集成后加入)
SRC_APPLICATION = \
Application/Src/app_test.c \
Application/Src/app_factory_test.c \
Application/Src/app_boot.c \
Application/Src/app_dispatch.c \
Application/Src/app_render.c \
Application/Src/app_key.c \
Application/Src/app_light_sensor.c \
Application/Src/IAP/app_iap.c \
Application/Src/IAP/app_iap_cmd.c \
Application/Src/IAP/app_iap_cfg.c \
Application/Src/LDI/app_ldi.c \
Application/Src/LDI/app_ldi_cmd.c \
Application/Src/LDI/app_ldi_cfg.c \
Application/Src/LDI/app_vms_ctrl.c \
Application/Src/AH_MQTT/ah_mqtt.c \
Application/Src/AH_MQTT/ah_mqtt_cmd.c \
Application/Src/Channel/app_udp.c \
Application/Src/Channel/app_tcp_server.c \
Application/Src/Channel/app_tcp_client.c \
Application/Src/Channel/app_mqtt.c \
Application/Src/Channel/app_rs232.c \
Application/Src/Channel/app_rs485.c
# ---- All Sources ----
SRC_ALL = \
$(SRC_KERNEL) \
$(SRC_PLATFORM) \
$(SRC_DEVICE) \
$(SRC_APPLICATION) \
$(SRC_CORE) \
$(SRC_HAL) \
$(SRC_RTT) \
$(SRC_LWIP) \
$(SRC_FREERTOS) \
$(SRC_STARTUP)
# ---- Object Files ----
OBJ_ALL = $(addprefix $(BUILD_DIR)/,$(SRC_ALL:.c=.o))
# ---- Targets ----
.PHONY: all clean
all: $(BUILD_DIR)/Project_STD.elf $(BUILD_DIR)/Project_STD.hex $(BUILD_DIR)/Project_STD.bin
@echo "==== Build complete ===="
@$(SIZE) $(BUILD_DIR)/Project_STD.elf
$(BUILD_DIR)/Project_STD.elf: $(OBJ_ALL)
@echo "Linking $@"
@mkdir -p $(dir $@)
$(LD) $(LDFLAGS) -o $@ $^
$(BUILD_DIR)/Project_STD.hex: $(BUILD_DIR)/Project_STD.elf
$(OBJCOPY) -O ihex $< $@
$(BUILD_DIR)/Project_STD.bin: $(BUILD_DIR)/Project_STD.elf
$(OBJCOPY) -O binary $< $@
# ---- Compile Rule ----
$(BUILD_DIR)/%.o: %.c
@echo "Compiling $<"
@mkdir -p $(dir $@)
$(CC) $(CFLAGS) -c -o $@ $<
clean:
rm -rf $(BUILD_DIR)