Skip to content

Commit d2eba1f

Browse files
committed
refactor(wasm): rename apply_agentdeck_quirks → install_esp32_arduino_quirks
The bootstrap thunks (heap-caps, esp_timer, locks, setCpuFrequencyMhz, esp_ota_*, HardwareSerial, delay, WifiWsLink, sendHello, esp_crc8) plus the dual-core handshake fakery are generic Arduino-ESP32 glue — every firmware built from the Arduino-ESP32 + GxEPD2 stack needs the same list. Carrying a customer's product name as a public simulator API was embarrassing. Renamed `WasmSimulator::apply_agentdeck_quirks` → `install_esp32_arduino_quirks`. Kept `apply_agentdeck_quirks` as a `#[deprecated]` wrapper so the previously-deployed standalone /agentdeck.html (now removed from the playground in a sibling commit) and any external callers keep working. Plus: `configs/systems/agentdeck.yaml` is now a first-class system manifest, independent of `examples/esp32-epaper-lab/system.yaml`. The two wirings are identical today and a leading comment block flags the manual sync requirement, but the files are no longer aliased so a future tweak to the lab demo's pin map can't silently break the production AgentDeck reference.
1 parent 2a0d189 commit d2eba1f

2 files changed

Lines changed: 50 additions & 6 deletions

File tree

configs/systems/agentdeck.yaml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# AgentDeck production hardware reference manifest.
2+
#
3+
# Pin map matches `firmware/src/pins.h` on the physical AgentDeck device:
4+
# BUSY = GPIO4
5+
# RST = GPIO16
6+
# DC = GPIO17
7+
# CS = GPIO5
8+
# SCK = GPIO18
9+
# MOSI = GPIO23
10+
#
11+
# Kept in sync with `examples/esp32-epaper-lab/system.yaml` manually — bump
12+
# both when the wiring ever needs to change.
13+
name: "agentdeck"
14+
chip: "../chips/esp32.yaml"
15+
external_devices:
16+
- id: "epaper"
17+
type: "ssd1680_tricolor_290"
18+
connection: "spi3"
19+
config:
20+
cs_pin: "GPIO5"
21+
board_io:
22+
- id: "epaper"
23+
kind: "spi_device"
24+
peripheral: "spi3"
25+
pin: 5
26+
signal: "input"
27+
active_high: true
28+
device_type: "ssd1680_tricolor_290"

crates/wasm/src/lib.rs

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub struct WasmSimulator {
4141
uart_rx_bufs: Vec<Arc<Mutex<VecDeque<u8>>>>,
4242
#[allow(dead_code)]
4343
arch: Arch,
44-
/// Set by `apply_agentdeck_quirks` / `enable_esp32_dual_core_emulation`.
44+
/// Set by `install_esp32_arduino_quirks` / `enable_esp32_dual_core_emulation`.
4545
/// When `Some`, `step_with_esp32_aids` runs the IPI bridge + dual-core
4646
/// handshake keep-alives each cycle.
4747
esp32_ipi: Option<Esp32IpiBridge>,
@@ -1434,8 +1434,9 @@ impl WasmSimulator {
14341434
}
14351435

14361436
// ──────────────────────────────────────────────────────────────────────
1437-
// AgentDeck-in-sim glue. Call after constructing the WasmSimulator with
1438-
// an ESP32-classic manifest + AgentDeck firmware ELF. Bakes in:
1437+
// Arduino-ESP32 bootstrap glue. Call after constructing the WasmSimulator
1438+
// with an ESP32-classic manifest + an Arduino-ESP32 firmware ELF (e.g.
1439+
// AgentDeck). Bakes in:
14391440
// * Memory pre-fakes (partition header, RTC freq probe, dual-core
14401441
// handshake bytes, ROM data region).
14411442
// * Flash thunks for the ESP-IDF + Arduino-ESP32 functions whose real
@@ -1448,7 +1449,7 @@ impl WasmSimulator {
14481449
// INTERRUPT bits when firmware writes DPORT_CPU_INTR_FROM_CPU.
14491450
// ──────────────────────────────────────────────────────────────────────
14501451
#[wasm_bindgen]
1451-
pub fn apply_agentdeck_quirks(&mut self) -> Result<(), JsValue> {
1452+
pub fn install_esp32_arduino_quirks(&mut self) -> Result<(), JsValue> {
14521453
use labwired_core::peripherals::esp32s3::rom_thunks;
14531454
let machine = self
14541455
.machine
@@ -1540,6 +1541,21 @@ impl WasmSimulator {
15401541
Ok(())
15411542
}
15421543

1544+
// DEPRECATED: renamed to install_esp32_arduino_quirks for clarity.
1545+
// The concern is Arduino-ESP32 firmware bootstrap (heap-caps thunks,
1546+
// dual-core handshake fakery, sendHello stub, WifiWsLink::loop stub,
1547+
// esp_crc8 thunk, etc.), not a specific customer product. Kept as a
1548+
// thin wrapper so the standalone /agentdeck.html page (and any other
1549+
// pre-rename caller) keeps working.
1550+
#[wasm_bindgen]
1551+
#[deprecated(
1552+
note = "Renamed to install_esp32_arduino_quirks — the bootstrap is generic Arduino-ESP32 glue, not AgentDeck-specific."
1553+
)]
1554+
pub fn apply_agentdeck_quirks(&mut self) -> Result<(), JsValue> {
1555+
#[allow(deprecated)]
1556+
self.install_esp32_arduino_quirks()
1557+
}
1558+
15431559
/// Re-write the dual-core handshake bytes. Call every ~10k steps from JS
15441560
/// — firmware boot code revisits these and we need them to stay 1.
15451561
#[wasm_bindgen]
@@ -1561,8 +1577,8 @@ impl WasmSimulator {
15611577
/// registers, raises the corresponding INTERRUPT bit, and clears the
15621578
/// trigger so the next write re-edges. The dual-core handshake bytes
15631579
/// are re-applied every 10k cycles (matching the e2e test cadence).
1564-
/// Falls back to plain `step` if `apply_agentdeck_quirks` hasn't been
1565-
/// called yet.
1580+
/// Falls back to plain `step` if `install_esp32_arduino_quirks` hasn't
1581+
/// been called yet.
15661582
#[wasm_bindgen]
15671583
pub fn step_with_esp32_aids(&mut self, cycles: u32) -> Result<(), JsValue> {
15681584
if self.esp32_ipi.is_none() {

0 commit comments

Comments
 (0)