-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile.include
123 lines (102 loc) · 3.53 KB
/
Makefile.include
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
MCUFIRMWAREBASE := $(realpath $(dir $(lastword $(MAKEFILE_LIST))))
APPDIR := $(CURDIR)
EXTERNAL_BOARD_DIRS ?= $(MCUFIRMWAREBASE)/boards/
LAST_MAKEFILEDIR = $(realpath $(dir $(lastword $(MAKEFILE_LIST))))
RIOTBASE ?= $(MCUFIRMWAREBASE)/../RIOT/
BUILD_DIR = $(BINDIR)/build
PKGDIRBASE = $(BUILD_DIR)/pkg
RIOTPKG ?= $(MCUFIRMWAREBASE)/pkg
# Function to check version
include $(MCUFIRMWAREBASE)/makefiles/version_check.mk.inc
# Create a symbolic for each package in RIOT
pkgs := $(foreach dir,$(wildcard $(RIOTBASE)/pkg/*/Makefile),$(subst Makefile,, $(dir)))
$(foreach pkg,$(pkgs), $(shell ln -sf $(pkg) $(RIOTPKG)/$(notdir $(pkg))))
# Development options
QUIET ?= 1
DEVELHELP ?= 1
THREAD_NAMES = 1
REMOTE_USER ?= root
define remote-flash-recipe
scp $(BINFILE) $(REMOTE_USER)@$(REMOTE_TARGET):/tmp/fw.bin
$(GDB) -nx -batch -ex "target extended-remote $(REMOTE_TARGET):3333" -ex "monitor reset halt" -ex "monitor flash write_image erase /tmp/fw.bin 0x08000000" -ex "monitor reset run"
endef
ifneq ($(REMOTE_TARGET),)
TERMPROG=ssh $(REMOTE_TARGET) picocom
TERMFLAGS=-q --imap lfcrlf -b $(BAUD) $(PORT)
flash-recipe = $(remote-flash-recipe)
endif
MCUFW_MODULE_DIRS = " \
motion_control \
motion_control/controllers \
motion_control/engines \
motion_control/filters \
motion_control/metas \
drivers \
lib \
planners \
platforms \
sys \
"
# All directories starting with 'shell_' are shell modules.
# List them to add their parent directory to EXTERNAL_MODULE_DIRS.
shell_module_dirs = $(wildcard $(MCUFW_MODULE_DIRS:%=$(MCUFIRMWAREBASE)/%/*/shell_*/.))
EXTERNAL_MODULE_DIRS += $(MCUFW_MODULE_DIRS:%=$(MCUFIRMWAREBASE)/%/) $(shell_module_dirs:%=%/..)
# Use C++20 by default
CXXEXFLAGS := $(filter-out -std=%, $(CXXEXFLAGS))
CXXEXFLAGS += -std=c++17
CXXEXFLAGS += -Wno-pedantic
CXXEXFLAGS += -Wno-cast-align
# Export mcu-firmware global variables
include $(MCUFIRMWAREBASE)/makefiles/global_vars.mk.inc
# Global project requirements
include $(MCUFIRMWAREBASE)/Makefile.dep
# RIOT Makefile include
include $(RIOTBASE)/Makefile.include
ifneq ($(wildcard $(APPDIR)/include/.*),)
INCLUDES += -I$(APPDIR)/include/
ifneq ($(CPU),native)
ifneq ($(wildcard $(APPDIR)/include/real/.*),)
INCLUDES += -I$(APPDIR)/include/real/
endif
else
ifneq ($(wildcard $(APPDIR)/include/simulation/.*),)
INCLUDES += -I$(APPDIR)/include/simulation/
endif
endif
endif
# mallinfo2 is only available on native architecture with glibc >=2.33, making mallinfo deprecated
mallinfo := mallinfo
ifeq ($(CPU),native)
GLIBC_VERSION := $(shell ldd --version | head -1 | awk '{print $$NF}')
ifeq ($(call version_ge,$(GLIBC_VERSION),2.33),TRUE)
mallinfo := mallinfo2
endif
endif
ifeq ($(mallinfo), mallinfo2)
CFLAGS += -D"MALLINFO=struct mallinfo2"
CFLAGS += -D"MALLINFO_FUNC()=mallinfo2()"
else
CFLAGS += -D"MALLINFO=struct mallinfo"
CFLAGS += -D"MALLINFO_FUNC()=mallinfo()"
endif
# Display only errors
CFLAGS += -DLOG_LEVEL=LOG_ERROR
# Activate asserts debug
CFLAGS += -DDEBUG_ASSERT_VERBOSE
# Link to librt for timer_* functions definitions
ifeq ($(CPU),native)
LINKFLAGS += -lrt
endif
# Using libstdcpp requires a larger ISR stack by default
ifeq (,$(findstring -DISR_STACKSIZE=,$(CFLAGS)))
CFLAGS += -DISR_STACKSIZE=2048
endif
# Main thread stack size
CFLAGS += -DTHREAD_STACKSIZE_MAIN=8192
# As RIOT Makefile.include is included, RAMSIZE can be computed for not native architectures
ifneq ($(CPU),native)
.DEFAULT_GOAL := world
endif
.PHONY: world
world: all
$(Q)$(MCUFIRMWAREBASE)/tools/fwsize.sh $(SIZE) $(ELFFILE) $(FLASHSIZE) $(RAM_LEN)