Skip to content

Web console: the WebUSB landing page (configure and inspect the emulator) - #136

Merged
finger563 merged 23 commits into
mainfrom
feat/web-console
Nov 14, 2026
Merged

finger563 merged 23 commits into
mainfrom
feat/web-console

Conversation

@finger563

@finger563 finger563 commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

This PR adds the Emulator Console, a web page that configures and inspects the emulator over USB. The firmware now advertises it as its WebUSB landing page, so Chrome or Edge offers to open it when the board is plugged in. It is published at https://esp-cpp.github.io/esp-box-emu/ (see setup below), and the source is in web/: plain HTML, CSS and ES modules with no build step.

Tabs:

  • Dashboard: the running game with its boxart, the frame rate, memory (with a history), firmware, partition and uptime, the last reset, the last crash, and the SD card's USB drive mode.
  • Screen: the game's screen, or the launcher's when no game runs, captured once or live. It has an on-screen controller (or keyboard), save/load slots and Quit.
  • Library: the games grouped by console with their boxart, read from the SD card. You can search, play, and filter by console; the filter optionally applies to the launcher too. You can also add a game (ROM, optional boxart and the metadata.csv line) or remove one.
  • Files: browse the SD card, download files, upload them (with drag and drop), create folders and delete.
  • Settings: the launcher's settings, applied and saved the same way as its own controls.
  • System: the chip, partitions, OTA state, reset reason and the other link services, plus restart, restart into download mode, and firmware update. An update reboots into the updater and opens espp's OTA console in a new tab. The generic services (core dump, system, monitor) open in their espp apps; the page picks the app from espp's registry.js by protocol and hands the device over.
  • Console: the console log over Web Serial, with a filter, follow mode and save.

Firmware changes:

  • Link protocol 4: a SETTINGS request to read the launcher's settings or change one (name=value), with each setting's limits. LIST_ROMS now includes each game's console key and boxart path. There's a matching emulink settings [name=value].
  • WebUSB landing page: esp-cpp.github.io/esp-box-emu/ instead of esp-cpp.github.io/espp/apps/device_hub.html, which doesn't exist; the hub is dispatcher_hub.html, and this page links to it.
  • Pages workflow: .github/workflows/pages.yml publishes web/ on a push to main. It needs Settings → Pages → Source: GitHub Actions enabled once.

link.js (framing, emu.control and the system service) and app.js are the same files in esp-box-emu and tab5-emu, like tools/emulink. The page also accepts the Device Hub's hand-off query string (?autoconnect=1&transport=usb&vid=…&pid=…&serial=…).

Tested on both boards in Chrome from http://localhost:8737:

  • connecting, and reconnecting automatically after a restart;
  • the dashboard;
  • the library, including launching a game, filtering, and loading all the boxart;
  • the live screen (about 0.2 s per NES frame on the box, and 3.7 s for a 1280×720 launcher shot on the Tab5, whose USB link is full speed);
  • the controller;
  • a file round trip (200 KB, byte for byte), folder creation and deletion;
  • the settings, with the brightness slider, the system info and the services list.

The JS framing is also cross-checked against emulink's Python codec.

Not tested: the Console tab (Web Serial needs the port picked in the browser's chooser) and the OTA hand-off.

Known issue (not caused by this PR): during these tests the box crashed while Sonic 2 (Genesis) was running. The crash was in the link task's next allocation, with a corrupted heap: a TLSF assert or an MMU fault. It is intermittent, and I couldn't pin it to a change; details are in the conversation. The page itself only makes ordinary link requests.

Screenshots (on the ESP-Box-Emu)

Dashboard (Sonic 2 running) Library
Screen and controller (Super Mario Bros. 3) System and services

🤖 Generated with Claude Code

https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY

finger563 and others added 8 commits November 12, 2026 23:42
- Left / right on the game list jump to the previous / next console.
- The console in the header opens a console picker (tap it, or X): all
  consoles, or only one console's games. The console is outlined while
  the list is filtered, and left / right then move the filter. Launching
  a game the filter hides lifts it.
- USB link (protocol 3): CONSOLE_FILTER (emulink filter <console|all>),
  the filter in STATUS, and SCREENSHOT of the launcher's screen when no
  game runs (lv_snapshot, now enabled).
- Graphics: a filtered roller does not wrap (a short list showed twice),
  and the Game Gear badge is lighter (it vanished on the dark header).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
- web/: the Emulator Console, plain HTML / CSS / ES modules (no build):
  dashboard (what runs, frame rate, memory, firmware, last crash, USB
  drive), the screen live with an on-screen / keyboard controller and save
  states, the library by console with boxart (play, filter the launcher,
  add / remove games), the SD card's files (download, upload, delete), the
  launcher's settings, the system (info, restart, firmware update through
  the updater and espp's OTA console, the other services in their espp
  apps) and the console log (Web Serial). link.js is the protocol, shared
  with tab5-emu like tools/emulink.
- The WebUSB landing page is now this console on the project's GitHub
  Pages (the old espp device_hub.html URL does not exist).
- Link protocol 4: SETTINGS (get / set the launcher's settings, as its
  controls do) and the console key and boxart path in LIST_ROMS;
  emulink settings [name=value].
- .github/workflows/pages.yml publishes web/ (Pages source: GitHub Actions).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
esp_tinyusb 3.0.1 (TinyUSB 0.21.0~6, the DWC2 SETUP-DMA erratum
workaround) corrupts the PSRAM heap on esp-box-emu while a Genesis game
runs: the link task's next allocation hits a tlsf assert or an MMU entry
fault. With 3.0.0 the same firmware is fine (checked on the box with the
same commit built both ways). A fresh build resolves '>=3.0.0' to 3.0.1,
so CI would have shipped it.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
The heap corruption seen with Sonic 2 on the box turned out to be
intermittent: the same builds that failed also pass repeated trials, so
the runs that blamed esp_tinyusb 3.0.1 were not evidence of a cause. The
corruption is tracked separately; no pin until it is understood.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
The heap corruption seen with Sonic 2 on the box turned out to be
intermittent: the same builds that failed also pass repeated trials, so
the runs that blamed esp_tinyusb 3.0.1 were not evidence of a cause. The
corruption is tracked separately; no pin until it is understood.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
Copilot AI balanced review requested due to automatic review settings November 13, 2026 16:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Automatic reconnect still attempts to claim the updater’s interface after an intentional OTA hand-off, competing with the OTA console for exclusive device access.

5 open issues
What changed in this PR

Adds a browser-based Emulator Console as the firmware’s WebUSB landing page, using the existing USB link shared with emulink.

Changes:

  • Adds device monitoring, screen capture and controls, game and file management, settings, system actions, and serial logs.
  • Extends control protocol 4 with launcher settings and richer ROM metadata, plus CLI support.
  • Updates the landing-page URL and adds GitHub Pages deployment.
File Description
web/​README.md Documents console features and local hosting.
web/​link.js Implements USB framing and device-control APIs.
web/​index.html Defines the console’s tabs and controls.
web/​app.js Implements connection handling and console interactions.
web/​app.css Styles the responsive interface and themes.
tools/​emulink/​emulink/​control.py Adds the settings protocol call.
tools/​emulink/​emulink/​cli.py Adds the emulink settings command.
README.md Introduces the web console and its features.
main/​remote_control.hpp Adds protocol 4 settings and richer ROM listings.
components/​gui/​src/​gui.cpp Reads, validates, and applies launcher settings.
components/​gui/​include/​gui.hpp Declares the remote settings interface.
components/​box-emu/​src/​box-emu.cpp Points WebUSB to the emulator console.
.github/​workflows/​pages.yml Checks scripts and publishes web/ to GitHub Pages.

Review effort: Balanced

Comment thread web/app.js Resolved
Comment thread web/app.js Resolved
Comment thread web/app.js Resolved
Comment thread web/app.js Resolved
Comment thread web/link.js Resolved
finger563 and others added 4 commits November 13, 2026 21:32
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
- Reconnect automatically only after an unexpected loss: not after
  Disconnect or a hand-off (the updater re-enumerates with the same serial
  and is the OTA console's to open); the delayed connect rechecks.
- Disconnect releases buttons held from the page and drops the boxart
  cache (revoking its URLs) and the last screenshot; replies for an older
  connection are not cached.
- The dashboard's core dump link hands the device off like Open app.
- File writes, deletes and metadata.csv edits run one at a time.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
…picker

- With a console filter on, Up from the first game lands on the header,
  which now moves on to that first game (the filtered roller stops at both
  ends, as Down does on the last game) instead of wrapping to the last.
- Selecting a game or setting the filter from the link closes the console
  picker first: a game started from there left the picker over the list
  with the list's keypad group restored after the game.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
finger563 and others added 2 commits November 13, 2026 22:00
… one pass

- CONSOLE_FILTER with an empty payload now returns {filter, consoles}
  without touching the launcher ("all" clears the filter, as before), and
  emulink filter with no console sends that query instead of re-setting
  the current filter (which rebuilt the list and could undo a newer pick).
- The picker counts each console's games in one pass over the grouped list.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread web/app.js Resolved
Comment thread web/app.js Resolved
Comment thread web/app.js Resolved
Comment thread web/app.js Resolved
Comment thread web/link.js Resolved
- A multi-file upload writes to the folder it was dropped in, through the
  connection it started on, whatever the page shows meanwhile.
- A settings change still debouncing when its connection ends is dropped.
- connect() stops after discovery if the link was lost meanwhile.
- The confirmation dialog makes the page behind it inert and gives focus
  back afterwards.
- A request observes its send and its reply together: a timeout while the
  frame is queued rejects at once, with no unhandled rejection.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread web/app.js Resolved
Comment thread web/app.js Resolved
Comment thread web/link.js Resolved
finger563 and others added 6 commits November 13, 2026 22:11
…he picker

- CONSOLE_FILTER (set) runs on the main loop under the GUI lock, like
  LAUNCH, and is refused while a launch the loop has taken has not
  started its cart yet: the new filter could change the game it starts.
- Re-reading metadata.csv closes an open console picker, whose consoles
  and counts are the old list's.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
… queued reads

- Add Game writes the ROM, its boxart and the metadata.csv line through
  the connection it started on and stops if that changed.
- On the Screen tab, Enter / Space on a focused control activate it
  instead of pressing Start; on a focused pad button they press that
  button (released on keyup or blur).
- File reads go through the operation queue as well, so a download never
  sees a file half rewritten by an upload.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
web/app.js and web/link.js match tab5-emu again (4663b35): launch, quit,
save, load, the drive switch and the ROM reload wait for a capture in
progress; no '..' in card paths; the confirmation answers Escape, keeps Tab
on its buttons, and a second question answers the first with no; buttons
are released on connect; the capture is cleared on disconnect; missing box
art is retried after a reload or the card's return; game frames only in a
game; a failed PNG is reported.

Firmware: buffered data lost when a read or the card handover closed the
file is reported by the next FILE_CLOSE (as tab5-emu b655ce1).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
Moves the Web Console section up next to Quick Start, explains the WebUSB
landing page and each tab, and adds dashboard / screen / library / settings /
files / system screenshots from the box (images/web-console/). The MAC
address is blanked in the system shot.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
…larifyCondition)

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
Base automatically changed from feat/console-filter to main November 14, 2026 05:47
main's tree is feat/console-filter's tip (8a0cd6c), already merged here, so
this branch's tree is kept as is.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
@github-actions

Copy link
Copy Markdown

✅Static analysis result - no issues found! ✅

@github-actions

Copy link
Copy Markdown

ESP-IDF Size Report for 'Esp Box Emu'

Metric Base PR Delta
FLASH 4,217,960 bytes (67.04%) 4,219,432 bytes (67.07%) 🔺 +1,472 bytes (+0.03%)
DRAM 170,405 bytes (49.86%) 170,405 bytes (49.86%) 0 bytes (0.00%)
IRAM 0 bytes 0 bytes 0 bytes
RAM (DRAM+IRAM) 170,405 bytes 170,405 bytes 0 bytes (0.00%)

FLASH uses app .bin size or json2 flash sum. RAM sums DRAM+IRAM via idf_size. Percentages shown when totals are available.
DRAM/IRAM usage does not include memory used by the heap allocator at runtime.
This report was generated by esp-idf-size-delta.

@finger563
finger563 merged commit 9b3eefa into main Nov 14, 2026
3 checks passed
@finger563
finger563 deleted the feat/web-console branch November 14, 2026 06:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants