Skip to content

feat(esp-idf): ESP-IDF network host for AtomS3R and Tab5 (stack C) - #307

Draft
HalfSweet wants to merge 2 commits into
feat/network-v2-b-corefrom
feat/network-v2-c-esp-idf
Draft

feat(esp-idf): ESP-IDF network host for AtomS3R and Tab5 (stack C)#307
HalfSweet wants to merge 2 commits into
feat/network-v2-b-corefrom
feat/network-v2-c-esp-idf

Conversation

@HalfSweet

Copy link
Copy Markdown
Collaborator

Summary

Stack C of 3 (on top of #306, stack B). hosts/esp-idf: the ESP-IDF v6.0.2 product host — a QuickJS-ng guest owned by one task, fixed-rate frame() ticks with pnet_runtime_begin_tick before each, the net/ws/httpd bindings, a network task under the runtime lock, the ESP-TLS provider with the IDF certificate bundle, board bring-up for the AtomS3R and the Tab5, the headless smoke app and firmware template, and tools/net-peer.ts (the independent workstation peer).

Review-round changes in this PR (reviewer items 5, 6, 7, 1)

  • Exact cadence (5). Tick k is scheduled at t0 + k / tick_hz on the microsecond timer instead of pdMS_TO_TICKS(1000/60) = 16 ms (62.5 Hz against a 60 Hz __simHz). Late ticks still get their one turn (Law 3); only a host more than 0.5 s behind drops ticks (stats.frames_skipped). Both boards now report 1800 frames per 30.0 s.
  • One lifecycle state machine (6). start() unwinds everything it created on any failure (TLS provider included; the network task is joined when the guest task fails); stop() publishes a waiter, waits for both tasks' exit flags and frees only then — a wedged task is leaked with an error, never freed under; a QuickJS interrupt handler bounds a guest turn in progress while stopping (stop_turn_budget_ms); NULL guards on the failed-boot path; guest_boot_failed and the plan hash in stats.
  • Real clock trust (7). plat_clock_trusted delegates to cfg.wall_clock_trusted (none = never trusted = TLS fails closed); the board layer latches the state from a completed SNTP sync (and every re-sync via the SNTP notification) or an explicit setter — not time(NULL) > 2024.
  • Plan-derived policy (1). The smoke firmware embeds the canonical ResolvedNetworkPolicy of its Build Plan: examples/net-smoke/pocket.json is a format-3 manifest; tools/esp-idf.ts (run by main/CMakeLists.txt) merges the rig's Kconfig endpoints, resolves the plan against the private atoms3r-dev / tab5-dev profiles (tools/esp-idf-profile.ts) and writes network-policy.json, host-inputs.h (plan hash, features → mounted roles) and app.js; main.c authors nothing. The bindings use the two-phase poll. The README documents the plan flow, restates the soak record honestly (the earlier "12 minutes" was frames ÷ 60 on the 62.5 Hz host) and notes the ESP-TLS-under-lock stall the overload guard now makes visible.

Hardware

AtomS3R (ESP32-S3) and Tab5 (ESP32-P4 rev 1.3 + C6): rebuilt, flashed, SMOKE PASS 26/26 each (plaintext suite against tools/net-peer.ts and board-to-board, TLS block against public hosts and badssl.com under the SNTP-latched clock trust), with the plan hash logged at boot and the embedded plan policy.

…ork task, bindings, AtomS3R and Tab5 (stack C)

hosts/esp-idf (stacked PR C of three, on top of B's core): the product-host
half of the network stack for ESP-IDF v6.0.2 — a QuickJS-ng guest owned by
one task, fixed-rate frame() ticks with pnet_runtime_begin_tick before
each, the globalThis.net / ws / httpd bindings, a network task under the
runtime lock, the ESP-TLS TlsProvider with the IDF certificate bundle,
board bring-up for the AtomS3R (native Wi-Fi) and the Tab5 (ESP32-P4 rev
1.3 + ESP32-C6 over SDIO), the headless smoke app and the firmware
template, plus tools/net-peer.ts — the independent workstation peer.
…ne, real clock trust, plan-derived policy (stack C)

The review fixes for the ESP-IDF host (stack C):

- Cadence (reviewer item 5): tick k is scheduled at t0 + k/tick_hz on the
  microsecond timer instead of pdMS_TO_TICKS(1000/60) = 16 ms (62.5 Hz
  against a 60 Hz __simHz); late ticks still get their one turn, only a
  host more than 0.5 s behind drops ticks (stats.frames_skipped). Both
  boards report 1800 frames per 30.0 s.
- Lifecycle (item 6): start() unwinds everything it created on any failure
  (TLS provider included, the network task joined when the guest task
  fails); stop() publishes a waiter, waits for both tasks' exit flags and
  frees only then (a wedged task is leaked with an error, never freed
  under); a QuickJS interrupt handler bounds a guest turn in progress
  while stopping; NULL guards on the failed-boot path.
- Clock trust (item 7): plat_clock_trusted delegates to
  cfg.wall_clock_trusted (none = never trusted = TLS fails closed); the
  board layer latches the state from a completed SNTP sync and every
  re-sync, or an explicit setter — not time(NULL) > 2024.
- Policy (item 1): the smoke firmware embeds the canonical
  ResolvedNetworkPolicy of its Build Plan. examples/net-smoke/pocket.json
  is a format-3 manifest; tools/esp-idf.ts (run by main/CMakeLists.txt)
  merges the rig's Kconfig endpoints, resolves the plan against the
  private atoms3r-dev / tab5-dev profiles (tools/esp-idf-profile.ts) and
  writes network-policy.json, host-inputs.h (plan hash, features → mounted
  roles) and app.js; main.c authors nothing. The bindings use the
  two-phase poll. README: the plan flow, the honest soak record, the
  TLS-under-lock stall.
- Hardware: AtomS3R and Tab5 rebuilt, flashed, SMOKE PASS 26/26 each with
  the plan-derived policy and TLS under the SNTP-latched clock trust.
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.

1 participant