# Bluetooth A2DP Sink defaults (ESP32 Classic BT only) # Include this in sdkconfig for boards that support Classic Bluetooth. # These options are ignored on ESP32-S3/C3/etc which lack Classic BT. # # To enable: Component config → Bluetooth → then these are set automatically. CONFIG_BT_ENABLED=y CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY=y CONFIG_BT_BLUEDROID_ENABLED=y CONFIG_BT_CLASSIC_ENABLED=y CONFIG_BT_A2DP_ENABLE=y CONFIG_ESP_COEX_SW_COEXIST_ENABLE=y # Security Setup # SSP requires a screen on the device to show the code CONFIG_BT_SSP_ENABLED=n CONFIG_BT_PIN_CODE="05032026" # Disable BLE host stack — A2DP uses Classic BT only. Disabling BLE avoids # compiling GATT server/client, SMP and L2CAP-BLE, recovering ~30-40 KB DRAM. CONFIG_BT_BLE_ENABLED=n # Only one A2DP connection at a time — reduce from defaults to save DRAM. # BR/EDR ACL: 1.2 KB per connection (default 2 → 1 saves 1.2 KB) # Bluedroid ACL: default 4 → 1 CONFIG_BTDM_CTRL_BR_EDR_MAX_ACL_CONN=1 CONFIG_BT_ACL_CONNECTIONS=1 # Allow Bluedroid to allocate from SPIRAM first, freeing internal DRAM for # timers, DMA buffers and WiFi. Fixes osi_alarm_new OOM crash when WiFi + # Classic BT are both active. CONFIG_BT_ALLOCATION_FROM_SPIRAM_FIRST=y # Reduce WiFi buffer pressure — AirPlay is stopped while BT is streaming, # so lower counts are safe and recover ~20 KB of internal DRAM. CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM=6 CONFIG_ESP_WIFI_DYNAMIC_RX_BUFFER_NUM=16 CONFIG_ESP_WIFI_DYNAMIC_TX_BUFFER_NUM=16 # RX BA window must be ≤ 2 × STATIC_RX_BUFFER_NUM CONFIG_ESP_WIFI_RX_BA_WIN=6 # Bluedroid creates many software timers; the default queue of 10 is # borderline. Increase to avoid commands backing up. CONFIG_FREERTOS_TIMER_QUEUE_LENGTH=16 # Push allocations > 1024 bytes to SPIRAM, keeping internal DRAM free for # semaphores, DMA descriptors and WiFi management structures that *must* # live in internal DRAM. Default is 16384 — far too aggressive when BT # already consumes ~100 KB of the ~320 KB budget. CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL=1024 # Smaller TCP windows — BT/WiFi coexistence halves radio bandwidth, # so the default 4×MSS buffers waste memory. 2×MSS is sufficient. CONFIG_LWIP_TCP_SND_BUF_DEFAULT=2880 CONFIG_LWIP_TCP_WND_DEFAULT=2880 # Reduce IRAM usage: WiFi ISR optimisations moved to flash (saves ~12 KB) CONFIG_ESP_WIFI_IRAM_OPT=n CONFIG_ESP_WIFI_RX_IRAM_OPT=n # Compiler optimization — use size optimization to reduce IRAM pressure # (especially important when BT is enabled on ESP32) CONFIG_COMPILER_OPTIMIZATION_SIZE=y # Reduce IRAM usage: move non-critical code to flash CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH=y CONFIG_RINGBUF_PLACE_FUNCTIONS_INTO_FLASH=y CONFIG_BTDM_CTRL_HLI=n CONFIG_HEAP_PLACE_FUNCTION_INTO_FLASH=y