Wirepas SDK
makefile_common.mk
Go to the documentation of this file.
1include makefile_color.mk
2
3# Minimum binaries version required by this SDK version
4MIN_BOOTLOADER_VERSION := 7
5MIN_STACK_VERSION := 5.5.0.0
6
7# SDK itself
8SDK_PATH := .
9INCLUDES := -I$(SDK_PATH)
10
11build_directory?= build/
12board_directory?= board/
13
14# Manage verbosity
15# Command are prefixed by @(D) or @(DD)
16# By default all is silent
17D=@
18DD=@
19
20ifeq ($(V),2)
21# Explicitly print everything
22D=
23DD=
24else ifeq ($(V), 1)
25# Explicitly print level 1
26D=
27endif
28
29# General SDK folder structure
30API_PATH := api/
31UTIL_PATH := util/
32HAL_API_PATH := mcu/hal_api/
33WP_LIB_PATH := libraries/
34GLOBAL_BUILD := $(build_directory)
35BOARDS_PATH := $(board_directory)
36BOARDS_PATH_INTERNAL := board_internal/
37MCU_PATH := mcu/
38
39# General compiler flags (Define it before specific makefile in order to allow app to overwrite it)
40CFLAGS := -Wall -Werror -Wextra
41CFLAGS += -std=gnu99 -mthumb -nostartfiles -lgcc -lnosys -ggdb --specs=nano.specs
42CFLAGS += -Os -ffunction-sections -fdata-sections
43
44# C++ exceptions are not supported
45CFLAGS += -fno-exceptions -fno-unwind-tables -fno-asynchronous-unwind-tables
46
47# Flags for linker
48LDFLAGS := -Wl,--gc-sections -Wl,-L$(MCU_PATH)common/linker
49
50# include global config file
51-include config.mk
52
53# Check that a correct version of python is installed by trying to launch check_python
54# This script has python3 shebang so try it without specifying interpreter
55PYTHON_STATUS := $(shell tools/check_python.py > /dev/null 2>&1; echo $$?)
56ifneq ($(PYTHON_STATUS),0)
57ifeq ($(python_interpreter),)
58python=python
59else
60python=$(python_interpreter)
61endif
62# It looks like python3 cannot be found or does not exist as a cmd (windows)
63# Force the launch with python cmd
64PYTHON_STATUS := $(shell $(python) tools/check_python.py > /dev/null; echo $$?)
65ifneq ($(PYTHON_STATUS),0)
66$(error Cannot find a suitable python version. You can force the python interpreter from config.mk)
67endif
68# Display a message if python version is 2.
69VERSION := $(shell $(python) tools/check_python.py)
70ifeq ($(VERSION),2)
71$(warning ***********************************************************************)
72$(warning "SDK supports python3 and python2 but uses python3 by default.)
73$(warning "It looks like python3 is not installed on your system.)
74$(warning "Using the python2 fallback for now but python2 support will be removed in a future release.)
75$(warning ***********************************************************************)
76endif
77endif
78
79#
80# Tools
81#
82# Prefix for Arm tools
83PREFIX := $(arm_toolchain)arm-none-eabi-
84
85# Toolchain programs
86CC := $(PREFIX)gcc
87AR := $(PREFIX)ar
88OBJCOPY := $(PREFIX)objcopy
89RM := rm
90MV := mv
91CP := cp
92CAT := cat
93MKDIR := mkdir -p
94CMP := cmp -s
95SCRAT_GEN := $(python) tools/genscratchpad.py
96HEX_GEN := $(python) tools/genhex.py
97HEXTOOL := $(python) tools/hextool.py
98FMW_SEL := $(python) tools/firmware_selector.py
99BOOT_CONF := $(python) tools/bootloader_config.py
100BL_UPD_CONF := $(python) tools/bl_updater_config.py
101WIZARD := $(python) tools/sdk_wizard.py
102HEX2ARRAY32 := $(python) tools/hextoarray32.py
103MAKE := make
104
105# List of available boards found under board/
106AVAILABLE_BOARDS := $(patsubst $(BOARDS_PATH)%/,%,$(sort $(dir $(wildcard $(BOARDS_PATH)*/.))))
107
108# Generic name of stack
109FIRMWARE_NAME := wpc_stack
110
111ifeq (,$(filter clean_all,$(MAKECMDGOALS)))
112ifeq (,$(filter doxygen,$(MAKECMDGOALS)))
113ifeq ($(target_board),)
114$(error No board defined, please use target_board=... on your command line. Available boards are: $(AVAILABLE_BOARDS))
115endif
116endif
117endif
118
119BOARD_FOLDER := $(BOARDS_PATH)$(target_board)
120
121ifeq (,$(wildcard $(BOARD_FOLDER)))
122$(error Board $(target_board) doesn't exist. Available boards are: $(AVAILABLE_BOARDS))
123endif
124
125# Board config file
126BOARD_CONFIG := $(BOARD_FOLDER)/config.mk
127
128# Include board specific config
129-include $(BOARD_CONFIG)
130
131# Include makefile for mcu family
132-include $(MCU_PATH)$(MCU_FAMILY)/makefile
133
134# Folder for Wirepas stack binary image
135IMAGE_PATH := image/
136
137# Folder for compressed archives of binaries
138ARCHIVE_PATH := image/
139
140# Add new flags as board and mcu are known
141CFLAGS += -DTARGET_BOARD=$(target_board)
142CFLAGS += -DMCU=$(MCU)
143CFLAGS += -DMCU_SUB=$(MCU_SUB)
144
145MCU_UPPER=$(shell echo $(MCU) | tr a-z A-Z)
146CFLAGS += -D$(MCU_UPPER)
147
148CFLAGS += -march=$(ARCH)
149
150INCLUDES += -I$(MCU_PATH)common/cmsis -I$(BOARD_FOLDER)
151
152# Folder where the application sources are located (and config file)
153# Can be in different folders, try them one by one
154APP_POSSIBLE_FOLDER := source/*/$(app_name)/ source/$(app_name)/
155APP_POSSIBLE_FOLDER += $(app_extra_folder)/$(app_name)/
156
157APP_SRCS_PATH := $(wildcard $(APP_POSSIBLE_FOLDER))
158ifeq (,$(wildcard $(APP_SRCS_PATH)))
159$(error App $(app_name) doesn't exist)
160endif
161
162# Check if an alternative config is given
163ifeq ($(app_config),)
164APP_CONFIG_FILE = config.mk
165APP_NAME := $(app_name)
166else
167$(info Using alternate app config: $(app_config))
168APP_CONFIG_FILE = $(app_config).mk
169# Modify app_name for build folder
170APP_NAME := $(app_name)_$(app_config)
171endif
172
173APP_CONFIG = $(APP_SRCS_PATH)$(APP_CONFIG_FILE)
174ifeq (,$(wildcard $(APP_CONFIG)))
175$(error Config file $(APP_CONFIG) doesn't exist)
176endif
177
178# Include app specific config
179include $(APP_CONFIG)
180
181# Build prefixes
182BUILDPREFIX := $(GLOBAL_BUILD)$(target_board)/
183BUILDPREFIX_APP := $(BUILDPREFIX)$(APP_NAME)/
184# Stack is under an app specific folder as config may depend on app
185BUILDPREFIX_STACK := $(BUILDPREFIX_APP)stack/
186# Bootloader is under an app specific folder as config may depend on app (unlocked/locked)
187BUILDPREFIX_BOOTLOADER := $(BUILDPREFIX_APP)bootloader/
188BUILDPREFIX_TEST_BOOTLOADER := $(BUILDPREFIX_APP)bootloader_test/
189# Bootloader updater is under an app specific folder as it depends on bootloader
190BUILDPREFIX_BL_UPDATER := $(BUILDPREFIX_APP)bl_updater/
191# Board-specific files in archive are extracted here for processing
192BUILDPREFIX_IMAGE := $(BUILDPREFIX_APP)image/
193
194# Where to extract binaries from archive
195EXTRACT_PATH := $(BUILDPREFIX_IMAGE)
196
197# Where to search binaries from, in order
198FIRMWARE_PATH := $(EXTRACT_PATH):$(IMAGE_PATH)
199
200BOOTLOADER_HEX := $(BUILDPREFIX_BOOTLOADER)bootloader.hex
201BOOTLOADER_TEST_HEX := $(BUILDPREFIX_APP)bootloader_test/bootloader_test.hex
202BOOTLOADER_CONFIG_INI := $(BUILDPREFIX_APP)bootloader_full_config.ini
203
204BL_UPDATER_OLD_CONFIG_INI := $(BUILDPREFIX_BL_UPDATER)old_bootloader_config.ini
205BL_UPDATER_BUILD_VARIABLES_MK := $(BUILDPREFIX_BL_UPDATER)bl_updater_build_variables.mk
206BL_UPDATER_HEX := $(BUILDPREFIX_BL_UPDATER)bl_updater.hex
207
208STACK_HEX := $(BUILDPREFIX_STACK)$(FIRMWARE_NAME).hex
209STACK_CONF := $(BUILDPREFIX_STACK)$(FIRMWARE_NAME).conf
210
211APP_HEX := $(BUILDPREFIX_APP)$(APP_NAME).hex
212
213# Build-time make variables that depend on the selected configuration
214BUILD_VARIABLES_MK := $(BUILDPREFIX_APP)build_variables.mk
215
216# Files to track make command line parameters, to do a rebuild after any changes
217MAKE_PARAMS_FILE := $(BUILDPREFIX_APP)make_params.txt
218MAKE_PARAMS_TEMP_FILE := $(BUILDPREFIX_APP)make_params_temp.txt
219
220mac_profile?=ism_24_ghz