Ruview/firmware/esp32-csi-node/main
ruv 425f0e6aac fix(firmware): defensive node_id capture prevents runtime clobber (#390)
Users on multi-node ESP32 deployments have been reporting for months
that their provisioned `node_id` reverts to the Kconfig default of `1`
in UDP frames and the `csi_collector` init log, despite boot showing:

    nvs_config: NVS override: node_id=4
    main: ESP32-S3 CSI Node (ADR-018) - Node ID: 4
    csi_collector: CSI collection initialized (node_id=1, channel=11)

See #232, #375, #385, #386, #390. The root memory-corruption path for
the `g_nvs_config.node_id` byte has not been definitively isolated
(does not reproduce on my attached ESP32-S3 running current source
and the v0.6.0 release binary), but the UDP frame header can be made
tamper-proof regardless:

1. `csi_collector_init()` now captures `g_nvs_config.node_id` into a
   module-local `static uint8_t s_node_id` at init time.
2. `csi_serialize_frame()` reads `buf[4]` from `s_node_id`, not from
   the global - so any later corruption of `g_nvs_config` cannot
   affect outgoing CSI frames.
3. All other consumers (`edge_processing.c` x3, `wasm_runtime.c`,
   `display_ui.c`, `main.c swarm_bridge_init`) now go through a new
   `csi_collector_get_node_id()` accessor instead of reading the
   global directly.
4. A canary at end-of-init logs `WARN` if `g_nvs_config.node_id`
   already diverges from the captured value - this will pinpoint
   the corruption path if it happens on a user's device.

Hardware validation on attached ESP32-S3 (COM8):
  - NVS loads node_id=2
  - Boot log: `main: ... Node ID: 2`
  - NEW log: `csi_collector: Captured node_id=2 at init (defensive
    copy for #232/#375/#385/#390)`
  - Init log: `csi_collector: CSI collection initialized (node_id=2)`
  - UDP frame byte[4] = 2 (verified via socket sniffer, 15/15 packets)

This is defense in depth - it shields the UDP frame from whatever
upstream bug is clobbering the struct. When a user hits the original
bug, the canary WARN will help isolate the root cause.

Refs #232 #375 #385 #386 #390

Co-Authored-By: claude-flow <ruv@ruv.net>
2026-04-15 13:47:34 -04:00
..
CMakeLists.txt feat: happiness scoring pipeline + ESP32 swarm with Cognitum Seed (#285) 2026-03-20 18:46:34 -04:00
csi_collector.c fix(firmware): defensive node_id capture prevents runtime clobber (#390) 2026-04-15 13:47:34 -04:00
csi_collector.h fix(firmware): defensive node_id capture prevents runtime clobber (#390) 2026-04-15 13:47:34 -04:00
display_hal.c docs: update README with ADR-045–048, Observatory, adaptive classifier, AMOLED display 2026-03-05 10:20:48 -05:00
display_hal.h docs: update README with ADR-045–048, Observatory, adaptive classifier, AMOLED display 2026-03-05 10:20:48 -05:00
display_task.c fix: remove unsafe exec() in display_task.c 2026-03-26 04:08:00 +00:00
display_task.h docs: update README with ADR-045–048, Observatory, adaptive classifier, AMOLED display 2026-03-05 10:20:48 -05:00
display_ui.c fix(firmware): defensive node_id capture prevents runtime clobber (#390) 2026-04-15 13:47:34 -04:00
display_ui.h docs: update README with ADR-045–048, Observatory, adaptive classifier, AMOLED display 2026-03-05 10:20:48 -05:00
edge_processing.c fix(firmware): defensive node_id capture prevents runtime clobber (#390) 2026-04-15 13:47:34 -04:00
edge_processing.h feat: ADR-069 ESP32 CSI → Cognitum Seed RVF pipeline (v0.5.4-esp32) 2026-04-02 19:32:18 -04:00
idf_component.yml docs: update README with ADR-045–048, Observatory, adaptive classifier, AMOLED display 2026-03-05 10:20:48 -05:00
Kconfig.projbuild fix: embed firmware version from version.txt, log at boot (#354) 2026-04-06 11:26:58 -04:00
lv_conf.h docs: update README with ADR-045–048, Observatory, adaptive classifier, AMOLED display 2026-03-05 10:20:48 -05:00
main.c fix(firmware): defensive node_id capture prevents runtime clobber (#390) 2026-04-15 13:47:34 -04:00
mmwave_sensor.c feat: ADR-063/064 mmWave sensor fusion + multimodal ambient intelligence (#269) 2026-03-15 16:10:10 -04:00
mmwave_sensor.h feat: ADR-063/064 mmWave sensor fusion + multimodal ambient intelligence (#269) 2026-03-15 16:10:10 -04:00
mock_csi.c feat: QEMU ESP32-S3 testing platform + swarm configurator (ADR-061/062) (#260) 2026-03-14 13:39:51 -04:00
mock_csi.h feat: QEMU ESP32-S3 testing platform + swarm configurator (ADR-061/062) (#260) 2026-03-14 13:39:51 -04:00
nvs_config.c feat: happiness scoring pipeline + ESP32 swarm with Cognitum Seed (#285) 2026-03-20 18:46:34 -04:00
nvs_config.h feat: happiness scoring pipeline + ESP32 swarm with Cognitum Seed (#285) 2026-03-20 18:46:34 -04:00
ota_update.c fix: security hardening — replace fake HMAC, add path traversal protection, OTA auth (ADR-050) 2026-03-06 13:11:04 -05:00
ota_update.h feat: complete vendor repos, add edge intelligence and WASM modules 2026-03-02 23:53:25 -05:00
power_mgmt.c feat: complete vendor repos, add edge intelligence and WASM modules 2026-03-02 23:53:25 -05:00
power_mgmt.h feat: complete vendor repos, add edge intelligence and WASM modules 2026-03-02 23:53:25 -05:00
rvf_parser.c feat: complete vendor repos, add edge intelligence and WASM modules 2026-03-02 23:53:25 -05:00
rvf_parser.h feat: complete vendor repos, add edge intelligence and WASM modules 2026-03-02 23:53:25 -05:00
stream_sender.c fix: rate-limit CSI sends and add ENOMEM backoff to prevent crash (#132) 2026-03-03 16:00:40 -05:00
stream_sender.h fix(docker): Update Dockerfile paths from src/ to v1/src/ 2026-02-28 13:38:21 -05:00
swarm_bridge.c feat: happiness scoring pipeline + ESP32 swarm with Cognitum Seed (#285) 2026-03-20 18:46:34 -04:00
swarm_bridge.h feat: happiness scoring pipeline + ESP32 swarm with Cognitum Seed (#285) 2026-03-20 18:46:34 -04:00
wasm_runtime.c fix(firmware): defensive node_id capture prevents runtime clobber (#390) 2026-04-15 13:47:34 -04:00
wasm_runtime.h feat: complete vendor repos, add edge intelligence and WASM modules 2026-03-02 23:53:25 -05:00
wasm_upload.c fix: security hardening — replace fake HMAC, add path traversal protection, OTA auth (ADR-050) 2026-03-06 13:11:04 -05:00
wasm_upload.h feat: complete vendor repos, add edge intelligence and WASM modules 2026-03-02 23:53:25 -05:00