-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
143 lines (109 loc) · 3.48 KB
/
Makefile
File metadata and controls
143 lines (109 loc) · 3.48 KB
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
PORT ?= /dev/ttyACM0
IDF_PATH ?= $(shell cat .IDF_PATH 2>/dev/null || echo `pwd`/esp-idf)
IDF_TOOLS_PATH ?= $(shell cat .IDF_TOOLS_PATH 2>/dev/null || echo `pwd`/esp-idf-tools)
IDF_BRANCH ?= master
IDF_COMMIT ?= aaebc374676621980878789c49d239232ea714c5
IDF_EXPORT_QUIET ?= 1
IDF_GITHUB_ASSETS ?= dl.espressif.com/github_assets
MAKEFLAGS += --silent
SHELL := /usr/bin/env bash
DEVICE ?= bornhack-2024 # Default target device
BUILD ?= build/$(DEVICE)
export IDF_TOOLS_PATH
export IDF_GITHUB_ASSETS
# General targets
.PHONY: all
all: build flash
.PHONY: install
install: flash
# Preparation
.PHONY: prepare
prepare: submodules sdk
.PHONY: submodules
submodules:
if [ ! -f .submodules_update_done ]; then \
echo "Updating submodules"; \
git submodule update --init --recursive; \
touch .submodules_update_done; \
fi
.PHONY: sdk
sdk:
if test -d "$(IDF_PATH)"; then echo -e "ESP-IDF target folder exists!\r\nPlease remove the folder or un-set the environment variable."; exit 1; fi
if test -d "$(IDF_TOOLS_PATH)"; then echo -e "ESP-IDF tools target folder exists!\r\nPlease remove the folder or un-set the environment variable."; exit 1; fi
git clone --recursive --branch "$(IDF_BRANCH)" https://github.com/espressif/esp-idf.git "$(IDF_PATH)" --depth=1 --shallow-submodules
cd "$(IDF_PATH)"; git fetch origin "$(IDF_COMMIT)" --recurse-submodules || true
cd "$(IDF_PATH)"; git checkout "$(IDF_COMMIT)"
cd "$(IDF_PATH)"; git submodule update --init --recursive
cd "$(IDF_PATH)"; bash install.sh all
.PHONY: removesdk
removesdk:
rm -rf "$(IDF_PATH)"
rm -rf "$(IDF_TOOLS_PATH)"
.PHONY: refreshsdk
refreshsdk: removesdk sdk
.PHONY: menuconfig
menuconfig:
source "$(IDF_PATH)/export.sh" && idf.py menuconfig -DDEVICE=$(DEVICE)
# Cleaning
.PHONY: clean
clean:
rm -rf $(BUILD)
rm -f .submodules_update_done
.PHONY: fullclean
fullclean: clean
rm -f sdkconfig
rm -f sdkconfig.old
rm -f sdkconfig.ci
rm -f sdkconfig.defaults
# Check if build environment is set up correctly
.PHONY: checkbuildenv
checkbuildenv:
if [ -z "$(IDF_PATH)" ]; then echo "IDF_PATH is not set!"; exit 1; fi
if [ -z "$(IDF_TOOLS_PATH)" ]; then echo "IDF_TOOLS_PATH is not set!"; exit 1; fi
# Building
.PHONY: build
build: checkbuildenv submodules
source "$(IDF_PATH)/export.sh" >/dev/null && idf.py -B $(BUILD) build -DDEVICE=$(DEVICE)
# Hardware
.PHONY: flash
flash: build
source "$(IDF_PATH)/export.sh" && \
idf.py -B $(BUILD) flash -p $(PORT)
.PHONY: flashmonitor
flashmonitor: build
source "$(IDF_PATH)/export.sh" && \
idf.py -B $(BUILD) flash -p $(PORT) monitor
.PHONY: erase
erase:
source "$(IDF_PATH)/export.sh" && idf.py -B $(BUILD) erase-flash -p $(PORT)
.PHONY: monitor
monitor:
source "$(IDF_PATH)/export.sh" && idf.py -B $(BUILD) monitor -p $(PORT)
.PHONY: openocd
openocd:
source "$(IDF_PATH)/export.sh" && idf.py -B $(BUILD) openocd
.PHONY: gdb
gdb:
source "$(IDF_PATH)/export.sh" && idf.py -B $(BUILD) gdb
# Tools
.PHONY: size
size:
source "$(IDF_PATH)/export.sh" && idf.py -B $(BUILD) size
.PHONY: size-components
size-components:
source "$(IDF_PATH)/export.sh" && idf.py -B $(BUILD) size-components
.PHONY: size-files
size-files:
source "$(IDF_PATH)/export.sh" && idf.py -B $(BUILD) size-files
# Formatting
.PHONY: format
format:
find main/ -iname '*.h' -o -iname '*.c' -o -iname '*.cpp' | xargs clang-format -i
# Build all targets
.PHONY: buildall
buildall:
$(MAKE) build DEVICE=tanmatsu
$(MAKE) build DEVICE=kami
$(MAKE) build DEVICE=mch2022
$(MAKE) build DEVICE=bornhack-2024
$(MAKE) build DEVICE=bornhack-2025