build: refactor: deduplicate --port option usage

This commit is contained in:
Laborratte5 2024-04-29 23:59:49 +02:00
parent b51a248a18
commit 745e8bb55b
Signed by: Laborratte5
GPG key ID: 3A30072E35202C02

View file

@ -1,7 +1,7 @@
VENV = poetry run
ESP_TOOL = $(VENV) esptool.py
ESP_TOOL = $(VENV) esptool.py --port $(ESP_PORT)
MPYCROSS = $(VENV) mpy-cross
AMPY = $(VENV) ampy
AMPY = $(VENV) ampy --port $(ESP_PORT)
# Downloaded from https://micropython.org/download/ESP8266_GENERIC/
MICRO_PYTHON_FIRMWARE = ESP8266_GENERIC-20240222-v1.22.2.bin
@ -17,23 +17,23 @@ check: src/*.mpy
$(VENV) python3 -m py_compile src/*.py
erase_flash:
$(ESP_TOOL) --port $(ESP_PORT) erase_flash
$(ESP_TOOL) erase_flash
flash_esp: erase_flash
$(ESP_TOOL) --port $(ESP_PORT) --baud 460800 write_flash --flash_size=detect 0 $(MICRO_PYTHON_FIRMWARE)
$(ESP_TOOL) --baud 460800 write_flash --flash_size=detect 0 $(MICRO_PYTHON_FIRMWARE)
install: check src/*.mpy
$(AMPY) --port $(ESP_PORT) put src/main.py
$(AMPY) put src/main.py
@for f in $(filter-out check,$?); do \
echo Uploading $$f; \
$(AMPY) --port $(ESP_PORT) put $$f; \
$(AMPY) put $$f; \
done
uninstall:
@echo $(filter-out /boot.py,$(shell $(AMPY) --port $(ESP_PORT) ls))
@for f in $(filter-out /boot.py,$(shell $(AMPY) --port $(ESP_PORT) ls)); do \
@echo $(filter-out /boot.py,$(shell $(AMPY) ls))
@for f in $(filter-out /boot.py,$(shell $(AMPY) ls)); do \
echo Deleting $$f; \
$(AMPY) --port $(ESP_PORT) rm $$f; \
$(AMPY) rm $$f; \
done
clean: