Statistics
| Branch: | Tag: | Revision:

amiro-os / modules / STM32F4Discovery / Makefile @ 8be006e0

History | View | Annotate | Download (11.624 KB)

1 07ff44a7 Thomas Schöpping
################################################################################
2
# AMiRo-OS is an operating system designed for the Autonomous Mini Robot       #
3
# (AMiRo) platform.                                                            #
4 84f0ce9e Thomas Schöpping
# Copyright (C) 2016..2019  Thomas Schöpping et al.                            #
5 07ff44a7 Thomas Schöpping
#                                                                              #
6
# This program is free software: you can redistribute it and/or modify         #
7
# it under the terms of the GNU General Public License as published by         #
8
# the Free Software Foundation, either version 3 of the License, or            #
9
# (at your option) any later version.                                          #
10
#                                                                              #
11
# This program is distributed in the hope that it will be useful,              #
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of               #
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the                #
14
# GNU General Public License for more details.                                 #
15
#                                                                              #
16
# You should have received a copy of the GNU General Public License            #
17
# along with this program.  If not, see <http://www.gnu.org/licenses/>.        #
18
#                                                                              #
19
# This research/work was supported by the Cluster of Excellence Cognitive      #
20
# Interaction Technology 'CITEC' (EXC 277) at Bielefeld University, which is   #
21
# funded by the German Research Foundation (DFG).                              #
22
################################################################################
23
24
25
26
################################################################################
27
# Build global options                                                         #
28
# NOTE: Can be overridden externally.                                          #
29
#                                                                              #
30
31
# Compiler options here.
32
ifeq ($(USE_OPT),)
33
  USE_OPT = -O2 -fomit-frame-pointer -falign-functions=16 -fstack-usage
34
endif
35
36
# C specific options here (added to USE_OPT).
37
ifeq ($(USE_COPT),)
38
  USE_COPT = -std=c11
39
endif
40
41
# C++ specific options here (added to USE_OPT).
42
ifeq ($(USE_CPPOPT),)
43
  USE_CPPOPT = -fno-rtti -std=c++17
44
endif
45
46
# Enable this if you want the linker to remove unused code and data
47
ifeq ($(USE_LINK_GC),)
48
  USE_LINK_GC = yes
49
endif
50
51
# Linker extra options here.
52
ifeq ($(USE_LDOPT),)
53
  USE_LDOPT =
54
endif
55
56
# Enable this if you want link time optimizations (LTO)
57
ifeq ($(USE_LTO),)
58
  USE_LTO = yes
59
endif
60
61
# If enabled, this option allows to compile the application in THUMB mode.
62
ifeq ($(USE_THUMB),)
63
  USE_THUMB = yes
64
endif
65
66
# Enable this if you want to see the full log while compiling.
67
ifeq ($(USE_VERBOSE_COMPILE),)
68
  USE_VERBOSE_COMPILE = no
69
endif
70
71
# If enabled, this option makes the build process faster by not compiling
72
# modules not used in the current configuration.
73
ifeq ($(USE_SMART_BUILD),)
74
  USE_SMART_BUILD = no
75
endif
76
77
#                                                                              #
78
# Build global options                                                         #
79
################################################################################
80
81
################################################################################
82
# Architecture or project specific options                                     #
83
#                                                                              #
84
85
# Stack size to be allocated to the Cortex-M process stack. This stack is
86
# the stack used by the main() thread.
87
ifeq ($(USE_PROCESS_STACKSIZE),)
88
  USE_PROCESS_STACKSIZE = 0x400
89
endif
90
91
# Stack size to the allocated to the Cortex-M main/exceptions stack. This
92
# stack is used for processing interrupts and exceptions.
93
ifeq ($(USE_EXCEPTIONS_STACKSIZE),)
94
  USE_EXCEPTIONS_STACKSIZE = 0x400
95
endif
96
97
# Enables the use of FPU on Cortex-M4.
98
# Possible selections are:
99
#   no     - no FPU is used (probably equals 'soft')
100
#   soft   - does not use the FPU, thus all floating point operations are emulated
101
#   softfp - uses the FPU, but uses the integer registers only
102
#   hard   - uses the FPU and passes data via the FPU registers
103
ifeq ($(USE_FPU),)
104
  USE_FPU = softfp
105
endif
106
107
#                                                                              #
108
# Architecture or project specific options                                     #
109
################################################################################
110
111
################################################################################
112
# Project, sources and paths                                                   #
113
#                                                                              #
114
115
# Define project name here
116
PROJECT := $(patsubst $(abspath $(dir $(abspath $(lastword $(MAKEFILE_LIST))))..)/%,%,$(abspath $(dir $(abspath $(lastword $(MAKEFILE_LIST))))))
117
118
# Imported source files and paths
119
include ../../kernel/kernel.mk
120
CHIBIOS := $(AMIROOS_KERNEL)
121
AMIROOS = ../..
122
# Licensing files
123
include $(CHIBIOS)/os/license/license.mk
124
# Startup files
125
include $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC/mk/startup_stm32f4xx.mk
126
# HAL-OSAL files
127
include $(CHIBIOS)/os/hal/hal.mk
128
include $(CHIBIOS)/os/hal/ports/STM32/STM32F4xx/platform.mk
129
include ./board.mk
130
include $(CHIBIOS)/os/hal/osal/rt/osal.mk
131
# RTOS files
132
include $(CHIBIOS)/os/rt/rt.mk
133
include $(CHIBIOS)/os/common/ports/ARMCMx/compilers/GCC/mk/port_v7m.mk
134
# Other files (optional).
135
include $(CHIBIOS)/test/lib/test.mk
136
include $(CHIBIOS)/test/rt/rt_test.mk
137
include $(CHIBIOS)/test/oslib/oslib_test.mk
138
# AMiRo-BLT files
139
include ../../bootloader/bootloader.mk
140
# AMiRo-LLD files
141
include ../../periphery-lld/periphery-lld.mk
142
# AMiRo-OS files
143
include ../modules.mk
144
include $(AMIROOS)/core/core.mk
145
include $(AMIROOS)/unittests/unittests.mk
146
147
# Define linker script file here
148
LDSCRIPT= $(BOARDLD)/STM32F407xG.ld
149
150
# C sources that can be compiled in ARM or THUMB mode depending on the global
151
# setting.
152
CSRC = $(LICSRC) \
153
       $(STARTUPSRC) \
154
       $(KERNSRC) \
155
       $(PORTSRC) \
156
       $(OSALSRC) \
157
       $(HALSRC) \
158
       $(PLATFORMSRC) \
159
       $(BOARDSRC) \
160
       $(MODULESCSRC) \
161
       $(TESTSRC) \
162
       $(PERIPHERYLLDCSRC) \
163
       $(AMIROOSCORECSRC) \
164
       $(UNITTESTSCSRC) \
165
       $(CHIBIOS)/os/various/evtimer.c \
166
       $(CHIBIOS)/os/various/syscalls.c \
167
       $(CHIBIOS)/os/hal/lib/streams/chprintf.c \
168
       module.c \
169
       $(APPSCSRC)
170
171
# C++ sources that can be compiled in ARM or THUMB mode depending on the global
172
# setting.
173
CPPSRC = $(AMIROOSCORECPPSRC) \
174
         $(APPSCPPSRC)
175
176
# C sources to be compiled in ARM mode regardless of the global setting.
177
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
178
#       option that results in lower performance and larger code size.
179
ACSRC = $(APPSACSRC)
180
181
# C++ sources to be compiled in ARM mode regardless of the global setting.
182
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
183
#       option that results in lower performance and larger code size.
184
ACPPSRC = $(APPSACPPSRC)
185
186
# C sources to be compiled in THUMB mode regardless of the global setting.
187
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
188
#       option that results in lower performance and larger code size.
189
TCSRC = $(APPSTCSRC)
190
191
# C sources to be compiled in THUMB mode regardless of the global setting.
192
# NOTE: Mixing ARM and THUMB mode enables the -mthumb-interwork compiler
193
#       option that results in lower performance and larger code size.
194
TCPPSRC = $(APPSTCPPSRC)
195
196
# List ASM source files here
197
ASMSRC = $(APPSASMSRC)
198
ASMXSRC = $(STARTUPASM) \
199
          $(PORTASM) \
200
          $(OSALASM) \
201
          $(APPSASMXSRC)
202
203
INCDIR = $(LICINC) \
204
         $(STARTUPINC) \
205
         $(KERNINC) \
206
         $(PORTINC) \
207
         $(OSALINC) \
208
         $(HALINC) \
209
         $(PLATFORMINC) \
210
         $(BOARDINC) \
211
         $(MODULESINC) \
212
         $(TESTINC) \
213
         $(BOOTLOADERINC) \
214
         $(CHIBIOS)/os/hal/lib/streams \
215
         $(PERIPHERYLLDINC) \
216
         $(AMIROOS) \
217
         $(AMIROOSCOREINC) \
218
         $(UNITTESTSINC) \
219
         $(APPSINC)
220
221
#                                                                              #
222
# Project, sources and paths                                                   #
223
################################################################################
224
225
################################################################################
226
# Compiler settings                                                            #
227
# NOTE: Some can be overridden externally.                                     #
228
#                                                                              #
229
230
MCU  = cortex-m4
231
232
#TRGT = arm-elf-
233
TRGT = arm-none-eabi-
234
CC   = $(TRGT)gcc
235
CPPC = $(TRGT)g++
236
# Enable loading with g++ only if you need C++ runtime support.
237
# NOTE: You can use C++ even without C++ support if you are careful. C++
238
#       runtime support makes code size explode.
239
LD   = $(TRGT)gcc
240
#LD   = $(TRGT)g++
241
CP   = $(TRGT)objcopy
242
AS   = $(TRGT)gcc -x assembler-with-cpp
243
AR   = $(TRGT)ar
244
OD   = $(TRGT)objdump
245
SZ   = $(TRGT)size
246
HEX  = $(CP) -O ihex
247
BIN  = $(CP) -O binary
248
SREC = $(CP) -O srec --srec-len=248
249
250
# ARM-specific options here
251
ifeq ($(AOPT),)
252
  AOPT =
253
endif
254
255
# THUMB-specific options here
256
ifeq ($(TOPT),)
257
  TOPT = -mthumb -DTHUMB
258
endif
259
260
# Define C warning options here
261
ifeq ($(CWARN),)
262
  CWARN = -Wall -Wextra -Wundef -Wstrict-prototypes
263
endif
264
265
# Define C++ warning options here
266
ifeq ($(CPPWARN),)
267
  CPPWARN = -Wall -Wextra -Wundef
268
endif
269
270
#                                                                              #
271
# Compiler settings                                                            #
272
################################################################################
273
274
################################################################################
275
# Start of user section                                                        #
276
#                                                                              #
277
278
# List all user C define here, like -D_DEBUG=1
279
UDEFS +=
280
281
# Define ASM defines here
282
UADEFS +=
283
284
# List all user directories here
285
UINCDIR +=
286
287
# List the user directory to look for the libraries here
288
ULIBDIR +=
289
290
# List all user libraries here
291
ULIBS +=
292
293
#                                                                              #
294
# End of user defines                                                          #
295
################################################################################
296
297 2c89d7e2 Thomas Schöpping
################################################################################
298
# Start of targets section                                                     #
299
#                                                                              #
300 07ff44a7 Thomas Schöpping
301 2c89d7e2 Thomas Schöpping
# all and its dependencies
302
BUILDDIR = ./build
303 07ff44a7 Thomas Schöpping
RULESPATH = $(CHIBIOS)/os/common/startup/ARMCMx/compilers/GCC
304
include $(RULESPATH)/rules.mk
305
306 2c89d7e2 Thomas Schöpping
# flash
307 07ff44a7 Thomas Schöpping
include $(AMIROOS)/bootloader/bootloader.mk
308
309 2c89d7e2 Thomas Schöpping
flash: $(BUILDDIR)/$(PROJECT).elf
310 07ff44a7 Thomas Schöpping
	openocd -f interface/stlink-v2-1.cfg -c "set WORKAREASIZE 0x2000" -f target/stm32f4x.cfg -c "program build/$(PROJECT).elf verify reset exit"
311
312 2c89d7e2 Thomas Schöpping
#                                                                              #
313
# End of targets section                                                       #
314
################################################################################
315