feat(bt): Add initial support of Bluetooth Classic on ESP32-S31

- feat(soc_caps): Enable BT Classic and BLE in esp32s31
- Add git submodule for ESP32-S31 bt controller lib files
- changed sdkconfig.defaults and README for Bluetooth Classic examples
- change(docs): Added vendor HCI documentations for ESP32-S31
- change(Bluedroid): Adapt to ESP32-S31 due to some API differences on
  Bluetooth controller from ESP32
- change(bt): Modify CMakeLists.txt to support the Bluetooth dual-mode
  architecture on ESP32-S31
- change(bt): Add ECC P-192 functions to tinycrypt
This commit is contained in:
wangmengyang
2026-04-21 17:50:34 +08:00
committed by Wang Mengyang
parent 9c2bde6b64
commit 11268d8bfb
95 changed files with 5312 additions and 165 deletions
@@ -1,5 +1,5 @@
| Supported Targets | ESP32 |
| ----------------- | ----- |
| Supported Targets | ESP32 | ESP32-S31 |
| ----------------- | ----- | --------- |
A2DP-SINK-STREAM EXAMPLE
======================
@@ -5,4 +5,5 @@ CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY=y
CONFIG_BT_BLUEDROID_ENABLED=y
CONFIG_BT_CLASSIC_ENABLED=y
CONFIG_BT_A2DP_ENABLE=y
CONFIG_BT_BLE_ENABLED=n
CONFIG_DAC_DMA_AUTO_16BIT_ALIGN=n
@@ -0,0 +1,2 @@
CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE=y
CONFIG_EXAMPLE_A2DP_SINK_OUTPUT_IDLE=y
@@ -1,5 +1,5 @@
| Supported Targets | ESP32 |
| ----------------- | ----- |
| Supported Targets | ESP32 | ESP32-S31 |
| ----------------- | ----- | --------- |
A2DP-SOURCE EXAMPLE
========================
@@ -7,3 +7,4 @@ CONFIG_BTDM_CTRL_MODE_BTDM=n
CONFIG_BT_BLUEDROID_ENABLED=y
CONFIG_BT_CLASSIC_ENABLED=y
CONFIG_BT_A2DP_ENABLE=y
CONFIG_BT_BLE_ENABLED=n
@@ -0,0 +1 @@
CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE=y
@@ -1,5 +1,5 @@
| Supported Targets | ESP32 |
| ----------------- | ----- |
| Supported Targets | ESP32 | ESP32-S31 |
| ----------------- | ----- | --------- |
AVRCP-ABSOLUTE-VOLUME EXAMPLE
======================
@@ -5,4 +5,5 @@ CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY=y
CONFIG_BT_BLUEDROID_ENABLED=y
CONFIG_BT_CLASSIC_ENABLED=y
CONFIG_BT_A2DP_ENABLE=y
CONFIG_BT_BLE_ENABLED=n
CONFIG_DAC_DMA_AUTO_16BIT_ALIGN=n
@@ -0,0 +1,2 @@
CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE=y
CONFIG_EXAMPLE_A2DP_SINK_OUTPUT_IDLE=y
@@ -1,5 +1,5 @@
| Supported Targets | ESP32 |
| ----------------- | ----- |
| Supported Targets | ESP32 | ESP32-S31 |
| ----------------- | ----- | --------- |
AVRCP-CT-COVER-ART EXAMPLE
======================
@@ -6,6 +6,7 @@ CONFIG_BT_BLUEDROID_ENABLED=y
CONFIG_BT_CLASSIC_ENABLED=y
CONFIG_BT_A2DP_ENABLE=y
CONFIG_BT_AVRCP_CT_COVER_ART_ENABLED=y
CONFIG_BT_BLE_ENABLED=n
CONFIG_DAC_DMA_AUTO_16BIT_ALIGN=n
CONFIG_SPIRAM=y
CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE=y
@@ -0,0 +1,2 @@
CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE=y
CONFIG_EXAMPLE_A2DP_SINK_OUTPUT_IDLE=y
@@ -1,5 +1,5 @@
| Supported Targets | ESP32 |
| ----------------- | ----- |
| Supported Targets | ESP32 | ESP32-S31 |
| ----------------- | ----- | --------- |
AVRCP-CT-METADATA EXAMPLE
======================
@@ -5,4 +5,5 @@ CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY=y
CONFIG_BT_BLUEDROID_ENABLED=y
CONFIG_BT_CLASSIC_ENABLED=y
CONFIG_BT_A2DP_ENABLE=y
CONFIG_BT_BLE_ENABLED=n
CONFIG_DAC_DMA_AUTO_16BIT_ALIGN=n
@@ -0,0 +1,2 @@
CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE=y
CONFIG_EXAMPLE_A2DP_SINK_OUTPUT_IDLE=y
@@ -1,5 +1,5 @@
| Supported Targets | ESP32 |
| ----------------- | ----- |
| Supported Targets | ESP32 | ESP32-S31 |
| ----------------- | ----- | --------- |
# ESP-IDF BT-DISCOVERY Example
@@ -0,0 +1 @@
CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE=y
@@ -1,5 +1,5 @@
| Supported Targets | ESP32 |
| ----------------- | ----- |
| Supported Targets | ESP32 | ESP32-S31 |
| ----------------- | ----- | --------- |
# Bluetooth HID Device example
@@ -178,7 +178,7 @@ void app_main(void) {
}
```
Report Mode can be choosen by remote HID Host through the SET_PROTOCOL request:
Report Mode can be chosen by remote HID Host through the SET_PROTOCOL request:
```
void esp_bt_hidd_cb(esp_hidd_cb_event_t event, esp_hidd_cb_param_t *param)
@@ -5,3 +5,4 @@ CONFIG_BTDM_CTRL_MODE_BTDM=n
CONFIG_BT_CLASSIC_ENABLED=y
CONFIG_BT_HID_ENABLED=y
CONFIG_BT_HID_DEVICE_ENABLED=y
CONFIG_BT_BLE_ENABLED=n
@@ -0,0 +1 @@
CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE=y
@@ -1,5 +1,5 @@
| Supported Targets | ESP32 |
| ----------------- | ----- |
| Supported Targets | ESP32 | ESP32-S31 |
| ----------------- | ----- | --------- |
ESP-IDF BT-L2CAP-CLIENT EXAMPLE
===================================
@@ -48,7 +48,7 @@ See the [Getting Started Guide](https://docs.espressif.com/projects/esp-idf/en/l
For the first step, this example performs device discovery to search for a target device whose device name is "ESP_BT_L2CAP_SERVER". If a candidate target is found, the local device will initiate connection with it.
When you run this example, the explain prints the following at the very begining:
When you run this example, the explain prints the following at the very beginning:
```
I (1383) L2CAP_TAG: ESP_BT_L2CAP_INIT_EVT: status:0
@@ -8,3 +8,4 @@ CONFIG_BT_BLUEDROID_ENABLED=y
CONFIG_BT_CLASSIC_ENABLED=y
CONFIG_BT_L2CAP_ENABLED=y
CONFIG_BT_SDP_COMMON_ENABLED=y
CONFIG_BT_BLE_ENABLED=n
@@ -0,0 +1 @@
CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE=y
@@ -1,5 +1,5 @@
| Supported Targets | ESP32 |
| ----------------- | ----- |
| Supported Targets | ESP32 | ESP32-S31 |
| ----------------- | ----- | --------- |
ESP-IDF BT-L2CAP-SERVER EXAMPLE
===================================
@@ -48,7 +48,7 @@ See the [Getting Started Guide](https://docs.espressif.com/projects/esp-idf/en/l
After the program is started, the example starts inquiry scan and page scan, awaiting being discovered and connected. Other bluetooth devices can discover a device named "ESP_BT_L2CAP_SERVER". ESP-IDF examples for other L2CAP client can be used to connect to the local device.
When you run this example, the explain prints the following at the very begining:
When you run this example, the explain prints the following at the very beginning:
```
I (1398) L2CAP_TAG: ESP_BT_L2CAP_INIT_EVT: status:0
@@ -8,3 +8,4 @@ CONFIG_BT_BLUEDROID_ENABLED=y
CONFIG_BT_CLASSIC_ENABLED=y
CONFIG_BT_L2CAP_ENABLED=y
CONFIG_BT_SDP_COMMON_ENABLED=y
CONFIG_BT_BLE_ENABLED=n
@@ -0,0 +1 @@
CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE=y
@@ -1,5 +1,5 @@
| Supported Targets | ESP32 |
| ----------------- | ----- |
| Supported Targets | ESP32 | ESP32-S31 |
| ----------------- | ----- | --------- |
## ESP-IDF BT-SPP-ACCEPTOR demo
@@ -50,7 +50,7 @@ See the [Getting Started Guide](https://docs.espressif.com/projects/esp-idf/en/l
## Example Description
After the program starts, the example will start an SPP acceptor. The example will calculate the data rate or just print the received data after the SPP connection is established. You can connect to the server and send data with another ESP32 development board, Andriod phone or computer which performs as the SPP initiator.
After the program starts, the example will start an SPP acceptor. The example will calculate the data rate or just print the received data after the SPP connection is established. You can connect to the server and send data with another ESP32 development board, Android phone or computer which performs as the SPP initiator.
## Trouble shooting
@@ -0,0 +1 @@
CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE=y
@@ -1,5 +1,5 @@
| Supported Targets | ESP32 |
| ----------------- | ----- |
| Supported Targets | ESP32 | ESP32-S31 |
| ----------------- | ----- | --------- |
# ESP-IDF BT-SPP-INITATOR demo
@@ -52,10 +52,10 @@ When you run this example and the IO capability is `ESP_IO_CAP_IO` or `ESP_IO_CA
Supported commands are as follows, arguments are embraced with < and >
spp h; -- show command manual
Use this cmmand table if the IO Capability of local device set as IO_CAP_IO.
Use this command table if the IO Capability of local device set as IO_CAP_IO.
spp ok; -- manual Numeric Confirmation.
Use this cmmand table if the IO Capability of local device set as IO_CAP_IN.
Use this command table if the IO Capability of local device set as IO_CAP_IN.
spp key <auth key>; -- manual Passkey. (e.g. spp key 136245;)
########################################################################
@@ -127,7 +127,7 @@ Q: How to change the process of SSP?
A: Users can set the IO Capability and Security Mask for their device (fixed Security Mode, Security Mode 4). In short, the Security Mask sets the security level for authentication stage and the IO Capability determines the way of user interaction during pairing. The default Security Mask of this demo is `ESP_SPP_SEC_AUTHENTICATE` which support MITM (Man In The Middle) protection. For more information about Security Simple Pair on ESP32, please refer to [ESP32_SSP](../bt_spp_acceptor/ESP32_SSP.md).
Q: How can we reach the maximum throughput when using SPP?
A: The default MTU size of classic Bluetooth SPP on ESP32 is 990 bytes, and higher throughput can be achieved in the case that data chunck size is close to the MTU size or multiple of MTU size. For example, sending 100 bytes data per second is much better than sending 10 bytes every 100 milliseconds.
A: The default MTU size of classic Bluetooth SPP on ESP32 is 990 bytes, and higher throughput can be achieved in the case that data chunk size is close to the MTU size or multiple of MTU size. For example, sending 100 bytes data per second is much better than sending 10 bytes every 100 milliseconds.
Q: What is the difference between the event `ESP_SPP_CONG_EVT` and the parameter `cong` of the event `ESP_SPP_WRITE_EVT`?
A: The event `ESP_SPP_CONG_EVT` shows the changing status from `congest` to `uncongest`, or form `uncongest` to `congest`. Congestion can have many causes, such as using out of the credit which is sent by peer, reaching the high watermark of the Tx buffer, the congestion at Bluetooth L2CAP layer and so on. The parameter `cong` of the event `ESP_SPP_WRITE_EVT` shows a snapshot of the state of the flow control manager after the write operation is completed. The user needs to carefully consider retransmitting or continuing to write according to these two events. The ESP32 offers an VFS mode of SPP which hides the details of retransmitting, but it will block the caller and is not more efficient than the callback mode.
@@ -0,0 +1 @@
CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE=y
@@ -1,5 +1,5 @@
| Supported Targets | ESP32 |
| ----------------- | ----- |
| Supported Targets | ESP32 | ESP32-S31 |
| ----------------- | ----- | --------- |
## ESP-IDF BT-SPP-VFS-ACCEPTOR demo
@@ -50,7 +50,7 @@ See the [Getting Started Guide](https://docs.espressif.com/projects/esp-idf/en/l
## Example Description
After the program starts, the example will start an SPP acceptor. The example will print the received data after the SPP connection is established. You can connect to the server and send data with another ESP32 development board, Andriod phone or computer which performs as the SPP initiator.
After the program starts, the example will start an SPP acceptor. The example will print the received data after the SPP connection is established. You can connect to the server and send data with another ESP32 development board, Android phone or computer which performs as the SPP initiator.
## FAQ
Please refer the FAQ part in the [README.md](../bt_spp_acceptor/README.md)
@@ -0,0 +1 @@
CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE=y
@@ -1,5 +1,5 @@
| Supported Targets | ESP32 |
| ----------------- | ----- |
| Supported Targets | ESP32 | ESP32-S31 |
| ----------------- | ----- | --------- |
# ESP-IDF BT-SPP-INITATOR demo
@@ -0,0 +1 @@
CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE=y
@@ -1,5 +1,5 @@
| Supported Targets | ESP32 |
| ----------------- | ----- |
| Supported Targets | ESP32 | ESP32-S31 |
| ----------------- | ----- | --------- |
# Hands-Free Audio Gateway (HF-AG)
@@ -10,6 +10,8 @@
#include "gpio_pcm_config.h"
#include "esp_rom_gpio.h"
#if CONFIG_BT_HFP_AUDIO_DATA_PATH_PCM
#define GPIO_OUTPUT_PCM_FSYNC (25)
#define GPIO_OUTPUT_PCM_CLK_OUT (5)
#define GPIO_OUTPUT_PCM_DOUT (26)
@@ -56,6 +58,8 @@ void app_gpio_pcm_io_cfg(void)
esp_rom_gpio_connect_in_signal(GPIO_INPUT_PCM_DIN, PCMDIN_IDX, false);
}
#endif /* #if CONFIG_BT_HFP_AUDIO_DATA_PATH_PCM */
#if ACOUSTIC_ECHO_CANCELLATION_ENABLE
#define GPIO_OUTPUT_AEC_1 (19)
@@ -0,0 +1,3 @@
CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE=y
CONFIG_BT_CTRL_BR_EDR_MAX_SYNC_CONN=1
CONFIG_BT_HFP_AUDIO_DATA_PATH_HCI=y
@@ -1,5 +1,5 @@
| Supported Targets | ESP32 |
| ----------------- | ----- |
| Supported Targets | ESP32 | ESP32-S31 |
| ----------------- | ----- | --------- |
# Hands-Free Client
@@ -364,4 +364,4 @@ Due to the complexity of HFP, this example has more source files than other blue
- For voice interface, ESP32 has provided PCM input/output signals which can be mapped to GPIO pins. So, please go to `gpio_pcm_config.c` for the configuration details.
- If you want to update the command table, please refer to `app_hf_msg_set.c`.
- If you want to update the responses of HF Unit or want to update the log, please refer to `bt_app_hf.c`.
- Task configuration part is in `bt_app_core.c`.
- Task configuration part is in `bt_app_core.c`.
@@ -10,6 +10,8 @@
#include "gpio_pcm_config.h"
#include "esp_rom_gpio.h"
#if CONFIG_BT_HFP_AUDIO_DATA_PATH_PCM
#define GPIO_OUTPUT_PCM_FSYNC (25)
#define GPIO_OUTPUT_PCM_CLK_OUT (5)
#define GPIO_OUTPUT_PCM_DOUT (26)
@@ -55,6 +57,7 @@ void app_gpio_pcm_io_cfg(void)
esp_rom_gpio_connect_out_signal(GPIO_OUTPUT_PCM_DOUT, PCMDOUT_IDX, false, false);
esp_rom_gpio_connect_in_signal(GPIO_INPUT_PCM_DIN, PCMDIN_IDX, false);
}
#endif /* #if CONFIG_BT_HFP_AUDIO_DATA_PATH_PCM */
#if ACOUSTIC_ECHO_CANCELLATION_ENABLE
@@ -0,0 +1,3 @@
CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE=y
CONFIG_BT_CTRL_BR_EDR_MAX_SYNC_CONN=1
CONFIG_BT_HFP_AUDIO_DATA_PATH_HCI=y