feat(web): add initial browser emulator interface

This commit is contained in:
2026-07-20 07:00:28 -04:00
parent 6538cec9f6
commit 0683c1b1c1
12 changed files with 808 additions and 25 deletions
+14 -5
View File
@@ -265,15 +265,23 @@ ADC ladders on GPIO1 & GPIO2; power button GPIO3; UC8253 @ 16 MHz.
`-sEMULATE_FUNCTION_POINTER_CASTS=1` is required for QEMU's QOM callbacks.
- The WASM dependency image omits libgcrypt. AES/RSA/DS/XTS devices are therefore
not instantiated; their MMIO falls through to the existing zero-return stub.
Canonical firmware boot still needs browser-level validation; add cross-built
libgcrypt only if firmware proves it uses those accelerators.
- Real firmware currently stops in `ffi_call_js`: Emscripten's
`EMULATE_FUNCTION_POINTER_CASTS` conflicts with libffi/BigInt. The paused
machine and browser bridge smoke tests pass; full browser boot does not yet.
- The upstream Emscripten RAM allocator fix is backported: anonymous guest RAM
uses `qemu_memalign` instead of the broken partial-unmap `mmap` workaround.
- Emscripten pthreads require cross-origin isolation (COOP/COEP) in the browser.
`make web` runs the stdlib server with those headers and serves `/web/` plus
the sibling `dist/wasm/` artifacts.
- The narrow browser bridge exports panel surface metadata/pixels and atomic
ADC/GPIO setters. JS polls a frame generation counter and forces alpha to 255;
X3's native surface stores RGB with a zero alpha byte.
- Firmware and ROM are written to MEMFS before QEMU starts. A second boot needs
a page reload because QEMU machine selection and global state are process-wide.
Next:
1. **Static browser front-end**: display surface → canvas; physical buttons →
ADC/GPIO controls; uploaded flash; SD block backend; `variant=x3|x4` chosen
before boot. Must run fully from static assets (airgapped).
1. **Browser SD storage**: add an uploaded or OPFS-backed SD block device.
2. **Full X4 rendering later**: SSD1677 is 800×480 controller / 480×800 portrait,
BUSY active-high. Implement its RAM/window/update commands when needed.
@@ -287,6 +295,7 @@ Next:
| Native/WASM patches | `qemu/patches/0001-xteink-machine.patch`, `0002-qemu-wasm.patch` |
| WASM environment | `qemu/wasm/Dockerfile` |
| WASM build | `scripts/build-qemu-wasm.sh` → `dist/wasm/` |
| Browser UI | `web/`; run with `make web` |
| QEMU source (ephemeral) | `_scratch/qemu-src` (via `make qemu`) |
| Canonical firmware | `https://github.com/crosspoint-reader/crosspoint-reader` |
| Tested firmware checkout | `/tmp/crosspoint-reader-main` @ `556b8ae` (unmodified) |