-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathMakefile
More file actions
183 lines (149 loc) · 6.56 KB
/
Makefile
File metadata and controls
183 lines (149 loc) · 6.56 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
DOCKER_UID=$(shell id -u)
DOCKER_UGID=$(shell id -g)
PWD=$(shell pwd)
default: help
help: ## This help page
@echo 'make targets:'
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " %-24s %s\n", $$1, $$2}'
docker-pull: ## pull docker images
docker pull jedie/micropython:latest
docker-build: docker-pull ## pull and build docker images
docker build \
--build-arg "DOCKER_UID=${DOCKER_UID}" \
--build-arg "DOCKER_UGID=${DOCKER_UGID}" \
. \
-t local/micropython:latest
#
# Just "extract" compiled "mpy-cross" from docker image and store it here: ./build/mpy-cross
# So we can use it locally for 'soft' OTA Updates
docker run \
-e "DOCKER_UID=${DOCKER_UID}" \
-e "DOCKER_UGID=${DOCKER_UGID}" \
--mount type=bind,src=${PWD}/build/,dst=/mpy/build/ \
local/micropython:latest \
/bin/bash -c "cp /mpy/micropython/mpy-cross/mpy-cross /mpy/build/mpy-cross"
#
# Print version info:
build/mpy-cross --version
update: docker-build ## update git repositories/submodules, virtualenv, docker images and build local docker image
git pull origin master
@if [ -d docker-yaota8266/yaota8266/ota-server/lib/axtls ] ; \
then \
echo -n "\nGit submodules exists, ok.\n\n" ; \
else \
git submodule update --init --recursive ; \
fi
python3 -m pip install --upgrade pipenv
pipenv update
thonny: ## run Thonny IDE to access the Micropython REPL (Python prompt)
pipenv run thonny &
test: update ## Run pytest
PYTHONPATH=src pipenv run pytest
.PHONY: sdist
sdist:
pipenv run make_sdist
micropython_shell: sdist docker-build ## start a bash shell in docker container "local/micropython:latest"
docker run -it \
-e "DOCKER_UID=${DOCKER_UID}" \
-e "DOCKER_UGID=${DOCKER_UGID}" \
--mount type=bind,src=${PWD}/micropython_config/,dst=/mpy/micropython_config/ \
--mount type=bind,src=${PWD}/sdist/,dst=/mpy/micropython/ports/esp8266/sdist/ \
--mount type=bind,src=${PWD}/build/,dst=/mpy/build/ \
local/micropython:latest \
/bin/bash
unix-port-shell: docker-build ## start micropython unix port interpreter
docker run -it \
-e "DOCKER_UID=${DOCKER_UID}" \
-e "DOCKER_UGID=${DOCKER_UGID}" \
local/micropython:latest \
/mpy/micropython/ports/unix/micropython
assert-yaota8266-setup:
$(MAKE) -C docker-yaota8266/yaota8266 assert-yaota8266-setup
build-firmware-combined: sdist docker-build ## compiles the micropython non-OTA firmware and store it here: /build/firmware-combined.bin
docker run \
-e "DOCKER_UID=${DOCKER_UID}" \
-e "DOCKER_UGID=${DOCKER_UGID}" \
--mount type=bind,src=${PWD}/micropython_config/,dst=/mpy/micropython_config/ \
--mount type=bind,src=${PWD}/sdist/,dst=/mpy/micropython/ports/esp8266/sdist/ \
--mount type=bind,src=${PWD}/build/,dst=/mpy/build/ \
local/micropython:latest \
/bin/bash -c "cd /mpy/micropython/ports/esp8266/ \
&& make clean \
&& make -j12 \
FROZEN_MANIFEST=/mpy/micropython_config/manifest.py \
MICROPY_PY_BTREE=0 \
MICROPY_VFS_FAT=0 \
MICROPY_VFS_LFS2=1 \
&& cp -u /mpy/micropython/ports/esp8266/build-GENERIC/firmware-combined.bin /mpy/build/firmware-combined.bin"
@echo -n "\n"
ls -la build
@echo -n "\n"
file build/firmware-combined.bin
build-ota-firmware: sdist docker-build assert-yaota8266-setup ## compiles the micropython OTA firmware and store it here: /build/firmware-ota.bin
docker run \
-e "DOCKER_UID=${DOCKER_UID}" \
-e "DOCKER_UGID=${DOCKER_UGID}" \
--mount type=bind,src=${PWD}/micropython_config/,dst=/mpy/micropython_config/ \
--mount type=bind,src=${PWD}/sdist/,dst=/mpy/micropython/ports/esp8266/sdist/ \
--mount type=bind,src=${PWD}/build/,dst=/mpy/build/ \
local/micropython:latest \
/bin/bash -c "cd /mpy/micropython/ports/esp8266/ \
&& make clean \
&& make -j12 ota \
FROZEN_MANIFEST=/mpy/micropython_config/manifest.py \
MICROPY_PY_BTREE=0 \
MICROPY_VFS_FAT=0 \
MICROPY_VFS_LFS2=1 \
&& cp -u /mpy/micropython/ports/esp8266/build-GENERIC/firmware-ota.bin /mpy/build/firmware-ota.bin"
@echo -n "\n"
python3 docker-yaota8266/yaota8266/cli.py sign build/firmware-ota.bin
@echo -n "\n"
ls -la build
@echo -n "\n"
file build/firmware-ota.bin
yaota8266-rsa-keys: docker-build ## Pull/build yaota8266 docker images and Generate RSA keys and/or print RSA modulus line for copy&paste into config.h
$(MAKE) -C docker-yaota8266 rsa-keys
yaota8266-build: docker-build assert-yaota8266-setup ## Compile ota bootloader and store it here: build/yaota8266.bin
$(MAKE) -C docker-yaota8266 build
@echo -n "\n"
cp -u docker-yaota8266/yaota8266/yaota8266.bin build/yaota8266.bin
ls -la build
@echo -n "\n"
file build/yaota8266.bin
verify: ## Check RSA key, config.h and compiled "yaota8266.bin"
$(MAKE) -C docker-yaota8266/yaota8266 verify
erase-flash: ## call esptool.py erase_flash
pipenv run esptool.py --port /dev/ttyUSB0 erase_flash
flash-firmware-combined: ## Flash build/firmware-combined to location 0x3c000 via esptool.py
@if [ -f build/firmware-combined.bin ] ; \
then \
echo -n "\nbuild/firmware-combined.bin exists, ok.\n\n" ; \
else \
echo -n "\nERROR: Please run 'make build-firmware-combined' first to create 'build/firmware-combined.bin' !\n\n" ; \
exit 1 ; \
fi
pipenv run esptool.py --port /dev/ttyUSB0 --baud 460800 write_flash -fs 1MB -fm dout 0 build/firmware-combined.bin
flash-yaota8266: verify ## Flash build/yaota8266.bin to location 0x0 via esptool.py
@if [ -f build/yaota8266.bin ] ; \
then \
echo -n "\nbuild/yaota8266.bin exists, ok.\n\n" ; \
else \
echo -n "\nERROR: Please run 'make yaota8266-build' first to create 'build/yaota8266.bin' !\n\n" ; \
exit 1 ; \
fi
pipenv run esptool.py --port /dev/ttyUSB0 --baud 460800 write_flash -fs 1MB -fm dout 0x0 build/yaota8266.bin
flash-ota-firmware: verify ## Flash build/firmware-ota.bin to location 0x3c000 via esptool.py
@if [ -f build/firmware-ota.bin ] ; \
then \
echo -n "\nbuild/firmware-ota.bin exists, ok.\n\n" ; \
else \
echo -n "\nERROR: Please run 'make build-ota-firmware' first to create 'build/firmware-ota.bin' !\n\n" ; \
exit 1 ; \
fi
pipenv run esptool.py --port /dev/ttyUSB0 --baud 460800 write_flash -fs 1MB -fm dout 0x3c000 build/firmware-ota.bin
hard-ota: ## Start yaota8266 live-ota to hard-OTA Update the firmware file build/firmware-ota.bin.ota
pipenv run docker-yaota8266/yaota8266/cli.py ota build/firmware-ota.bin.ota
soft-ota: ## Start soft-OTA updates: Compile .py to .mpy and push missing/updated files (*.mpy, *.css, *.html etc.) to the device
pipenv run start_soft_ota_server
miniterm: ## Low level debug device via miniterm.py (from pyserial) to /dev/ttyUSB0
pipenv run miniterm.py /dev/ttyUSB0 115200