forked from proactivity-lab-study/esw-digital-sensor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
208 lines (161 loc) · 8.09 KB
/
Makefile
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
# This is the main makefile for digi-sensor firmware
# _______________________ User overridable configuration _______________________
PROJECT_NAME ?= digi-sensor
VERSION_MAJOR ?= 1
VERSION_MINOR ?= 0
VERSION_PATCH ?= 0
VERSION_DEVEL ?= "-dev"
# No bootloader, app starts at 0
APP_START = 0
# Common build options - some of these should be moved to targets/boards
CFLAGS += -Wall -std=c99
CFLAGS += -ffunction-sections -fdata-sections -ffreestanding -fsingle-precision-constant -Wstrict-aliasing=0
CFLAGS += -DconfigUSE_TICKLESS_IDLE=0
CFLAGS += -D__START=main -D__STARTUP_CLEAR_BSS
CFLAGS += -DVTOR_START_LOCATION=$(APP_START)
LDFLAGS += -nostartfiles -Wl,--gc-sections -Wl,--relax -Wl,-Map=$(@:.elf=.map),--cref -Wl,--wrap=atexit -specs=nosys.specs
LDLIBS += -lgcc -lm
INCLUDES += -Xassembler -I$(BUILD_DIR) -I.
# The CMSIS RTOS2 wrapper for FreeRTOS now requires this flag to actually import the components
CFLAGS += -D_RTE_=1
# If set, disables asserts and debugging, enables optimization
RELEASE_BUILD ?= 0
# Set the lll verbosity base level
CFLAGS += -DBASE_LOG_LEVEL=0xFFFF # Everything
#CFLAGS += -DBASE_LOG_LEVEL=0 # Nothing
#CFLAGS += -DBASE_LOG_LEVEL=LOG_INFO1
#CFLAGS += -DBASE_LOG_LEVEL=0x0088 # (LOG_DEBUG1 | LOG_INFO1)
# Enable debug messages
VERBOSE ?= 0
# Disable info messages
#SILENT ?= 1
# This project contains several Makefiles that reference the project root
ROOT_DIR ?= $(abspath ../..)
ZOO ?= $(ROOT_DIR)/zoo
# Destination for build results
BUILD_BASE_DIR ?= build
# Mark the default target
DEFAULT_BUILD_TARGET ?= $(PROJECT_NAME)
# Configure how image is programmed to target device
PROGRAM_IMAGE ?= $(BUILD_DIR)/$(PROJECT_NAME).bin
PROGRAM_DEST_ADDR ?= $(APP_START)
# Silabs SDK location and version, due to licensing terms, the SDK is not
# distributed with this project and must be installed with Simplicity Studio.
# The variable needs to point at the subdirectory with the version number, set
# it in Makefile.private or through the environment.
SILABS_SDKDIR ?= $(HOME)/SimplicityStudio_v5/developer/sdks/gecko_sdk_suite/v3.2
# Pull in the developer's private configuration overrides and settings
-include Makefile.private
# _______________________ Non-overridable configuration _______________________
BUILD_DIR = $(BUILD_BASE_DIR)/$(BUILD_TARGET)
BUILDSYSTEM_DIR := $(ZOO)/thinnect.node-buildsystem/make
PLATFORMS_DIRS := $(ZOO)/thinnect.node-buildsystem/make $(ZOO)/thinnect.dev-platforms/make
PHONY_GOALS := all clean
TARGETLESS_GOALS += clean
UUID_APPLICATION := d709e1c5-496a-4d31-8957-f389d7fdbb71
VERSION_BIN := $(shell printf "%02X" $(VERSION_MAJOR))$(shell printf "%02X" $(VERSION_MINOR))$(shell printf "%02X" $(VERSION_PATCH))
VERSION_STR := "$(VERSION_MAJOR).$(VERSION_MINOR).$(VERSION_PATCH)"$(VERSION_DEVEL)
SW_MAJOR_VERSION := $(VERSION_MAJOR)
SW_MINOR_VERSION := $(VERSION_MINOR)
SW_PATCH_VERSION := $(VERSION_PATCH)
BUILD_TIMESTAMP := $(shell date '+%s')
IDENT_TIMESTAMP := $(BUILD_TIMESTAMP)
# NODE_PLATFORM_DIR is used by targets to add components to INCLUDES and SOURCES
NODE_PLATFORM_DIR := $(ZOO)/thinnect.node-platform
# ______________ Build components - sources and includes _______________________
SOURCES += app_main.c \
i2c_handler.c \
gpio_handler.c \
mma8653fc_driver.c \
# FreeRTOS
FREERTOS_DIR ?= $(ZOO)/FreeRTOS-Kernel
FREERTOS_INC = -I$(FREERTOS_DIR)/include \
-I$(ZOO)/thinnect.cmsis-freertos/CMSIS_5/CMSIS/RTOS2/Include \
-I$(ZOO)/thinnect.cmsis-freertos/CMSIS-FreeRTOS/CMSIS/RTOS2/FreeRTOS/Include \
-I$(ZOO)/thinnect.cmsis-freertos/$(MCU_ARCH)
FREERTOS_SRC = $(wildcard $(FREERTOS_DIR)/*.c) \
$(ZOO)/thinnect.cmsis-freertos/CMSIS-FreeRTOS/CMSIS/RTOS2/FreeRTOS/Source/cmsis_os2.c
INCLUDES += $(FREERTOS_PORT_INC) $(FREERTOS_INC)
SOURCES += $(FREERTOS_PORT_SRC) $(FREERTOS_SRC)
# CMSIS_CONFIG_DIR is used to add default CMSIS and FreeRTOS configs to INCLUDES
CMSIS_CONFIG_DIR ?= $(ZOO)/thinnect.cmsis-freertos/$(MCU_ARCH)/config
# Silabs EMLIB, RAIL, radio
INCLUDES += \
-I$(SILABS_SDKDIR)/hardware/kit/common/drivers \
-I$(SILABS_SDKDIR)/platform/halconfig/inc/hal-config \
-I$(SILABS_SDKDIR)/platform/emlib/inc \
# Sources for dependencies and Silabs libraries
SOURCES += \
$(SILABS_SDKDIR)/hardware/kit/common/drivers/retargetserial.c \
$(SILABS_SDKDIR)/hardware/kit/common/drivers/retargetio.c \
$(SILABS_SDKDIR)/platform/emlib/src/em_system.c \
$(SILABS_SDKDIR)/platform/emlib/src/em_core.c \
$(SILABS_SDKDIR)/platform/emlib/src/em_emu.c \
$(SILABS_SDKDIR)/platform/emlib/src/em_cmu.c \
$(SILABS_SDKDIR)/platform/emlib/src/em_rmu.c \
$(SILABS_SDKDIR)/platform/emlib/src/em_gpio.c \
$(SILABS_SDKDIR)/platform/emlib/src/em_usart.c \
$(SILABS_SDKDIR)/platform/emlib/src/em_msc.c \
$(SILABS_SDKDIR)/platform/emlib/src/em_timer.c \
$(SILABS_SDKDIR)/platform/emlib/src/em_i2c.c
# logging
CFLAGS += -DLOGGER_FWRITE
SOURCES += $(NODE_PLATFORM_DIR)/silabs/logger_fwrite.c
SOURCES += $(ZOO)/thinnect.lll/logging/loggers_ext.c
INCLUDES += -I$(ZOO)/thinnect.lll/logging
# device signature
INCLUDES += -I$(ZOO)/thinnect.device-signature/signature \
-I$(ZOO)/thinnect.device-signature/area
SOURCES += $(ZOO)/thinnect.device-signature/signature/DeviceSignature.c \
$(ZOO)/thinnect.device-signature/area/silabs/SignatureArea.c
# Generally useful external tools
INCLUDES += -I$(ZOO)/lammertb.libcrc/include \
-I$(ZOO)/jtbr.endianness \
-I$(ZOO)/graphitemaster.incbin
SOURCES += $(ZOO)/lammertb.libcrc/src/crcccitt.c
# platform stuff - watchdog, io etc...
INCLUDES += -I$(NODE_PLATFORM_DIR)/include
# ------------------------------------------------------------------------------
# Pull in the grunt work
include $(BUILDSYSTEM_DIR)/Makerules
$(call passVarToCpp,CFLAGS,VERSION_MAJOR)
$(call passVarToCpp,CFLAGS,VERSION_MINOR)
$(call passVarToCpp,CFLAGS,VERSION_PATCH)
$(call passVarToCpp,CFLAGS,VERSION_STR)
$(call passVarToCpp,CFLAGS,SW_MAJOR_VERSION)
$(call passVarToCpp,CFLAGS,SW_MINOR_VERSION)
$(call passVarToCpp,CFLAGS,SW_PATCH_VERSION)
$(call passVarToCpp,CFLAGS,IDENT_TIMESTAMP)
UUID_APPLICATION_BYTES = $(call uuidToCstr,$(UUID_APPLICATION))
$(call passVarToCpp,CFLAGS,UUID_APPLICATION_BYTES)
$(call passVarToCpp,CFLAGS,BASE_LOG_LEVEL)
# _______________________________ Project rules _______________________________
all: $(BUILD_DIR)/$(PROJECT_NAME).bin
# header.bin should be recreated if a build takes place
$(OBJECTS): $(BUILD_DIR)/header.bin
$(BUILD_DIR)/$(PROJECT_NAME).elf: Makefile | $(BUILD_DIR)
$(BUILD_DIR)/header.bin: Makefile | $(BUILD_DIR)
$(call pInfo,Creating application header block [$@])
$(HEADEREDIT) -c -v softtype,1 -v firmaddr,$(APP_START) -v firmsizemax,$(APP_MAX_LEN) \
-v version,$(VERSION_STR) -v versionbin,$(VERSION_BIN) \
-v uuid,$(UUID_BOARD) -v uuid2,$(UUID_PLATFORM) -v uuid3,$(UUID_APPLICATION) \
-v timestamp,$(BUILD_TIMESTAMP) \
-v name,$(PROJECT_NAME) \
-v size -v crc "$@"
$(BUILD_DIR)/$(PROJECT_NAME).elf: $(OBJECTS)
$(call pInfo,Linking [$@])
$(HIDE_CMD)$(CC) $(CFLAGS) $(INCLUDES) $(OBJECTS) $(LDLIBS) $(LDFLAGS) -o $@
$(BUILD_DIR)/$(PROJECT_NAME).bin: $(BUILD_DIR)/$(PROJECT_NAME).elf
$(call pInfo,Exporting [$@])
$(HIDE_CMD)$(TC_SIZE) --format=Berkeley $<
$(HIDE_CMD)$(TC_OBJCOPY) --strip-all -O binary "$<" "$@"
$(HIDE_CMD)$(HEADEREDIT) -v size -v crc $@
$(PROJECT_NAME): $(BUILD_DIR)/$(PROJECT_NAME).bin
# _______________________________ Utility rules ________________________________
$(BUILD_DIR):
$(call pInfo,Creating [$@])
@mkdir -p "$@"
clean:
$(call pInfo,Nuking everything in [$(BUILD_BASE_DIR)])
@-rm -rf "$(BUILD_BASE_DIR)"
.PHONY: $(PHONY_GOALS)