-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
145 lines (119 loc) · 4.61 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
####################################################################################################
#
# flipflip's ESP8266 Album Art Display
#
# Copyright (c) 2020 Philippe Kehl <flipflip at oinkzwurgl dot org>
#
####################################################################################################
SKETCH := AlbumArtDisplay.ino
ARDUINO := arduino
PORT := /dev/ttyUSB0
SRCS := $(SKETCH) $(sort $(wildcard src/*.h) $(wildcard src/*.c) $(wildcard src/*.cpp))
DEPS := Makefile tools/debug.pl tools/gen_config.h
PERL := perl
TOUCH := touch
RM := rm
MV := mv
SED := sed
SHELL := bash
.PHONY: defaulttarget
defaulttarget:
@echo "Make what?! Try 'make help'..."
####################################################################################################
# canned receipe for verify, build, clean, etc.
target_names :=
targets_verify :=
targets_upload :=
targets_clean :=
targets_trace :=
define makeRules
target_names += $(strip $(1))
targets_verify += $(strip $(1))-verify
.PHONY: $(strip $(1))-verify
$(strip $(1))-verify: build-$(strip $(1))/.verify
build-$(strip $(1))/.verify: $(SRCS)
$(PERL) tools/gen_config_h.pl $(1)
$(ARDUINO) --verify --preserve-temp-files --verbose --board $(2) $$< --pref build.path=$$(dir $$@) 2>&1 \
| sed -r 's|/.*?/build-$(strip $(1))/sketch/||g' ; exit "$$$${PIPESTATUS[0]}"
$(TOUCH) $$@
targets_upload += $(strip $(1))-upload
.PHONY: $(strip $(1))-upload
$(strip $(1))-upload: $(SRCS)
$(PERL) tools/gen_config_h.pl $(1)
$(ARDUINO) --upload --preserve-temp-files --verbose --board $(2) $$< --pref build.path=build-$(strip $(1)) --port $(PORT) 2>&1 \
| sed -r 's|/.*?/build-$(strip $(1))/sketch/||g' ; exit "$$$${PIPESTATUS[0]}"
targets_clean += $(strip $(1))-clean
.PHONY: $(strip $(1))-clean
$(strip $(1))-clean:
$(RM) -rf build-$(strip $(1))
targets_trace += $(strip $(1))-trace
.PHONY: $(strip $(1))-trace
$(strip $(1))-trace: build-$(strip $(1))/$(SKETCH).elf
$(PERL) tools/EspStackTraceDecoder.pl build-$(strip $(1))/$(SKETCH).elf -
endef
####################################################################################################
# generate target receipes
# see ~/.arduino15/packages/esp32/hardware/esp32/1.0.4/boards.txt
BOARD_ESP32_MINI32 := esp32:esp32:esp32:PSRAM=disabled,PartitionScheme=noota_3g,CPUFreq=240,FlashMode=qio,FlashFreq=80,FlashSize=4M,UploadSpeed=921600,DebugLevel=verbose
$(eval $(call makeRules, esp32-mini32, $(BOARD_ESP32_MINI32)))
# manual recipes for making and flashing SPIFFS image
mkspiffs=$(lastword $(sort $(wildcard ~/.arduino15/packages/esp32/tools/mkspiffs/*/mkspiffs)))
esptoolpy=$(lastword $(sort $(wildcard ~/.arduino15/packages/esp32/tools/esptool_py/*/esptool.py)))
build-esp32-mini32/spiffs.bin: $(wildcard data/*) Makefile
$(RM) -f $@
$(mkspiffs) -c data -b 4096 -p 256 -s 3080192 $@
ls -l $@
.PHONE: flash-spiffs
flash-spiffs: build-esp32-mini32/spiffs.bin
$(esptoolpy) --chip esp32 --port $(PORT) --baud 921600 --before default_reset --after hard_reset write_flash \
-z --flash_mode qio --flash_freq 80m --flash_size detect \
0x110000 $<
####################################################################################################
.PHONY: help
help:
@echo
@echo "Usage:"
@echo
@echo " make <target> [PORT=...] [ARDUINO=...]"
@echo
@echo "Where <target> can be:"
@echo
@echo " <name>-verify build (verify) sketch"
@echo " <name>-upload build and upload sketch"
@echo " <name>-trace decode stack trace"
@echo " <name>-clean clean build directory"
@echo " monitor show serial output"
@echo " clean clean all build directories"
@echo " verify build (verify) sketch for all <name>s"
@echo " flash-spiffs make and flash filesystem (data/*)"
@echo
@echo "The following <name>s are available:"
@echo
@echo " $(target_names)"
@echo
@echo "Optional parameters:"
@echo
@echo " PORT serial port (default: $(PORT))"
@echo " ARDUINO path to arduino binary (default: $(ARDUINO))"
@echo
@echo "Example to build, upload and start serial monitor:"
@echo
@echo " make $(firstword $(target_names))-upload monitor"
@echo
.PHONY: debugmf
debugmf:
@echo "target_names: $(target_names)"
@echo "targets_verify: $(targets_verify)"
@echo "targets_upload: $(targets_upload)"
@echo "targets_trace: $(targets_trace)"
@echo "targets_clean: $(targets_clean)"
.PHONY: verify
verify: $(targets_verify)
.PHONY: clean
clean: $(targets_clean)
rm -f src/config.h
.PHONY: monitor
monitor:
perl tools/debug.pl $(PORT):115200
####################################################################################################
# eof