blob: 7043b20ea2738e4628b2eaaed802caf22001949d (
plain)
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
|
# Optionally some environment variables can be set:
#
# FQBN Fully Qualified Board Name; if not set in the environment
# it will be assigned a value in this makefile
#
# SERIAL_DEV Serial device to upload the sketch; if not set in the
# environment it will be assigned:
# /dev/ttyUSB0 if it exists, or
# /dev/ttyACM0 if it exists, or
# unknown
#
# MDNS_NAME Hostname of the Arduino; if not set in the environment
# it will be assigned a value in this makefile. This is
# needed for OTA update, the device will be searched
# on the local subnet using this name
#
# OTA_PORT Port used by OTA update; if not set in the environment
# it will be assigned the default value of 8266 in this
# makefile
#
# OTA_PASS Password used for OTA update; if not set in the environment
# it will be assigned the default value of an empty string
PROGNAME = mush
CORE = esp8266:esp8266
FQBN = $(CORE):espmxdevkit
MDNS_NAME = $(PROGNAME)
OTA_PORT = 8266
OTA_PASS =
SERIAL_DEV = $(firstword $(wildcard /dev/ttyUSB* /dev/ttyACM*))
.DEFAULT_GOAL = all
init:
[ -e /home/d/.arduino15/arduino-cli.yaml ] || arduino-cli config init
arduino-cli config set board_manager.additional_urls https://arduino.esp8266.com/stable/package_esp8266com_index.json
arduino-cli core update-index
arduino-cli core install $(CORE)
arduino-cli lib update-index
arduino-cli lib install 'DHT sensor library'
$(cli) compile --show-properties > $@
cli = arduino-cli -b "$(FQBN)"
ifeq (,$(wildcard init))
ifneq ($(MAKECMDGOALS),init)
$(error please run make init)
endif
else
BUILD_DIR != sed -ne 's/^build.path=//p' < init
PLAT_PATH != sed -ne 's/^runtime.platform.path=//p' < init
PY_PATH != sed -ne 's/^runtime.tools.python3.path=//p' < init
endif
ifneq (,$(filter ota, $(MAKECMDGOALS)))
MDNS_IP != getent ahostsv4 $(MDNS_NAME).local | (read ip _; echo $$ip)
endif
SRC := CCS811.cpp $(PROGNAME).ino
HDRS := CCS811.h ota.h wifiinfo.h
BIN := $(BUILD_DIR)/$(PROGNAME).ino.bin
ELF := $(BUILD_DIR)/$(PROGNAME).ino.elf
.PHONY: all
all: $(ELF)
@ls -l $(ELF)
compile: $(ELF)
.PHONY: compile
build_flags =
$(BIN) $(ELF): $(SRC) $(HDRS)
$(cli) compile $() $(addprefix --build-property build.extra_flags=,$(build_flags)) --warnings all
upload: $(ELF)
[ -w "$(SERIAL_DEV)" ] || sudo chmod 666 "$(SERIAL_DEV)"
$(cli) upload -p "$(SERIAL_DEV)"
ota: $(BIN)
[ "$(MDNS_IP)" ]
"$(PY_PATH)/python3" "$(PLAT_PATH)/tools/espota.py" -i "$(MDNS_IP)" -p "$(OTA_PORT)" --auth="$(OTA_PASS)" -f "$(BIN)"
|