sdkconfig.defaults.bt 2.7 KB

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