initial commit

This commit is contained in:
2026-07-19 19:21:43 -04:00
commit f972fbe78b
20 changed files with 2032 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
#!/usr/bin/env bash
set -euo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
SRC="${QEMU_SRC:-$ROOT/_scratch/qemu-src}"
TAG="esp-develop-9.2.2-20260417"
PATCH="$ROOT/qemu/patches/0001-xteink-x3-machine.patch"
JOBS="${JOBS:-2}"
if [ ! -d "$SRC/.git" ]; then
git clone --depth 1 --branch "$TAG" https://github.com/espressif/qemu "$SRC"
fi
cd "$SRC"
if git apply --check "$PATCH" 2>/dev/null; then
git apply "$PATCH"
elif ! git apply --reverse --check "$PATCH" 2>/dev/null; then
echo "QEMU source has changes that conflict with $PATCH" >&2
exit 1
fi
if [ ! -f build/build.ninja ]; then
./configure \
--target-list=riscv32-softmmu \
--enable-gcrypt \
--enable-slirp \
--disable-werror \
--disable-docs \
--disable-tools
fi
ninja -C build -j"$JOBS" qemu-system-riscv32
printf '%s\n' "$SRC/build/qemu-system-riscv32"
+24
View File
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
# Build a FAT32 SD-card image from a local directory — the local-disk backing
# for the emulated SD. QEMU's block layer is the interface: this same image is
# swapped for a browser-supplied blockdev (File/OPFS) in the WASM build.
#
# scripts/mksd.sh [src-dir] [out-img] (SIZE_MB env overrides size)
set -euo pipefail
SRC="${1:-../crosspoint-reader-lua/sdcard}"
OUT="${2:-sd.img}"
SIZE_MB="${SIZE_MB:-64}"
[ -d "$SRC" ] || { echo "no such dir: $SRC" >&2; exit 1; }
OUT_ABS="$(realpath -m "$OUT")"
rm -f "$OUT_ABS"
truncate -s "${SIZE_MB}M" "$OUT_ABS"
mkfs.vfat -F 32 -n XTEINK "$OUT_ABS" >/dev/null
# mcopy the tree in (recursive, no per-file prompts).
( cd "$SRC" && for e in *; do [ -e "$e" ] && mcopy -i "$OUT_ABS" -s -Q -o "$e" ::; done )
echo "wrote $OUT (${SIZE_MB}M FAT32) from $SRC"
mdir -i "$OUT_ABS" :: | sed 's/^/ /'
+26
View File
@@ -0,0 +1,26 @@
#!/usr/bin/env python3
# Exercise the button/ADC QOM interface: qmp-qom.py <sock> get|set <path> <prop> [value]
import json
import socket
import sys
sock = socket.socket(socket.AF_UNIX)
sock.connect(sys.argv[1])
f = sock.makefile("rw")
json.loads(f.readline())
def cmd(command):
f.write(json.dumps(command) + "\n")
f.flush()
return json.loads(f.readline())
cmd({"execute": "qmp_capabilities"})
op, path, prop = sys.argv[2], sys.argv[3], sys.argv[4]
if op == "set":
print(cmd({"execute": "qom-set", "arguments": {
"path": path, "property": prop, "value": int(sys.argv[5])}}))
else:
print(cmd({"execute": "qom-get", "arguments": {
"path": path, "property": prop}}))
+18
View File
@@ -0,0 +1,18 @@
#!/usr/bin/env python3
import json
import socket
import sys
sock = socket.socket(socket.AF_UNIX)
sock.connect(sys.argv[1])
f = sock.makefile("rw")
json.loads(f.readline())
for command in (
{"execute": "qmp_capabilities"},
{"execute": "screendump", "arguments": {"filename": sys.argv[2]}},
):
f.write(json.dumps(command) + "\n")
f.flush()
response = json.loads(f.readline())
if "error" in response:
raise RuntimeError(response["error"])