Files
pyxis/sdkconfig.defaults
T
torlando-tech e343caf2d2 Stability: WDT yield, BLE mutex fixes, time-based desync recovery
Reduces crash rate from every 60-85s to 1 reboot per 6+ minutes.
Zero WDT triggers in 10-minute stability test.

BLE mutex fixes (BLEInterface.cpp):
- Release _mutex before blocking GATT ops in onConnected() and
  onServicesDiscovered() — prevents 5-30s main-loop stalls during
  service discovery, notification subscribe, identity exchange
- Non-blocking try_lock() for peerCount(), getConnectedPeerSummaries(),
  get_stats() — returns empty/default if BLE task holds mutex
- Write-without-response in initiateHandshake()

WDT and persistence (main.cpp, sdkconfig.defaults, microReticulum):
- 30s WDT timeout (up from 10s) for SPIFFS flash I/O headroom
- Register Identity::set_persist_yield_callback() to feed WDT every
  5 entries during save_known_destinations() (70+ entries = 30-50s)
- WDT feeds between reticulum and identity persist calls

BLE host desync recovery (NimBLEPlatform):
- Time-based desync tracking instead of aggressive counter-based reboot
- 60s tolerance without connections, 5 minutes with active connections
  (data still flows over existing BLE mesh links)
- Remove immediate recoverBLEStack() from 574 handler and
  enterErrorRecovery() — let startScan() manage reboot decision
- Increase CONNECTION_COOLDOWN from 3s to 10s to reduce 574 risk
- Increase SCAN_FAIL_RECOVERY_THRESHOLD from 5 to 10

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-23 12:30:30 -05:00

87 lines
3.1 KiB
Plaintext

# Required for Arduino framework
CONFIG_FREERTOS_HZ=1000
# Flash configuration for 8MB
CONFIG_ESPTOOLPY_FLASHSIZE_8MB=y
CONFIG_PARTITION_TABLE_CUSTOM=y
CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv"
# Enable Bluetooth with NimBLE (uses ~100KB less RAM than Bluedroid)
CONFIG_BT_ENABLED=y
CONFIG_BT_NIMBLE_ENABLED=y
CONFIG_BT_BLUEDROID_ENABLED=n
# NimBLE role configuration - enable both central and peripheral for mesh
CONFIG_BT_NIMBLE_ROLE_CENTRAL=y
CONFIG_BT_NIMBLE_ROLE_PERIPHERAL=y
CONFIG_BT_NIMBLE_ROLE_BROADCASTER=y
CONFIG_BT_NIMBLE_ROLE_OBSERVER=y
# NimBLE connection settings
CONFIG_BT_NIMBLE_MAX_CONNECTIONS=3
CONFIG_BT_NIMBLE_MAX_BONDS=10
# NimBLE GATT settings
CONFIG_BT_NIMBLE_ATT_PREFERRED_MTU=517
CONFIG_BT_NIMBLE_GAP_DEVICE_NAME_MAX_LEN=31
# Increase task stack size for stability
CONFIG_BT_NIMBLE_TASK_STACK_SIZE=8192
# Coexistence with WiFi
CONFIG_ESP32_WIFI_SW_COEXIST_ENABLE=y
# Enable C++ exceptions (required for microReticulum)
CONFIG_COMPILER_CXX_EXCEPTIONS=y
CONFIG_COMPILER_CXX_EXCEPTIONS_EMG_POOL_SIZE=0
# Enable PSRAM (8MB external RAM) for zero heap fragmentation
CONFIG_ESP32S3_SPIRAM_SUPPORT=y
CONFIG_SPIRAM=y
CONFIG_SPIRAM_MODE_OCT=y
CONFIG_SPIRAM_SPEED_80M=y
# Configure malloc to use PSRAM
CONFIG_SPIRAM_USE_MALLOC=y
# Allocations smaller than this go to internal RAM (bytes)
# Lowered from 4096 to 64 to move Bytes allocations (16-200 bytes) to PSRAM
# This reduces internal heap fragmentation at cost of slightly slower access
CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=64
# Reserve this much internal RAM for DMA/ISR (bytes)
CONFIG_SPIRAM_MALLOC_RESERVE_INTERNAL=32768
# ============================================================================
# Boot Time Optimizations
# These settings reduce boot time. See BOOT_OPTIMIZATIONS.md for details.
# ============================================================================
# Disable PSRAM memory test at boot (~2 seconds saved for 8MB PSRAM)
# The memory test verifies PSRAM integrity but is redundant for stable hardware.
# To re-enable for debugging: comment out this line or set to y
CONFIG_SPIRAM_MEMTEST=n
# Reduce bootloader log verbosity (saves serial output time)
# Bootloader messages are rarely needed in production
CONFIG_BOOTLOADER_LOG_LEVEL_WARN=y
CONFIG_BOOTLOADER_LOG_LEVEL=2
# Skip ROM bootloader output (saves serial time)
CONFIG_BOOT_ROM_LOG_ALWAYS_OFF=y
# ============================================================================
# FreeRTOS Timer Service Task
# Default 2048 is too small when NimBLE/WiFi timer callbacks run
# ============================================================================
CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=4096
# ============================================================================
# Task Watchdog Timer (TWDT)
# Detects task starvation and deadlock conditions
# 30s timeout accommodates SPIFFS flash I/O during identity persistence
# (writing 40-50 destinations to flash takes 5-15s with GC/erase)
# ============================================================================
CONFIG_ESP_TASK_WDT_EN=y
CONFIG_ESP_TASK_WDT_TIMEOUT_S=30
CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0=y
CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU1=y