forked from Stunkymonkey/esp32-tang
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
183 lines (157 loc) · 4.13 KB
/
Copy pathMakefile
File metadata and controls
183 lines (157 loc) · 4.13 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
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
# ESP32 Tang Server Makefile
# Convenient shortcuts for ESP-IDF development tasks
.DEFAULT_GOAL := help
# Configuration variables
PORT ?= /dev/ttyUSB0
BAUD ?= 115200
TARGET ?= esp32
# Help target
.PHONY: help
help:
@echo "ESP32 Tang Server Development Commands"
@echo "====================================="
@echo ""
@echo "Setup:"
@echo " setup-target Set ESP32 as build target"
@echo " menuconfig Open configuration menu"
@echo ""
@echo "Build:"
@echo " build Build the project"
@echo " clean Clean build files"
@echo " fullclean Full clean (including config)"
@echo ""
@echo "Flash & Monitor:"
@echo " flash Flash to device"
@echo " monitor Open serial monitor"
@echo " flash-monitor Flash and immediately monitor"
@echo ""
@echo "Development:"
@echo " size Show binary size analysis"
@echo " erase Erase flash completely"
@echo " bootloader Flash bootloader only"
@echo ""
@echo "Board Management:"
@echo " list-boards List connected boards"
@echo " detect-port Detect serial ports"
@echo " board-info Show board information"
@echo ""
@echo "Environment variables:"
@echo " PORT=/dev/ttyUSB0 (default serial port)"
@echo " BAUD=115200 (default baud rate)"
@echo " TARGET=esp32 (default target)"
# Setup commands
.PHONY: setup-target
setup-target:
idf.py set-target $(TARGET)
.PHONY: menuconfig
menuconfig:
idf.py menuconfig
# Build commands
.PHONY: build
build:
idf.py build
.PHONY: clean
clean:
idf.py clean
.PHONY: fullclean
fullclean:
idf.py fullclean
# Flash and monitor commands
.PHONY: flash
flash:
idf.py -p $(PORT) -b $(BAUD) flash
.PHONY: monitor
monitor:
idf.py -p $(PORT) -b $(BAUD) monitor
.PHONY: flash-monitor
flash-monitor:
idf.py -p $(PORT) -b $(BAUD) flash monitor
# Development utilities
.PHONY: size
size:
idf.py size
.PHONY: size-components
size-components:
idf.py size-components
.PHONY: size-files
size-files:
idf.py size-files
.PHONY: erase
erase:
idf.py -p $(PORT) erase-flash
.PHONY: bootloader
bootloader:
idf.py -p $(PORT) bootloader-flash
# Show partition table
.PHONY: partition-table
partition-table:
idf.py partition-table
# Generate compilation database for IDE support
.PHONY: compile-commands
compile-commands:
idf.py build --cmake-args="-DCMAKE_EXPORT_COMPILE_COMMANDS=ON"
# Development shortcuts
.PHONY: dev
dev: build flash-monitor
.PHONY: quick
quick: build flash
# Board management
.PHONY: list-boards
list-boards:
idf.py -p $(PORT) board_info || echo "Connect board to $(PORT)"
.PHONY: detect-port
detect-port:
@echo "Scanning for ESP32 devices..."
@if ls /dev/ttyUSB* >/dev/null 2>&1; then \
echo "Found USB serial devices:"; \
ls -la /dev/ttyUSB* | head -5; \
elif ls /dev/ttyACM* >/dev/null 2>&1; then \
echo "Found ACM serial devices:"; \
ls -la /dev/ttyACM* | head -5; \
else \
echo "No serial devices found. Make sure ESP32 is connected."; \
fi
.PHONY: board-info
board-info:
@echo "Board Information:"
@echo "=================="
@echo "Target: $(TARGET)"
@echo "Port: $(PORT)"
@echo "Baud: $(BAUD)"
@echo ""
@echo "ESP-IDF Version:"
@idf.py --version
@echo ""
@echo "Project status:"
@idf.py show-port-info -p $(PORT) 2>/dev/null || echo "No device connected to $(PORT)"
# Show ESP-IDF version and tools
.PHONY: version
version:
@echo "ESP-IDF Version Information:"
@idf.py --version
@echo ""
@echo "Toolchain versions:"
@xtensa-esp32-elf-gcc --version | head -1 || echo "Toolchain not found"
@python3 --version
@cmake --version | head -1
# Validate project structure
.PHONY: validate
validate:
@echo "Validating ESP-IDF project structure..."
@if [ ! -f "CMakeLists.txt" ]; then \
echo "Error: CMakeLists.txt not found"; \
exit 1; \
fi
@if [ ! -d "main" ]; then \
echo "Error: main directory not found"; \
exit 1; \
fi
@echo "Project validation passed!"
# Full development cycle
.PHONY: full-setup
full-setup: setup-target menuconfig build
@echo ""
@echo "Full setup complete! You can now:"
@echo " make flash # Flash to device"
@echo " make monitor # View serial output"
@echo " make dev # Flash and monitor"