/
Makefile.chibios
309 lines (246 loc) · 8.16 KB
/
Makefile.chibios
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
#
# Copyright (C) 2013 AggieAir, A Remote Sensing Unmanned Aerial System for Scientific Applications
# Utah State University, http://aggieair.usu.edu/
#
# Michal Podhradsky (michal.podhradsky@aggiemail.usu.edu)
# Calvin Coopmans (c.r.coopmans@ieee.org)
#
# credits to ENAC team for initial work on ChibiOs and Paparazzi integration
#
# This file is part of paparazzi.
#
# paparazzi is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# paparazzi is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with paparazzi; see the file COPYING. If not, write to
# the Free Software Foundation, 59 Temple Place - Suite 330,
# Boston, MA 02111-1307, USA.
#
#
# This is the common Makefile for target using chibios
#
CHIBIOS = $(PAPARAZZI_SRC)/sw/ext/chibios
CHIBIOS_SPECIFIC_DIR = $(PAPARAZZI_SRC)/sw/airborne/boards/$(BOARD)/chibios
# Launch with "make Q=''" to get full command display
Q=@
#
# General rules
#
$(TARGET).srcsnd = $(notdir $($(TARGET).srcs))
$(TARGET).objso = $($(TARGET).srcs:%.c=$(OBJDIR)/%.o)
$(TARGET).objs = $($(TARGET).objso:%.S=$(OBJDIR)/%.o)
##############################################################################
# Build global options
# NOTE: Can be overridden externally.
#
# Compiler options here.
ifeq ($(USE_OPT),)
USE_OPT = -std=gnu99 -O2 -ggdb -fomit-frame-pointer -falign-functions \
-W -Wall
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),)
ifeq ($(Q),@)
USE_VERBOSE_COMPILE = no
else
USE_VERBOSE_COMPILE = yes
endif
endif
# Enable this if you really want to use the STM FWLib.
ifeq ($(USE_FWLIB),)
USE_FWLIB = no
endif
#
# Build global options
##############################################################################
#
# Architecture or project specific options
##############################################################################
##############################################################################
# Project, sources and paths
#
# Imported source files and paths
include $(CHIBIOS_SPECIFIC_DIR)/board.mk
include $(CHIBIOS)/os/hal/platforms/$(CHIBIOS_BOARD_PLATFORM)
include $(CHIBIOS)/os/hal/hal.mk
include $(CHIBIOS)/os/ports/GCC/$(CHIBIOS_BOARD_PORT)
include $(CHIBIOS)/os/kernel/kernel.mk
#include $(CHIBIOS)/test/test.mk
# Define linker script file here
LDSCRIPT= $(PORTLD)/$(CHIBIOS_BOARD_LINKER)
# Define linker script file here
#LDSCRIPT= $($(TARGET).LDSCRIPT)
# C sources that can be compiled in ARM or THUMB mode depending on the global
# setting.
CSRC = $(PORTSRC) \
$(KERNSRC) \
$(TESTSRC) \
$(HALSRC) \
$(PLATFORMSRC) \
$(BOARDSRC) \
$(CHIBIOS)/os/various/evtimer.c \
$(CHIBIOS)/os/various/syscalls.c \
$(CHIBIOS_BOARD_MAIN) \
$($(TARGET).srcs)
# 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) \
$(HALINC) $(PLATFORMINC) $(BOARDINC) \
$(CHIBIOS)/os/various $(CHIBIOS_SPECIFIC_DIR)
BUILDDIR := $(OBJDIR)
#
# Project, sources and paths
##############################################################################
##############################################################################
# Compiler settings
#
MCU ?= cortex-m3
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
# ARM-specific options here
AOPT =
# THUMB-specific options here
TOPT = -mthumb -DTHUMB
# Define C warning options here
CWARN = -Wall -Wextra -Wstrict-prototypes
# Define C++ warning options here
CPPWARN = -Wall -Wextra
#
# Compiler settings
##############################################################################
##############################################################################
# Start of default section
#
# List all default C defines here, like -D_DEBUG=1
DDEFS =
# 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 = -lm
# -lm needed to tell the compiler to use <math.h>
#
# End of default section
##############################################################################
##############################################################################
# Start of user section (extra libraries etc.)
#
# List all user C define here, like -D_DEBUG=1
#UDEFS =
UDEFS = $($(TARGET).CFLAGS)
# Define ASM defines here
UADEFS =
# List all user directories here
#UINCDIR =
UINCDIR = $(patsubst -I%,%,$(INCLUDES))
# List the user directory to look for the libraries here
ULIBDIR =
# List all user libraries here
ULIBS =
#
# End of user defines
##############################################################################
# TODO: remove these...
# Info messages
#$(info CHIBIOS = $(CHIBIOS))
#$(info PORTSRC = $(PORTSRC))
#$(info KERNSRC = $(KERNSRC))
#$(info TESTSRC = $(TESTSRC))
#$(info HALSRC = $(HALSRC))
#$(info PLATFORMSRC = $(PLATFORMSRC))
#$(info BOARDSRC = $(BOARDSRC))
$(info INCDIR = $(INCDIR))
$(info UINCDIR = $(UINCDIR))
$(info CSRC = $(CSRC))
$(info UDEFS = $(UDEFS))
#
# Include upload rules
##############################################################################
# Default upload using black magic probe
#ifndef FLASH_MODE
#FLASH_MODE = JTAG
#endif
# for now, no luftboot
ASSUMING_LUFTBOOT = "yes"
# Settings for GDB
# default port configuration for BMP
BMP_PORT = /dev/ttyACM0
GDB = $(shell which arm-none-eabi-gdb)
# Settings for OOCD
$(TARGET).OOCD_INTERFACE=flossjtag
OOCD_INTERFACE=flossjtag
OOCD = $(shell which openocd)
ifndef $(TARGET).OOCD_BOARD
OOCD_BOARD = lisa-m
else
OOCD_BOARD = $($(TARGET).OOCD_BOARD)
endif
###############################################################################
# Upload makefile
include $(PAPARAZZI_HOME)/conf/Makefile.stm32-upload
###############################################################################
ifeq ($(USE_FPU),yes)
USE_OPT += -mfloat-abi=hard -mfpu=fpv4-sp-d16 -fsingle-precision-constant
DDEFS += -DCORTEX_USE_FPU=TRUE
else
DDEFS += -DCORTEX_USE_FPU=FALSE
endif
# Compile
include $(CHIBIOS)/os/ports/GCC/ARMCMx/rules.mk