1 # Version of GCC used for Wirepas testing
2 GCC_TESTED_VERSION := 10.2.1
4 # Minimum binaries version required by this SDK version
5 MIN_BOOTLOADER_VERSION := 7
6 MIN_STACK_VERSION := 5.3.0.0
10 INCLUDES := -I$(SDK_PATH)
12 # General SDK folder structure
15 HAL_API_PATH := mcu/hal_api/
16 WP_LIB_PATH := libraries/
17 GLOBAL_BUILD := build/
19 BOARDS_PATH_INTERNAL := board_internal/
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
28 LDFLAGS := -Wl,--gc-sections
30 # include global config file
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),)
40 python=$(python_interpreter)
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)
48 # Display a message if python version is 2.
49 VERSION := $(shell $(python) tools/check_python.py)
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 ***********************************************************************)
62 # Prefix for Arm tools
63 PREFIX := $(arm_toolchain)arm-none-eabi-
68 OBJCOPY := $(PREFIX)objcopy
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
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 ***********************************************************************)
91 # List of available boards found under board/
92 AVAILABLE_BOARDS := $(patsubst $(BOARDS_PATH)%/,%,$(sort $(dir $(wildcard $(BOARDS_PATH)*/.))))
94 # Generic name of stack
95 FIRMWARE_NAME := wpc_stack
97 ifeq ($(target_board),)
98 $(error No board defined, please use target_board=... on your command line. Available boards are: $(AVAILABLE_BOARDS))
101 BOARD_FOLDER := $(BOARDS_PATH)$(target_board)
103 ifeq (,$(wildcard $(BOARD_FOLDER)))
104 $(error Board $(target_board) doesn't exist. Available boards are: $(AVAILABLE_BOARDS))
108 BOARD_CONFIG := $(BOARD_FOLDER)/config.mk
110 # Include board specific config
111 -include $(BOARD_CONFIG)
113 # Include makefile for mcu family
114 -include $(MCU_PATH)$(MCU_FAMILY)/makefile
116 # Folder for Wirepas stack binary image
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)
124 MCU_UPPER=$(shell echo $(MCU) | tr a-z A-Z)
125 CFLAGS += -D$(MCU_UPPER)
127 CFLAGS += -march=$(ARCH)
129 INCLUDES += -I$(MCU_PATH)common/cmsis -I$(BOARD_FOLDER)
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)/
135 APP_SRCS_PATH := $(wildcard $(APP_POSSIBLE_FOLDER))
136 ifeq (,$(wildcard $(APP_SRCS_PATH)))
137 $(error App $(app_name) doesn't exist)
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)
146 APP_CONFIG_FILE = $(app_config).mk
147 # Modify app_name for build folder
148 APP_NAME := $(app_name)_$(app_config)
151 APP_CONFIG = $(APP_SRCS_PATH)$(APP_CONFIG_FILE)
152 ifeq (,$(wildcard $(APP_CONFIG)))
153 $(error Config file $(APP_CONFIG) doesn't exist)
156 # Include app specific config
157 include $(APP_CONFIG)
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/
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
173 STACK_HEX := $(BUILDPREFIX_STACK)$(FIRMWARE_NAME).hex
175 APP_HEX := $(BUILDPREFIX_APP)$(APP_NAME).hex
177 mac_profile?=ism_24_ghz