Commit Graph

5 Commits

Author SHA1 Message Date
Dragan Spiridonov d33e4a531c merge: bring upstream/main into PR #397
Upstream moved forward with v0.6.2-esp32 (ADR-081 adaptive CSI mesh kernel,
Timer Svc stack fix) and the Docker entrypoint merge of PR #402.

Conflicts resolved:

- `firmware/esp32-csi-node/sdkconfig.defaults`: both sides appended a new
  config block. Kept both — `CONFIG_ESP_WIFI_EXTRA_IRAM_OPT=y` (ours,
  defense-in-depth for RuView#396 SPI cache race) AND
  `CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=8192` (upstream's ADR-081 Timer
  Svc stack bump). They target different crash modes.

- Applied the same `CONFIG_ESP_WIFI_EXTRA_IRAM_OPT=y` line to
  `sdkconfig.defaults.4mb` and `sdkconfig.defaults.template` for
  consistency — the SPI cache race is not flash-size specific, and the
  4MB / template variants run the same CSI collector code with the same
  MGMT-only callback path.

- `firmware/esp32-csi-node/version.txt`: both sides bumped to 0.6.2.
  Upstream already released v0.6.2-esp32, so our in-flight work bumps
  to 0.6.3.

- `CHANGELOG.md`: auto-merge placed our [Unreleased] #397 entries
  (and the older #391 / #390 entries) inside the newly-cut
  [v0.6.2-esp32] section. Moved them back to [Unreleased] — they
  describe work that has not been released yet.

Auto-merged cleanly: `csi_collector.c`, `csi_collector.h`, `main.c`,
`docker/*`, `README.md`, `docs/user-guide.md`. Verified the PR's
defensive-copy code (`s_node_id_early_set`, `s_filter_mac`,
`CSI_MIN_PROCESS_INTERVAL_US`, `s_early_drop`, the 50 Hz rate gate,
MGMT-only filter, and `csi_collector_set_node_id()` API) is still
present, and that the dropped probe-injection symbols stay absent
(grep confirms 0 / 27 hits).

Validation in this devcontainer:

- ADR-081 host tests built and ran from `firmware/esp32-csi-node/tests/host/`:
  `test_adaptive_controller` 18/18 pass, `test_rv_feature_state` 15/15
  pass, `test_rv_mesh` 27/27 pass — 60/60 total. These exercise the
  merged-in pure-C logic that this PR has no changes against, so
  they're a regression check that the merge didn't corrupt the
  upstream modules.
- `edge_processing.c` still has `const float sample_rate = 10.0f;`.
- Brace balance and dangling-ref checks on `csi_collector.c` pass.

ESP-IDF firmware build, flash, and miniterm soak still deferred to
@ruvnet's COM7 per the original review comment.

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-04-21 15:30:15 +00:00
Dragan Spiridonov 728a8fd97e fix(firmware): address PR #397 review feedback
Applies @ruvnet's five review requests on PR #397 (RuView#397 comment
4289417527):

1. **Inline comment on `provision.py` `write_flash`** — ESP-IDF v5.4
   bundles esptool 4.10.0 (underscore-only). #391's hyphen swap broke
   the documented venv flow; kept the underscore form and added a
   three-line comment warning future maintainers not to "re-fix" it.

2. **Correct `edge_processing.c` sample_rate** (blocking) — changed
   hard-coded `20.0f` → `10.0f` at line 718 so
   `estimate_bpm_zero_crossing()` matches the MGMT-only CSI rate.
   Without this, breathing and heart-rate reports were 2× the true
   value. Added a comment tying the constant to the callback rate gate.

3. **Removed disabled probe-injection infrastructure** — dropped the
   forward declaration, the `CSI_PROBE_INTERVAL_MS` define, six static
   variables (`s_probe_timer`, `s_probe_tx_count`, `s_probe_tx_fail`,
   `s_ap_bssid`, `s_ap_bssid_known`), and three functions
   (`csi_send_probe_request`, `probe_timer_cb`,
   `csi_collector_start_probe_timer`). None were reachable.
   `csi_inject_ndp_frame()` reverted to the original ADR-029 stub.
   Can be revived from this commit's parent if needed.

4. **Cleaned `sdkconfig.defaults`** — removed the SPIRAM prose and
   commented-out `# CONFIG_SPIRAM is not set` line. Kept only the live
   `CONFIG_ESP_WIFI_EXTRA_IRAM_OPT=y` with a concise rationale.

5. **Bumped firmware version 0.6.1 → 0.6.2** and added four
   `[Unreleased]` CHANGELOG entries covering the SPI cache crash fix,
   the `filter_mac` / `node_id` clobber defense, the sample-rate
   correction, and the `write_flash` command-form revert.

Net: +39 / -128 across six files.

Validation in this devcontainer:
- Static sanity on modified C files: braces balance (csi_collector.c
  59/59; edge_processing.c 96/96), zero dangling references to removed
  probe-injection symbols.
- Rust workspace tests and Python proof not executed here — cargo not
  installed and pip blocked by PEP 668. Deferring hardware build +
  flash + miniterm verification to @ruvnet's COM7 per his offer in
  the review comment.

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-04-21 15:02:14 +00:00
ruv a426ae386d Fix ADR-081 Timer Svc stack overflow on ESP32-S3
emit_feature_state() runs inside the FreeRTOS Timer Svc task via the
fast loop callback; it memsets an rv_feature_state_t, queries vitals/
radio, and sends via stream_sender (lwIP sendto). Default Timer Svc
stack is 2 KiB, which overflows and panics ~1 s after boot:

  ***ERROR*** A stack overflow in task Tmr Svc has been detected.

Bump CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH to 8 KiB across the three
sdkconfig defaults files (default, template, 4mb). Matches the main
task stack size already in use.

Found during on-device validation on ESP32-S3 (MAC 3c:0f:02:e9:b5:f8)
after flashing the post-merge v0.6.1 build — firmware boots, connects
WiFi, emits one medium tick, then crashes on the fast tick that calls
emit_feature_state().

Follow-up: consider moving emit_feature_state + network I/O out of the
timer daemon into a dedicated worker task (open issue).

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-04-20 10:48:21 -04:00
Dragan Spiridonov 8b60b8cfea fix(firmware): 50 Hz callback rate gate + sdkconfig extra IRAM opt
- Add early rate gate in wifi_csi_callback at 50 Hz (defense-in-depth,
  does not prevent crash alone but reduces callback execution time)
- Add null-data injection timer infrastructure (disabled — TX adds
  interrupt pressure that triggers the SPI cache crash, RuView#396)
- sdkconfig.defaults: add CONFIG_ESP_WIFI_EXTRA_IRAM_OPT=y
- sdkconfig.defaults: document SPIRAM XIP attempt (crashes differently)

Co-Authored-By: Ruflo & AQE
2026-04-16 18:12:49 +02:00
ruv 952f27a1ce fix(firmware): enable CSI in sdkconfig and add build guard (ADR-057)
The committed sdkconfig had CONFIG_ESP_WIFI_CSI_ENABLED disabled, causing
all builds to crash at runtime with "CSI not enabled in menuconfig".
Root cause: sdkconfig.defaults.template existed but ESP-IDF only reads
sdkconfig.defaults (no .template suffix).

Fixes:
- Add sdkconfig.defaults with CONFIG_ESP_WIFI_CSI_ENABLED=y
- Add #error compile guard in csi_collector.c to prevent recurrence
- Fix NVS encryption default (requires eFuse, breaks clean builds)

Verified: Docker build + flash to ESP32-S3 + CSI callbacks confirmed.

Closes #241
Relates to #223, #238, #234, #210, #190

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-03-12 13:49:20 -04:00