-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathMakefile
137 lines (113 loc) · 4.16 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
PROJECT_NAME := ultimate_base
TARGETS := ubase
OUTPUT_DIRECTORY := build
SDK_ROOT := /home/the_3d6/devtools/nrf/nRF5_SDK_14.1.0_1dda907
PROJ_DIR := .
$(OUTPUT_DIRECTORY)/ubase.out: \
LINKER_SCRIPT := ultimate_base_nrf52.ld
# Source files common to all targets
SRC_FILES += \
$(PROJ_DIR)/ultimate_base_main.c \
$(PROJ_DIR)/leds.c \
$(PROJ_DIR)/fast_radio.c \
$(PROJ_DIR)/timer_core.c \
$(PROJ_DIR)/uart_interface.c \
$(SDK_ROOT)/components/toolchain/gcc/gcc_startup_nrf52.S \
$(SDK_ROOT)/components/toolchain/system_nrf52.c \
$(SDK_ROOT)/components/boards/boards.c \
$(SDK_ROOT)/components/libraries/util/app_error.c \
$(SDK_ROOT)/components/libraries/util/app_error_weak.c \
$(SDK_ROOT)/components/libraries/util/app_util_platform.c \
$(SDK_ROOT)/components/libraries/util/nrf_assert.c \
$(SDK_ROOT)/components/libraries/strerror/nrf_strerror.c \
# Include folders common to all targets
INC_FOLDERS += \
$(SDK_ROOT)/components \
$(SDK_ROOT)/components/libraries/experimental_memobj \
$(SDK_ROOT)/components/libraries/experimental_section_vars \
$(SDK_ROOT)/components/toolchain \
$(SDK_ROOT)/components/libraries/util \
$(SDK_ROOT)/components/libraries/balloc \
$(SDK_ROOT)/components/libraries/experimental_log \
$(SDK_ROOT)/components/libraries/experimental_log/src \
$(PROJ_DIR) \
$(SDK_ROOT)/components/toolchain/gcc \
$(SDK_ROOT)/components/libraries/bsp \
$(SDK_ROOT)/components/drivers_nrf/nrf_soc_nosd \
config \
$(SDK_ROOT)/components/device \
$(SDK_ROOT)/components/boards \
$(SDK_ROOT)/components/drivers_nrf/delay \
$(SDK_ROOT)/components/toolchain/cmsis/include \
$(SDK_ROOT)/components/drivers_nrf/hal \
$(SDK_ROOT)/components/libraries/strerror \
# Libraries common to all targets
LIB_FILES += \
# Optimization flags
OPT = -O3
# Uncomment the line below to enable link time optimization
#OPT += -flto
# C flags common to all targets
CFLAGS += $(OPT)
CFLAGS += -DBOARD_PCA10040
CFLAGS += -DBSP_DEFINES_ONLY
CFLAGS += -DCONFIG_GPIO_AS_PINRESET
CFLAGS += -DNRF52
CFLAGS += -DNRF52832_XXAA
CFLAGS += -DNRF52_PAN_74
CFLAGS += -mcpu=cortex-m4
CFLAGS += -mthumb -mabi=aapcs
CFLAGS += -Wall
CFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
# keep every function in a separate section, this allows linker to discard unused ones
CFLAGS += -ffunction-sections -fdata-sections -fno-strict-aliasing
CFLAGS += -fno-builtin -fshort-enums
# C++ flags common to all targets
CXXFLAGS += $(OPT)
# Assembler flags common to all targets
ASMFLAGS += -g3
ASMFLAGS += -mcpu=cortex-m4
ASMFLAGS += -mthumb -mabi=aapcs
ASMFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
ASMFLAGS += -DBOARD_PCA10040
ASMFLAGS += -DBSP_DEFINES_ONLY
ASMFLAGS += -DCONFIG_GPIO_AS_PINRESET
ASMFLAGS += -DNRF52
ASMFLAGS += -DNRF52832_XXAA
ASMFLAGS += -DNRF52_PAN_74
# Linker flags
LDFLAGS += $(OPT)
LDFLAGS += -mthumb -mabi=aapcs -L $(TEMPLATE_PATH) -T$(LINKER_SCRIPT)
LDFLAGS += -mcpu=cortex-m4
LDFLAGS += -mfloat-abi=hard -mfpu=fpv4-sp-d16
# let linker dump unused sections
LDFLAGS += -Wl,--gc-sections
# use newlib in nano version
LDFLAGS += --specs=nano.specs
# Add standard libraries at the very end of the linker input, after all objects
# that may need symbols provided by these libraries.
LIB_FILES += -lc -lnosys -lm
.PHONY: default help
# Default target - first one defined
default: ubase
# Print all targets that can be built
help:
@echo following targets are available:
@echo ubase
@echo sdk_config - starting external tool for editing sdk_config.h
@echo flash - flashing binary
TEMPLATE_PATH := $(SDK_ROOT)/components/toolchain/gcc
include $(TEMPLATE_PATH)/Makefile.common
$(foreach target, $(TARGETS), $(call define_target, $(target)))
.PHONY: flash erase
# Flash the program
flash: $(OUTPUT_DIRECTORY)/ubase.hex
@echo Flashing: $<
nrfjprog -f nrf52 --program $< --sectorerase
nrfjprog -f nrf52 --reset
erase:
nrfjprog -f nrf52 --eraseall
SDK_CONFIG_FILE := config/sdk_config.h
CMSIS_CONFIG_TOOL := $(SDK_ROOT)/external_tools/cmsisconfig/CMSIS_Configuration_Wizard.jar
sdk_config:
java -jar $(CMSIS_CONFIG_TOOL) $(SDK_CONFIG_FILE)