-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
51 lines (32 loc) · 1.31 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
# Makefile to build the boilerplate
#
# The Makefile is a helper construct for Eclipse usage.
#
BUILD_DIR := _build
PROJECT := register-access
CMAKE_FLAGS += -DPROJECT=$(PROJECT)
CMAKE_FLAGS += -DTOOLCHAIN_PATH=$(wildcard ~/bin/llvm-arm-none-eabi/bin)
.ONESHELL:
.PHONY: clean
clean:
ninja -C $(BUILD_DIR) -v clean
.PHONY: clean-build
clean-build:
rm -rf $(BUILD_DIR)
.PHONY: all
all: $(BUILD_DIR)/$(PROJECT).elf
@echo "--------------------------"
@arm-none-eabi-size -Ax $(BUILD_DIR)/$(PROJECT).elf | awk '{size=strtonum($$2); addr=strtonum($$3); if (addr>=0x20000000 && addr<0x20040000) ram += size; if (addr>0 && addr<0x10000000) rom += size; } END {print "Flash: " rom " RAM: " ram}'
@echo "--------------------------"
.PHONY: cmake-create-debug
cmake-create-debug:
cmake -B $(BUILD_DIR) -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=1 $(CMAKE_FLAGS)
.PHONY: cmake-create-release
cmake-create-release:
cmake -B $(BUILD_DIR) -G Ninja -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=1 $(CMAKE_FLAGS)
.PHONY: flash
flash: all
openocd -f interface/cmsis-dap.cfg -f target/nrf52.cfg -c "adapter speed 4000" -c "program {$(BUILD_DIR)/$(PROJECT).elf} verify reset; shutdown;"
.PHONY: $(BUILD_DIR)/$(PROJECT).elf
$(BUILD_DIR)/$(PROJECT).elf:
ninja -C $(BUILD_DIR) -v all