b959776068
Native and wasm now share one source tree, so the xteink machine and SD fixes never diverge. scripts/build-qemu.sh configures a dedicated build-native/ dir (ucontext coroutine backend; the fork defaults to the wasm fiber backend) that never clobbers the Emscripten build/ config. Retires the separate _scratch/qemu-src patch-based native build.
73 lines
2.4 KiB
Makefile
73 lines
2.4 KiB
Makefile
# Canonical firmware: clone https://github.com/crosspoint-reader/crosspoint-reader
|
|
# next to this repo, then build its PlatformIO `default` environment.
|
|
FIRMWARE_REPO ?= ../crosspoint-reader
|
|
FIRMWARE_DIR ?= $(FIRMWARE_REPO)/.pio/build/default
|
|
SD_SRC ?= $(FIRMWARE_REPO)/sdcard
|
|
# Native and wasm builds share the third_party/qemu submodule; edit it in place
|
|
# and both recompile incrementally. Native output lives in build-native so it
|
|
# never clobbers the Emscripten build/ config.
|
|
QEMU_SRC ?= third_party/qemu
|
|
QEMU_BIN = $(QEMU_SRC)/build-native/qemu-system-riscv32
|
|
QEMU_WASM_SRC ?= third_party/qemu
|
|
WASM_OUT ?= dist/wasm
|
|
VARIANT ?= x3
|
|
|
|
.PHONY: firmware sdimage qemu qemu-wasm web web-test test browser-test run run-upstream chip clean
|
|
|
|
firmware:
|
|
esptool --chip esp32c3 merge-bin -o flash.bin \
|
|
0x0 $(FIRMWARE_DIR)/bootloader.bin \
|
|
0x8000 $(FIRMWARE_DIR)/partitions.bin \
|
|
0x10000 $(FIRMWARE_DIR)/firmware.bin
|
|
truncate -s 16M flash.bin
|
|
cp $(FIRMWARE_DIR)/firmware.elf firmware.elf
|
|
|
|
# Local-disk implementation of the SD block interface.
|
|
sdimage:
|
|
scripts/mksd.sh $(SD_SRC) sd.img
|
|
|
|
qemu:
|
|
QEMU_SRC=$(QEMU_SRC) scripts/build-qemu.sh
|
|
|
|
qemu-wasm:
|
|
QEMU_WASM_SRC=$(QEMU_WASM_SRC) WASM_OUT=$(WASM_OUT) scripts/build-qemu-wasm.sh
|
|
|
|
# Serve over HTTPS by default so headless/LAN access is cross-origin isolated. Override with WEB_TLS=.
|
|
WEB_TLS ?= --tls
|
|
web: qemu-wasm
|
|
python3 scripts/serve-web.py $(WEB_TLS)
|
|
|
|
web-test:
|
|
node scripts/test-web.mjs
|
|
|
|
test:
|
|
$(MAKE) -C tests test
|
|
|
|
browser-test:
|
|
$(MAKE) -C tests browser
|
|
|
|
# Select X4 with `make run VARIANT=x4`. Add `-display none` for headless.
|
|
run: qemu
|
|
@sd=sd.img; tmpdir=; \
|
|
if [ ! -f "$$sd" ]; then \
|
|
tmpdir=$$(mktemp -d); mkdir "$$tmpdir/empty"; sd="$$tmpdir/sd.img"; \
|
|
SIZE_MB=64 scripts/mksd.sh "$$tmpdir/empty" "$$sd" >/dev/null; \
|
|
echo "Using a blank ephemeral SD card; writes will be discarded when QEMU exits."; \
|
|
fi; \
|
|
trap 'rm -rf "$$tmpdir"' EXIT; \
|
|
$(QEMU_BIN) -machine xteink,variant=$(VARIANT) -L $(QEMU_SRC)/pc-bios \
|
|
-serial stdio -drive file=flash.bin,if=mtd,format=raw \
|
|
-drive file="$$sd",if=sd,format=raw
|
|
|
|
# Unpatched release binary retained as the fast generic ESP32-C3 baseline.
|
|
run-upstream:
|
|
nix run .#run-upstream -- flash.bin
|
|
|
|
# Legacy Wokwi protocol model; retained as a small host-tested reference.
|
|
chip:
|
|
$(MAKE) -C chip
|
|
|
|
clean:
|
|
$(MAKE) -C chip clean
|
|
rm -f flash.bin flash16.bin firmware.elf
|