rules.mk
9.49 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
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
##############################################################################
# Build global options
# NOTE: Can be overridden externally.
#
# default paramenters
MCU_SIZE ?= MCU_386K_64K
USE_USB_DEVICE ?= no
# Imported source files and paths
CHIBIOS = $(SDK_ROOT)
include $(CHIBIOS)/econais/build/configs.inc
CONFIG = $(LIB_CONFIG)
BOOTLOADER = $(LIB_BOOTLOADER)
PLAT = $(LIB_PLAT)
USE_UPNP = $(LIB_USE_UPNP)
USE_DEBUGER = $(LIB_USE_DEBUGER)
USE_WPS = $(LIB_USE_WPS)
USE_8021X = $(LIB_USE_8021X)
RF_TEST = $(LIB_RF_TEST)
# Select the LWIP version (v140,v141)
LWIP ?= v141
# Compiler options here.
ifeq ($(USE_OPT),)
USE_OPT = -ggdb -fomit-frame-pointer -falign-functions=16
ifeq ($(USE_DEBUGER),false)
USE_OPT += -O2
else
USE_OPT += -O0
endif
endif
# C specific options here (added to USE_OPT).
ifeq ($(USE_COPT),)
USE_COPT =
endif
# C++ specific options here (added to USE_OPT).
ifeq ($(USE_CPPOPT),)
USE_CPPOPT = -fno-rtti
endif
# Enable this if you want the linker to remove unused code and data
ifeq ($(USE_LINK_GC),)
USE_LINK_GC = yes
endif
# If enabled, this option allows to compile the application in THUMB mode.
ifeq ($(USE_THUMB),)
USE_THUMB = yes
endif
# Enable this if you want to see the full log while compiling.
ifeq ($(USE_VERBOSE_COMPILE),)
USE_VERBOSE_COMPILE = no
endif
#
# Build global options
##############################################################################
##############################################################################
# Architecture or project specific options
#
# Enable this if you really want to use the STM FWLib.
ifeq ($(USE_FWLIB),)
USE_FWLIB = yes
endif
#
# Architecture or project specific options
##############################################################################
##############################################################################
# Project, sources and paths
#
# Define project name here
PROJECT = $(PROJECT_OUT)
ifeq ($(PLAT),STM32F4)
# Imported source files and paths
include $(CHIBIOS)/os/ports/GCC/ARMCMx/STM32F4xx/port.mk
# Define linker script file here
LDSCRIPT= $(PORTLD)/STM32F407xG.ld
# platform specific flags
USE_OPT += -mfpu=fpv4-sp-d16 -mhard-float -fsingle-precision-constant
endif
ifeq ($(PLAT),STM32F1)
# Imported source files and paths
include $(CHIBIOS)/os/ports/GCC/ARMCMx/STM32F1xx/port.mk
# Define linker script file here
ifeq ($(MCU_SIZE),MCU_768K_96K)
ifeq ($(BOOTLOADER),BOOTLOADER_NONE)
# NO bootloader
LDSCRIPT= $(PORTLD)/STM32F103xG_768K_96K.ld
else
# OTA bootloader
LDSCRIPT= $(PORTLD)/STM32F103xG_768K_96K_bootloader_ota.ld
endif
endif
ifeq ($(MCU_SIZE),MCU_1M_96K)
ifeq ($(BOOTLOADER),BOOTLOADER_NONE)
# NO bootloader
LDSCRIPT= $(PORTLD)/STM32F103xG_1M_96K.ld
else
# OTA bootloader
LDSCRIPT= $(PORTLD)/STM32F103xG_1M_96K_bootloader_ota.ld
endif
endif
# platform specific flags
USE_OPT += -DUSE_STDPERIPH_DRIVER -DSTM32F10X_XL -DUSE_STM3210E_EVAL -DVECT_TAB_FLASH
endif
include $(CHIBIOS)/os/kernel/kernel.mk
# C sources that can be compiled in ARM or THUMB mode depending on the global
# setting.
CSRC = $(PORTSRC) \
$(KERNSRC) \
$(CHIBIOS)/os/various/syscalls.c \
$(CHIBIOS)/os/various/evtimer.c
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
# setting.
CPPSRC =
# C sources to be compiled in ARM mode regardless of the global setting.
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
# option that results in lower performance and larger code size.
ACSRC =
# C++ sources to be compiled in ARM mode regardless of the global setting.
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
# option that results in lower performance and larger code size.
ACPPSRC =
# C sources to be compiled in THUMB mode regardless of the global setting.
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
# option that results in lower performance and larger code size.
TCSRC =
# C sources to be compiled in THUMB mode regardless of the global setting.
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
# option that results in lower performance and larger code size.
TCPPSRC =
# List ASM source files here
ASMSRC = $(PORTASM)
INCDIR = $(PORTINC) $(KERNINC) $(TESTINC) \
$(CHIBIOS)/os/various
#
# Project, sources and paths
##############################################################################
##############################################################################
# Compiler settings
#
ifeq ($(PLAT),STM32F4)
MCU = cortex-m4
endif
ifeq ($(PLAT),STM32F1)
MCU = cortex-m3
endif
#TRGT = arm-elf-
TRGT = arm-none-eabi-
CC = $(TRGT)gcc
CPPC = $(TRGT)g++
# Enable loading with g++ only if you need C++ runtime support.
# NOTE: You can use C++ even without C++ support if you are careful. C++
# runtime support makes code size explode.
LD = $(TRGT)gcc
#LD = $(TRGT)g++
CP = $(TRGT)objcopy
AS = $(TRGT)gcc -x assembler-with-cpp
OD = $(TRGT)objdump
HEX = $(CP) -O ihex
BIN = $(CP) -O binary
SIZE = $(TRGT)size
# ARM-specific options here
AOPT =
# THUMB-specific options here
TOPT = -mthumb -DTHUMB
# Define C warning options here
CWARN = -Wall -Wstrict-prototypes -Wunused-variable -Wunused-function
# Define C++ warning options here
CPPWARN = -Wall -Wunused-variable
#
# Compiler settings
##############################################################################
##############################################################################
# Start of default section
#
# List all default C defines here, like -D_DEBUG=1
DDEFS = -DGCC_ARMCM3 -DCHIBIOS -D$(PLAT) $(USER_DEFS)
# List all default ASM defines here, like -D_DEBUG=1
DADEFS =
# List all default directories to look for include files here
DINCDIR =
# List the default directory to look for the libraries here
DLIBDIR =
# List all default libraries here
DLIBS =
#
# End of default section
##############################################################################
##############################################################################
# Start of user section
#
# List all user C define here, like -D_DEBUG=1
UDEFS =
# Define ASM defines here
UADEFS =
# List all user directories here
UINCDIR =
# List the user directory to look for the libraries here
ULIBDIR =
# List all user libraries here
ULIBS = $(CHIBIOS)/econais/build/libwismart.a
#
# End of user defines
##############################################################################
ifeq ($(CONFIG),release)
DDEFS += -DLWIP_NOASSERT
USE_OPT += -DLIBWISMART_RELEASE
endif
ifeq ($(BOOTLOADER),BOOTLOADER_NONE)
DDEFS += -DLIBWISMART_BOOTLOADER_NONE
endif
ifeq ($(BOOTLOADER),BOOTLOADER_OTA)
DDEFS += -DLIBWISMART_BOOTLOADER_OTA
DDEFS += -DBOOLOADER_IMAGE_PAGES="(132)"
DDEFS += -DBOOTLOADER_MUTUAL_EEPROM_PAGE_INDEX="(BOOLOADER_IMAGE_PAGES + 0)"
DDEFS += -DBOOTLOADER_APP_PAGE_INDEX="(BOOLOADER_IMAGE_PAGES + 1)"
DDEFS += -DCORTEX_VTOR_INIT="(BOOTLOADER_APP_PAGE_INDEX * 2048)"
endif
ifeq ($(USE_UPNP),yes)
USE_OPT += -DLWIP_UPNP
endif
ifeq ($(USE_FWLIB),yes)
USE_OPT += -DUSE_STDPERIPH_DRIVER
ifeq ($(PLAT),STM32F4)
USE_OPT += -DSTM32F4XX
USE_OPT += -DUSE_STM324xG_EVAL
USE_OPT += -DMEDIA_USB_KEY
USE_OPT += -DUSB_LOCK
USE_OPT += -DMII_MODE
endif
endif
ifeq ($(PLAT),STM32F4)
#include USB Host files
include $(CHIBIOS)/stm32f4Driver/usb_key.mk
include $(CHIBIOS)/stm32f4Driver/usb_key_include.mk
CSRC += $(USB_PROJECT_SRC)
INCDIR += $(USB_PROJECT_INC)
#include stm library
include $(CHIBIOS)/stm32f4Library/stm32f4Library.mk
CSRC += $(STM_LIBRARY_SRC)
INCDIR += $(STM_LIBRARY_INC)
#include stm drivers
include $(CHIBIOS)/stm32f4Driver/stm32f4Driver.mk
CSRC += $(STM_DRIVER_ETHERNET_SRC)
INCDIR += $(STM_DRIVER_ETHERNET_INC)
#CSRC += $(STM_DRIVER_EVAL_SRC)
INCDIR += $(STM_DRIVER_EVAL_INC)
#include fatfs
include $(CHIBIOS)/externalModules/fatfs.mk
CSRC += $(FATFS_SRC)
INCDIR += $(FATFS_INC)
endif
ifeq ($(PLAT),STM32F1)
#include stm library
include $(CHIBIOS)/econais/STM32_Libs/F1/stm32f1Library.mk
INCDIR += $(STM_LIBRARY_INC)
ifeq ($(USE_USB_DEVICE),yes)
#include stm32f1 FS USB Device driver and more stm drivers
include $(CHIBIOS)/stm32f1Driver/stm32f1Driver.mk
USE_OPT += -DUSE_USB_DEVICE
CSRC += $(STM_DRIVER_FS_USB_DEVICE_SRC)
INCDIR += $(STM_DRIVER_FS_USB_DEVICE_INC)
CSRC += $(STM_DRIVER_EVAL_SRC)
INCDIR += $(STM_DRIVER_EVAL_INC)
INCDIR += $(STM_DRIVER_EVAL_INC)
endif
endif
##############################################################################
# include files the src code is inside of .a file
#include lwip
ifeq ($(LWIP),v140)
include $(CHIBIOS)/externalModules/lwip_v14/lwip_include.mk
endif
ifeq ($(LWIP),v141)
include $(CHIBIOS)/externalModules/lwip_v141/lwip_include.mk
endif
INCDIR += $(LWIP_INC)
#include econais
INCDIR += $(CHIBIOS)/econais/
INCDIR += $(CHIBIOS)/econais/inc/$(PLAT)
##########
#include main
CSRC += $(USER_SRC)
INCDIR += $(USER_INCDIR)
include $(CHIBIOS)/os/ports/GCC/ARMCMx/rules.mk
EXTERNAL:
ifneq ($(PLAT),$(LIB_PLAT))
$(error The target platform of the libwimart is different from the target platform of application. $(PLAT)-$(LIB_PLAT))
endif