Wirepas SDK
makefile_common.mk
Go to the documentation of this file.
1 # Version of GCC used for Wirepas testing
2 GCC_TESTED_VERSION := 10.2.1
3 
4 # Minimum binaries version required by this SDK version
5 MIN_BOOTLOADER_VERSION := 7
6 MIN_STACK_VERSION := 5.3.0.0
7 
8 # SDK itself
9 SDK_PATH := .
10 INCLUDES := -I$(SDK_PATH)
11 
12 # General SDK folder structure
13 API_PATH := api/
14 UTIL_PATH := util/
15 HAL_API_PATH := mcu/hal_api/
16 WP_LIB_PATH := libraries/
17 GLOBAL_BUILD := build/
18 BOARDS_PATH := board/
19 BOARDS_PATH_INTERNAL := board_internal/
20 MCU_PATH := mcu/
21 
22 # General compiler flags (Define it before specific makefile in order to allow app to overwrite it)
23 CFLAGS := -Wall -Werror -Wextra
24 CFLAGS += -std=gnu99 -mthumb -nostartfiles -lgcc -lnosys -ggdb --specs=nano.specs
25 CFLAGS += -Os -ffunction-sections -fdata-sections
26 
27 # Flags for linker
28 LDFLAGS := -Wl,--gc-sections
29 
30 # include global config file
31 -include config.mk
32 
33 # Check that a correct version of python is installed by trying to launch check_python
34 # This script has python3 shebang so try it without specifying interpreter
35 PYTHON_STATUS := $(shell tools/check_python.py > /dev/null 2>&1; echo $$?)
36 ifneq ($(PYTHON_STATUS),0)
37 ifeq ($(python_interpreter),)
38 python=python
39 else
40 python=$(python_interpreter)
41 endif
42 # It looks like python3 cannot be found or does not exist as a cmd (windows)
43 # Force the launch with python cmd
44 PYTHON_STATUS := $(shell $(python) tools/check_python.py > /dev/null; echo $$?)
45 ifneq ($(PYTHON_STATUS),0)
46 $(error Cannot find a suitable python version. You can force the python interpreter from config.mk)
47 endif
48 # Display a message if python version is 2.
49 VERSION := $(shell $(python) tools/check_python.py)
50 ifeq ($(VERSION),2)
51 $(warning ***********************************************************************)
52 $(warning "SDK supports python3 and python2 but uses python3 by default.)
53 $(warning "It looks like python3 is not installed on your system.)
54 $(warning "Using the python2 fallback for now but python2 support will be removed in a future release.)
55 $(warning ***********************************************************************)
56 endif
57 endif
58 
59 #
60 # Tools
61 #
62 # Prefix for Arm tools
63 PREFIX := $(arm_toolchain)arm-none-eabi-
64 
65 # Toolchain programs
66 CC := $(PREFIX)gcc
67 AR := $(PREFIX)ar
68 OBJCOPY := $(PREFIX)objcopy
69 RM := rm
70 MV := mv
71 CP := cp
72 MKDIR := mkdir -p
73 SCRAT_GEN := $(python) tools/genscratchpad.py
74 HEX_GEN := $(python) tools/genhex.py
75 HEXTOOL := $(python) tools/hextool.py
76 FMW_SEL := $(python) tools/firmware_selector.py
77 BOOT_CONF := $(python) tools/bootloader_config.py
78 WIZARD := $(python) tools/sdk_wizard.py
79 HEX2ARRAY32 := $(python) tools/hextoarray32.py
80 MAKE := make
81 
82 # Check the toolchain version with GCC
83 GCC_VERSION := $(shell $(CC) -dumpversion)
84 ifneq ($(GCC_VERSION), $(findstring $(GCC_VERSION), $(GCC_TESTED_VERSION)))
85 $(warning ***********************************************************************)
86 $(warning "GCC version used is not the recommended and tested by Wirepas )
87 $(warning "Recommended version is : $(GCC_TESTED_VERSION))
88 $(warning ***********************************************************************)
89 endif
90 
91 # List of available boards found under board/
92 AVAILABLE_BOARDS := $(patsubst $(BOARDS_PATH)%/,%,$(sort $(dir $(wildcard $(BOARDS_PATH)*/.))))
93 
94 # Generic name of stack
95 FIRMWARE_NAME := wpc_stack
96 
97 ifeq ($(target_board),)
98 $(error No board defined, please use target_board=... on your command line. Available boards are: $(AVAILABLE_BOARDS))
99 endif
100 
101 BOARD_FOLDER := $(BOARDS_PATH)$(target_board)
102 
103 ifeq (,$(wildcard $(BOARD_FOLDER)))
104 $(error Board $(target_board) doesn't exist. Available boards are: $(AVAILABLE_BOARDS))
105 endif
106 
107 # Board config file
108 BOARD_CONFIG := $(BOARD_FOLDER)/config.mk
109 
110 # Include board specific config
111 -include $(BOARD_CONFIG)
112 
113 # Include makefile for mcu family
114 -include $(MCU_PATH)$(MCU_FAMILY)/makefile
115 
116 # Folder for Wirepas stack binary image
117 IMAGE_PATH := image/
118 
119 # Add new flags as board and mcu are known
120 CFLAGS += -DTARGET_BOARD=$(target_board)
121 CFLAGS += -DMCU=$(MCU)
122 CFLAGS += -DMCU_SUB=$(MCU_SUB)
123 
124 MCU_UPPER=$(shell echo $(MCU) | tr a-z A-Z)
125 CFLAGS += -D$(MCU_UPPER)
126 
127 CFLAGS += -march=$(ARCH)
128 
129 INCLUDES += -I$(MCU_PATH)common/cmsis -I$(BOARD_FOLDER)
130 
131 # Folder where the application sources are located (and config file)
132 # Can be in different folders, try them one by one
133 APP_POSSIBLE_FOLDER := source/*/$(app_name)/ source/$(app_name)/
134 
135 APP_SRCS_PATH := $(wildcard $(APP_POSSIBLE_FOLDER))
136 ifeq (,$(wildcard $(APP_SRCS_PATH)))
137 $(error App $(app_name) doesn't exist)
138 endif
139 
140 # Check if an alternative config is given
141 ifeq ($(app_config),)
142 $(info Using default app config: config.mk)
143 APP_CONFIG_FILE = config.mk
144 APP_NAME := $(app_name)
145 else
146 APP_CONFIG_FILE = $(app_config).mk
147 # Modify app_name for build folder
148 APP_NAME := $(app_name)_$(app_config)
149 endif
150 
151 APP_CONFIG = $(APP_SRCS_PATH)$(APP_CONFIG_FILE)
152 ifeq (,$(wildcard $(APP_CONFIG)))
153 $(error Config file $(APP_CONFIG) doesn't exist)
154 endif
155 
156 # Include app specific config
157 include $(APP_CONFIG)
158 
159 # Build prefixes
160 BUILDPREFIX := $(GLOBAL_BUILD)$(target_board)/
161 BUILDPREFIX_APP := $(BUILDPREFIX)$(APP_NAME)/
162 # Stack is under a app specific folder as config may depend on app
163 BUILDPREFIX_STACK := $(BUILDPREFIX_APP)stack/
164 # Bootloader is under a app specific folder as config may depend on app (unlocked/locked)
165 BUILDPREFIX_BOOTLOADER := $(BUILDPREFIX_APP)bootloader/
166 BUILDPREFIX_TEST_BOOTLOADER := $(BUILDPREFIX_APP)bootloader_test/
167 
168 BOOTLOADER_HEX := $(BUILDPREFIX_BOOTLOADER)bootloader.hex
169 BOOTLOADER_TEST_HEX := $(BUILDPREFIX_APP)bootloader_test/bootloader_test.hex
170 BOOTLOADER_UPDATER_HEX := $(BUILDPREFIX)bootloader_updater/bootloader_updater.hex
171 BOOTLOADER_UPDATER_DATA_BIN := $(BUILDPREFIX)bootloader_updater/bootloader_updater_data.bin
172 
173 STACK_HEX := $(BUILDPREFIX_STACK)$(FIRMWARE_NAME).hex
174 
175 APP_HEX := $(BUILDPREFIX_APP)$(APP_NAME).hex
176 
177 mac_profile?=ism_24_ghz