diff --git a/vga_test/CMakeLists.txt b/CMakeLists.txt similarity index 100% rename from vga_test/CMakeLists.txt rename to CMakeLists.txt diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..620a550 --- /dev/null +++ b/Makefile @@ -0,0 +1,44 @@ +# Build and flash the firmware. Override any of these on the command line, +# e.g. make ota BOARD=192.168.1.50 +IDF_PATH ?= $(HOME)/esp/esp-idf +TOOLCHAIN ?= $(HOME)/.arduino15/packages/esp32/tools/esp-x32/2507/bin +PYENV ?= $(HOME)/.espressif/python_env/idf5.4_py3.12_env +PORT ?= /dev/ttyACM0 +BOARD ?= 10.1.1.167 + +# IDF_MAINTAINER skips IDF's tool version check, as the toolchain above is +# the Arduino core's rather than the one IDF installs +export IDF_PATH +export IDF_MAINTAINER := 1 +export PATH := $(TOOLCHAIN):$(PYENV)/bin:$(PATH) + +PYTHON := $(PYENV)/bin/python +BIN := build/vga_test.bin + +.PHONY: all build flash ota monitor font clean + +all: build + +build/build.ninja: + cmake -S . -B build -G Ninja -DPYTHON=$(PYTHON) -DPYTHON_DEPS_CHECKED=1 -DIDF_TARGET=esp32s3 + +build: build/build.ninja + ninja -C build + +# Over USB +flash: build + cd build && $(PYTHON) -m esptool --chip esp32s3 -p $(PORT) -b 460800 --before default_reset --after hard_reset write_flash @flash_args + +# Over WiFi +ota: build + curl -X POST --data-binary @$(BIN) http://$(BOARD)/api/ota + +monitor: + $(PYTHON) $(IDF_PATH)/tools/idf_monitor.py -p $(PORT) build/vga_test.elf + +# Needs Pillow and the DejaVu fonts +font: + python3 tools/gen_font.py main/font_data.h + +clean: + rm -rf build diff --git a/README.md b/README.md index 46f9dc8..ef990b7 100644 --- a/README.md +++ b/README.md @@ -29,12 +29,16 @@ Ground goes to VGA pin 5 and pins 6–8, and VGA pin 9 ## Build and flash -You need ESP-IDF 5.4 or later. +You need ESP-IDF 5.4 or later. The paths at the top of the `Makefile` point +at the toolchain to use; override them if yours are elsewhere. ``` -cd vga_test -idf.py set-target esp32s3 -idf.py build flash +make # build +make flash # flash over USB (PORT=/dev/ttyACM0) +make ota # flash over WiFi (BOARD=) +make monitor # serial console +make font # regenerate main/font_data.h +make clean ``` The serial console is on the USB-Serial-JTAG port, because GPIO 43/44 carry @@ -46,8 +50,4 @@ The board starts its own access point, `ESP32-VGA` (password `esp32vga`). You can also give it your home WiFi details in Settings. Open its IP address in a browser. -To update the firmware over WiFi, use the page's Settings section, or run: - -``` -curl -X POST --data-binary @build/vga_test.bin http:///api/ota -``` +To update the firmware over WiFi, use the page's Settings section or `make ota`. diff --git a/vga_test/main/CMakeLists.txt b/main/CMakeLists.txt similarity index 100% rename from vga_test/main/CMakeLists.txt rename to main/CMakeLists.txt diff --git a/vga_test/main/app.h b/main/app.h similarity index 100% rename from vga_test/main/app.h rename to main/app.h diff --git a/vga_test/main/content.c b/main/content.c similarity index 100% rename from vga_test/main/content.c rename to main/content.c diff --git a/vga_test/main/content.h b/main/content.h similarity index 100% rename from vga_test/main/content.h rename to main/content.h diff --git a/vga_test/main/display.c b/main/display.c similarity index 100% rename from vga_test/main/display.c rename to main/display.c diff --git a/vga_test/main/display.h b/main/display.h similarity index 100% rename from vga_test/main/display.h rename to main/display.h diff --git a/vga_test/main/font_data.h b/main/font_data.h similarity index 100% rename from vga_test/main/font_data.h rename to main/font_data.h diff --git a/vga_test/main/gallery.c b/main/gallery.c similarity index 100% rename from vga_test/main/gallery.c rename to main/gallery.c diff --git a/vga_test/main/index.html b/main/index.html similarity index 100% rename from vga_test/main/index.html rename to main/index.html diff --git a/vga_test/main/main.c b/main/main.c similarity index 100% rename from vga_test/main/main.c rename to main/main.c diff --git a/vga_test/main/web.c b/main/web.c similarity index 100% rename from vga_test/main/web.c rename to main/web.c diff --git a/vga_test/partitions.csv b/partitions.csv similarity index 100% rename from vga_test/partitions.csv rename to partitions.csv diff --git a/vga_test/sdkconfig.defaults b/sdkconfig.defaults similarity index 100% rename from vga_test/sdkconfig.defaults rename to sdkconfig.defaults diff --git a/vga_test/tools/gen_font.py b/tools/gen_font.py similarity index 100% rename from vga_test/tools/gen_font.py rename to tools/gen_font.py