Files
firmware/variants/esp32p4/esp32p4.ini
Ben Meadors b565a07a83 Remove proprietary Bosch BSEC blob; open in-tree IAQ estimator for BME680 (#11381)
* Remove proprietary Bosch BSEC blob; open in-tree IAQ estimator for BME680

BSEC2 cost ~37-39 KB flash and ~4-5 KB static RAM on ~190 of ~240 build
targets, linked whether or not a BME680 was attached, and was a no-source
proprietary archive inside GPLv3 release binaries. The firmware consumed
exactly one BSEC-exclusive output: the IAQ value.

- New BME680IaqEstimator: clean-room log-domain baseline tracker
  (humidity-compensated gas resistance vs a rise-fast/decay-slow ceiling,
  0-500 scale matching the existing UI bands), pure math, unit-tested on
  native (test_bme680_iaq, 15 tests incl. a deep-sleep reboot simulation).
  Warm-up/burn-in progress persists to /prefs/bme680.dat via SafeFile so
  one-sample-per-wake SENSOR nodes converge across reboots; stale
  /prefs/bsec.dat is removed once.
- BME680Sensor: single-path rewrite on Adafruit_BME680 with async
  once-per-minute sampling (~20x lower heater duty than BSEC LP mode),
  a hard 2-minute publish-freshness bound (a dead sensor stops reporting
  instead of freezing its last reading on the wire), and suppression of
  bogus gas_resistance=0 points from heater-unstable cycles.
- platformio.ini: environmental_extra_common/_extra/_no_bsec collapsed
  into one section; Bosch BSEC2 + BME68x deps deleted; per-variant BSEC
  link-path hacks and the TEMPORARY promicro lib_ignore removed.
  nrf52_promicro_diy_tcxo regains BME680 support at 36 KB clear of the
  warm-store cap; rak4631 lands at 75 KB clear.
- EnvironmentTelemetry: iaq rendering gates on has_iaq (a genuine IAQ of
  0 now displays); stale BSEC comments rewritten.
- rak4631 size budgets tightened (113000->108000 RAM, 786000->746000
  flash) to lock in the reclaimed headroom.
- bin/bme680_iaq_replay.cpp: host-side replay harness for tuning the
  estimator against captured BSEC traces (mean abs error + band
  agreement), no reflashing needed.

Measured (develop -> this branch): rak4631 -38.8 KB flash / -4.9 KB RAM;
heltec-v3 -36.4 KB / -4.0 KB; tlora-v2-1-1_6 +1.3 KB (its IAQ
approximation had been dead code since #9663 due to an inverted isfinite
check and now actually runs).

Note: gas_resistance stays kOhm on the wire for fleet compatibility; the
proto comment claiming MOhm gets a separate meshtastic/protobufs docs PR.

* Address CodeRabbit review feedback

- Use Throttle::isWithinTimespanMs for all elapsed-time predicates in
  BME680Sensor per coding guidelines (deadline math for the async reading
  completion stays raw, as it targets an absolute timestamp)
- Make the state file name members static constexpr
- Replay tool: cast uint16_t before %u (default argument promotion), report
  malformed input lines instead of silently skipping, and fail non-zero on
  stream read errors

* Address CodeRabbit nitpicks

- Replace the local clampf helper with std::clamp (meshUtils.h's clamp drags
  in Arduino.h, which would break the estimator's standalone host build that
  the replay harness depends on)
- Trim the replay tool's file header to a two-line summary; the full build,
  capture, and tuning workflow moves to docs/bme680_iaq_replay.md
2026-08-13 13:21:16 -04:00

111 lines
3.7 KiB
INI

[esp32p4_base]
extends = esp32_common
custom_esp32_kind = esp32p4
board_build.mcu = esp32p4
build_unflags=
-DHAS_UDP_MULTICAST=1
build_flags =
${esp32_common.build_flags}
-DMESHTASTIC_EXCLUDE_WIFI=1 ; TODO
-DMESHTASTIC_EXCLUDE_MQTT=1
-DMESHTASTIC_EXCLUDE_PAXCOUNTER=1
build_src_filter =
${esp32_common.build_src_filter} -<libpax/> +<platform/esp32> -<mesh/raspihttp> -<serialization/>
; ld_response_file.py is inherited from esp32_common (promoted there when
; rak_wismesh_tap_v2-tft outgrew the exec arg limit; it originally shipped here).
extra_scripts =
${esp32_common.extra_scripts}
; Override esp32_common component pruning: keep esp_hosted + esp_wifi_remote for P4 hosted BT
custom_component_remove =
espressif/esp_modem
espressif/esp-dsp
espressif/esp32-camera
espressif/libsodium
espressif/esp-modbus
espressif/qrcode
espressif/esp_insights
espressif/esp_diag_data_store
espressif/esp_diagnostics
espressif/esp_rainmaker
espressif/rmaker_common
espressif/network_provisioning
chmorgan/esp-libhelix-mp3
espressif/esp-tflite-micro
espressif/esp-sr
espressif/esp_matter
espressif/esp-zboss-lib
espressif/esp-zigbee-lib
espressif/mqtt
custom_sdkconfig =
${esp32_common.custom_sdkconfig}
CONFIG_ARDUINO_SELECTIVE_SD_MMC=y
CONFIG_BT_CONTROLLER_DISABLED=y
CONFIG_ESP_WIFI_REMOTE_ENABLED=y
# esp_hosted core
CONFIG_ESP_HOSTED_ENABLED=y
# Board: custom (not Espressif EV board)
CONFIG_ESP_HOSTED_P4_DEV_BOARD_NONE=y
# Delay after C6 reset to allow boot (e.g. old v2.3.0 may be slow)
CONFIG_ESP_HOSTED_SDIO_RESET_DELAY_MS=1500
CONFIG_ESP_HOSTED_SDIO_OPTIMIZATION_RX_STREAMING_MODE=y
CONFIG_ESP_HOSTED_SDIO_HOST_INTERFACE=y
CONFIG_ESP_HOSTED_IDF_SLAVE_TARGET="esp32c6"
CONFIG_ESP_HOSTED_CP_TARGET_ESP32C6=y
CONFIG_ESP_HOSTED_CP_TARGET_ESP32H2=n
CONFIG_ESP_HOSTED_PRIV_SDIO_OPTION=y
CONFIG_ESP_HOSTED_SPI_HOST_INTERFACE=n
CONFIG_ESP_HOSTED_TRANSPORT_SDIO=y
CONFIG_ESP_HOSTED_ENABLE_NIMBLE=y
CONFIG_ESP_HOSTED_ENABLE_BT_NIMBLE=y
CONFIG_ESP_HOSTED_NIMBLE_HCI_VHCI=y
CONFIG_ESP_HOSTED_ENABLE_PEER_DATA_TRANSFER=y
CONFIG_ESP_HOSTED_MAX_CUSTOM_MSG_HANDLERS=3
# OTA method: LittleFS
CONFIG_OTA_METHOD_LITTLEFS=y
# Skip version check - we force OTA regardless
# CONFIG_OTA_VERSION_CHECK_HOST_SLAVE is not set
# CONFIG_OTA_VERSION_CHECK_SLAVEFW_SLAVE is not set
# RX streaming mode
CONFIG_ESP_HOSTED_SLAVE_RESET_ON_EVERY_HOST_BOOTUP=y
;CONFIG_ESP_HOSTED_SLAVE_RESET_ONLY_IF_NECESSARY=y
# SOC_LCD (MUI / lovyanGFX)
CONFIG_SOC_LCD_I80_SUPPORTED=y
CONFIG_SOC_LCD_RGB_SUPPORTED=y
CONFIG_SOC_MIPI_DSI_SUPPORTED=y
# stack dump
CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT=y ; remove for production version
;CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT=y; for production version
;CONFIG_ESP_SYSTEM_PANIC_GDBSTUB=y ; for target debugging
# Logger: verbose for experiment
CONFIG_LOG_DEFAULT_LEVEL_INFO=y
CONFIG_LOG_MAXIMUM_LEVEL_DEBUG=y
lib_ignore =
${esp32_common.lib_ignore}
libpax
esp8266-oled-ssd1306
esp32_idf5_https_server
esp_driver_cam
esp_http_server
; Override lib_deps to exclude environmental_extras
lib_deps =
${arduino_base.lib_deps}
${networking_base.lib_deps}
${networking_extra.lib_deps}
${environmental_base.lib_deps}
${radiolib_base.lib_deps}
# renovate: datasource=git-refs depName=meshtastic/Crypto packageName=https://github.com/meshtastic/Crypto gitBranch=main
https://github.com/meshtastic/Crypto/archive/591ff9a690e8168ccb7a36abde8d7783e448d395.zip
# renovate: datasource=git-refs depName=meshtastic-ESP32_Codec2 packageName=https://github.com/meshtastic/ESP32_Codec2 gitBranch=master
https://github.com/meshtastic/ESP32_Codec2/archive/633326c78ac251c059ab3a8c430fcdf25b41672f.zip