Skip to content

Commit 8f7a904

Browse files
committed
esp32: update BLE sources
Apply changes needed after syncing hal to latest. Signed-off-by: Sylvio Alves <[email protected]>
1 parent 89e8e90 commit 8f7a904

File tree

2 files changed

+108
-42
lines changed

2 files changed

+108
-42
lines changed

zephyr/esp32/include/bt/esp_bt.h

Lines changed: 96 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ extern "C" {
5454
*
5555
* @note Please do not modify this value.
5656
*/
57-
#define ESP_BT_CONTROLLER_CONFIG_MAGIC_VAL 0x20240722
57+
#define ESP_BT_CONTROLLER_CONFIG_MAGIC_VAL 0x20241024
5858

5959
#if defined(CONFIG_BT_CTLR_TX_PWR_PLUS_9)
6060
#define ESP32_RADIO_TXP_DEFAULT ESP_PWR_LVL_P9
@@ -199,12 +199,37 @@ the adv packet will be discarded until the memory is restored. */
199199
#define BTDM_CTRL_SCAN_BACKOFF_UPPERLIMITMAX 0
200200
#endif
201201

202-
#define BT_TASK_EXTRA_STACK_SIZE 512
203-
#define ESP_TASK_BT_CONTROLLER_STACK (3584 + BT_TASK_EXTRA_STACK_SIZE)
204-
#define ESP_TASK_BT_CONTROLLER_PRIO 1
202+
#ifdef CONFIG_BTDM_BLE_LLCP_CONN_UPDATE
203+
#define BTDM_BLE_LLCP_CONN_UPDATE (1<<0)
204+
#else
205+
#define BTDM_BLE_LLCP_CONN_UPDATE (0<<0)
206+
#endif
207+
208+
#ifdef CONFIG_BTDM_BLE_LLCP_CHAN_MAP_UPDATE
209+
#define BTDM_BLE_LLCP_CHAN_MAP_UPDATE (1<<1)
210+
#else
211+
#define BTDM_BLE_LLCP_CHAN_MAP_UPDATE (0<<1)
212+
#endif
213+
214+
#define BTDM_BLE_LLCP_DISC_FLAG (BTDM_BLE_LLCP_CONN_UPDATE | BTDM_BLE_LLCP_CHAN_MAP_UPDATE)
215+
216+
#ifdef CONFIG_BTDM_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS
217+
#define BTDM_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS_ENABLED CONFIG_BTDM_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS
218+
#else
219+
#define BTDM_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS_ENABLED 0
220+
#endif
205221

206-
/* SMP is not supported yet */
207-
#define CONFIG_BTDM_CTRL_PINNED_TO_CORE 0
222+
#if defined(CONFIG_BTDM_BLE_CHAN_ASS_EN)
223+
#define BTDM_BLE_CHAN_ASS_EN (CONFIG_BTDM_BLE_CHAN_ASS_EN)
224+
#else
225+
#define BTDM_BLE_CHAN_ASS_EN (0)
226+
#endif
227+
228+
#if defined(CONFIG_BTDM_BLE_PING_EN)
229+
#define BTDM_BLE_PING_EN (CONFIG_BTDM_BLE_PING_EN)
230+
#else
231+
#define BTDM_BLE_PING_EN (0)
232+
#endif
208233

209234
/**
210235
* @brief Default Bluetooth Controller configuration
@@ -234,6 +259,10 @@ the adv packet will be discarded until the memory is restored. */
234259
.hli = BTDM_CTRL_HLI, \
235260
.dup_list_refresh_period = SCAN_DUPL_CACHE_REFRESH_PERIOD, \
236261
.ble_scan_backoff = BTDM_CTRL_SCAN_BACKOFF_UPPERLIMITMAX, \
262+
.ble_llcp_disc_flag = BTDM_BLE_LLCP_DISC_FLAG, \
263+
.ble_aa_check = BTDM_CTRL_CHECK_CONNECT_IND_ACCESS_ADDRESS_ENABLED, \
264+
.ble_chan_ass_en = BTDM_BLE_CHAN_ASS_EN, \
265+
.ble_ping_en = BTDM_BLE_PING_EN, \
237266
.magic = ESP_BT_CONTROLLER_CONFIG_MAGIC_VAL, \
238267
}
239268

@@ -253,39 +282,69 @@ the adv packet will be discarded until the memory is restored. */
253282
typedef struct {
254283
uint16_t controller_task_stack_size; /*!< Bluetooth Controller task stack size in bytes */
255284
uint8_t controller_task_prio; /*!< Bluetooth Controller task priority */
256-
uint8_t hci_uart_no; /*!< Indicates UART number if using UART1/2 as HCI I/O interface. Configurable in menuconfig. */
257-
uint32_t hci_uart_baudrate; /*!< Indicates UART baudrate if using UART1/2 as HCI I/O interface. Configurable in menuconfig. */
258-
uint8_t scan_duplicate_mode; /*!< Scan duplicate filtering mode. Configurable in menuconfig. */
259-
uint8_t scan_duplicate_type; /*!< Scan duplicate filtering type. Configurable in menuconfig. */
260-
uint16_t normal_adv_size; /*!< Maximum number of devices in scan duplicate filtering list. Configurable in menuconfig. */
261-
uint16_t mesh_adv_size; /*!< Maximum number of Mesh ADV packets in scan duplicate filtering list. Configurable in menuconfig. */
285+
uint8_t hci_uart_no; /*!< UART number as HCI I/O interface. Configurable in menuconfig.
286+
- 1 - URAT 1 (default)
287+
- 2 - URAT 2 */
288+
uint32_t hci_uart_baudrate; /*!< UART baudrate. Configurable in menuconfig.
289+
- Range: 115200 - 921600
290+
- Default: 921600 */
291+
uint8_t scan_duplicate_mode; /*!< Scan duplicate filtering mode. Configurable in menuconfig.
292+
- 0 - Normal scan duplicate filtering mode (default)
293+
- 1 - Special scan duplicate filtering mode for BLE Mesh */
294+
uint8_t scan_duplicate_type; /*!< Scan duplicate filtering type. If `scan_duplicate_mode` is set to 1, this parameter will be ignored. Configurable in menuconfig.
295+
- 0 - Filter scan duplicates by device address only (default)
296+
- 1 - Filter scan duplicates by advertising data only, even if they originate from different devices.
297+
- 2 - Filter scan duplicated by device address and advertising data. */
298+
uint16_t normal_adv_size; /*!< Maximum number of devices in scan duplicate filtering list. Configurable in menuconfig
299+
- Range: 10 - 1000
300+
- Default: 100 */
301+
uint16_t mesh_adv_size; /*!< Maximum number of Mesh advertising packets in scan duplicate filtering list. Configurable in menuconfig
302+
- Range: 10 - 1000
303+
- Default: 100 */
262304
uint16_t send_adv_reserved_size; /*!< Controller minimum memory value in bytes. Internal use only */
263305
uint32_t controller_debug_flag; /*!< Controller debug log flag. Internal use only */
264-
uint8_t mode; /*!< Controller mode:
265-
266-
1: BLE mode
267-
268-
2: Classic Bluetooth mode
269-
270-
3: Dual mode
271-
272-
Others: Invalid
273-
C
274-
onfigurable in menuconfig
275-
*/
276-
uint8_t ble_max_conn; /*!< Maximum number of BLE connections. Configurable in menuconfig. */
277-
uint8_t bt_max_acl_conn; /*!< Maximum number of BR/EDR ACL connections. Configurable in menuconfig. */
278-
uint8_t bt_sco_datapath; /*!< SCO data path, i.e. HCI or PCM module. Configurable in menuconfig. */
279-
bool auto_latency; /*!< True if BLE auto latency is enabled, used to enhance Classic Bluetooth performance; false otherwise. Configurable in menuconfig.*/
280-
bool bt_legacy_auth_vs_evt; /*!< True if BR/EDR Legacy Authentication Vendor Specific Event is enabled, which is required to protect from BIAS attack; false otherwise. Configurable in menuconfig. */
281-
uint8_t bt_max_sync_conn; /*!< Maximum number of BR/EDR synchronous connections. Configurable in menuconfig. */
282-
uint8_t ble_sca; /*!< BLE low power crystal accuracy index. Configurable in menuconfig. */
283-
uint8_t pcm_role; /*!< PCM role (master & slave). Configurable in menuconfig.*/
284-
uint8_t pcm_polar; /*!< PCM polar trig (falling clk edge & rising clk edge). Configurable in menuconfig. */
285-
uint8_t pcm_fsyncshp; /*!< Physical shape of the PCM Frame Synchronization signal (stereo mode & mono mode). Configurable in menuconfig */
286-
bool hli; /*!< True if using high level interrupt; false otherwise. Configurable in menuconfig. */
287-
uint16_t dup_list_refresh_period; /*!< Scan duplicate filtering list refresh period in seconds. Configurable in menuconfig.*/
288-
bool ble_scan_backoff; /*!< True if BLE scan backoff is enabled; false otherwise. Configurable in menuconfig.*/
306+
uint8_t mode; /*!< Controller mode. Configurable in menuconfig
307+
- 1 - BLE mode
308+
- 2 - Classic Bluetooth mode
309+
- 3 - Dual mode
310+
- 4 - Others: Invalid */
311+
uint8_t ble_max_conn; /*!< Maximum number of BLE connections. Configurable in menuconfig
312+
- Range: 1 - 9
313+
- Default: 3 */
314+
uint8_t bt_max_acl_conn; /*!< Maximum number of BR/EDR ACL connections. Configurable in menuconfig
315+
- Range: 1 - 7
316+
- Default: 2 */
317+
uint8_t bt_sco_datapath; /*!< SCO data path. Configurable in menuconfig
318+
- 0 - HCI module (default)
319+
- 1 - PCM module */
320+
bool auto_latency; /*!< True if BLE auto latency is enabled, used to enhance Classic Bluetooth performance in the Dual mode; false otherwise (default). Configurable in menuconfig */
321+
bool bt_legacy_auth_vs_evt; /*!< True if BR/EDR Legacy Authentication Vendor Specific Event is enabled (default in the classic bluetooth or Dual mode), which is required to protect from BIAS attack; false otherwise. Configurable in menuconfig */
322+
uint8_t bt_max_sync_conn; /*!< Maximum number of BR/EDR synchronous connections. Configurable in menuconfig
323+
- Range: 0 - 3
324+
- Default: 0 */
325+
uint8_t ble_sca; /*!< BLE low power crystal accuracy index. Configurable in menuconfig
326+
- 0 - `BTDM_BLE_DEFAULT_SCA_500PPM`
327+
- 1 - `BTDM_BLE_DEFAULT_SCA_250PPM` (default) */
328+
uint8_t pcm_role; /*!< PCM role. Configurable in menuconfig
329+
- 0 - PCM master (default)
330+
- 1 - PCM slave (default) */
331+
uint8_t pcm_polar; /*!< PCM polarity (falling clk edge & rising clk edge). Configurable in menuconfig
332+
- 0 - Falling Edge (default)
333+
- 1 - Rising Edge */
334+
uint8_t pcm_fsyncshp; /*!< Physical shape of the PCM Frame Synchronization signal. Configurable in menuconfig
335+
- 0 - Stereo Mode (default)
336+
- 1 - Mono Mode 1
337+
- 2 - Mono Mode 2 */
338+
bool hli; /*!< True if using high-level (level 4) interrupt (default); false otherwise. Configurable in menuconfig */
339+
uint16_t dup_list_refresh_period; /*!< Scan duplicate filtering list refresh period in seconds. Configurable in menuconfig
340+
- Range: 0 - 100 seconds
341+
- Default: 0 second */
342+
bool ble_scan_backoff; /*!< True if BLE scan backoff is enabled; false otherwise (default). Configurable in menuconfig */
343+
uint8_t ble_llcp_disc_flag; /*!< Flag indicating whether the Controller disconnects after Instant Passed (0x28) error occurs. Configurable in menuconfig.
344+
- The Controller does not disconnect after Instant Passed (0x28) by default. */
345+
bool ble_aa_check; /*!< True if adds a verification step for the Access Address within the `CONNECT_IND` PDU; false otherwise (default). Configurable in menuconfig */
346+
uint8_t ble_chan_ass_en; /*!< True if BLE channel assessment is enabled (default), false otherwise. Configurable in menuconfig */
347+
uint8_t ble_ping_en; /*!< True if BLE ping procedure is enabled (default), false otherwise. Configurable in menuconfig */
289348
uint32_t magic; /*!< Magic number */
290349
} esp_bt_controller_config_t;
291350

zephyr/esp32/src/bt/esp_bt_adapter.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -375,10 +375,10 @@ static DRAM_ATTR uint32_t btdm_lpcycle_us = 0;
375375
/* number of fractional bit for btdm_lpcycle_us */
376376
static DRAM_ATTR uint8_t btdm_lpcycle_us_frac = 0;
377377

378-
#if CONFIG_BTDM_MODEM_SLEEP_MODE_ORIG
378+
#if CONFIG_BTDM_CTRL_MODEM_SLEEP_MODE_ORIG
379379
// used low power clock
380380
static DRAM_ATTR uint8_t btdm_lpclk_sel;
381-
#endif /* #ifdef CONFIG_BTDM_MODEM_SLEEP_MODE_ORIG */
381+
#endif /* #ifdef CONFIG_BTDM_CTRL_MODEM_SLEEP_MODE_ORIG */
382382

383383
static DRAM_ATTR struct k_sem *s_wakeup_req_sem = NULL;
384384

@@ -885,7 +885,7 @@ static void IRAM_ATTR coex_bb_reset_unlock_wrapper(uint32_t restore)
885885
static int coex_schm_register_btdm_callback_wrapper(void *callback)
886886
{
887887
#if CONFIG_SW_COEXIST_ENABLE
888-
return coex_schm_register_btdm_callback(callback);
888+
return coex_schm_register_callback(OEX_SCHM_CALLBACK_TYPE_BT, callback);
889889
#else
890890
return 0;
891891
#endif
@@ -1079,12 +1079,13 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
10791079
btdm_controller_mem_init();
10801080

10811081
periph_module_enable(PERIPH_BT_MODULE);
1082+
periph_module_reset(PERIPH_BT_MODULE);
10821083

10831084
/* set default sleep clock cycle and its fractional bits */
10841085
btdm_lpcycle_us_frac = RTC_CLK_CAL_FRACT;
10851086
btdm_lpcycle_us = 2 << (btdm_lpcycle_us_frac);
10861087

1087-
#if CONFIG_BTDM_MODEM_SLEEP_MODE_ORIG
1088+
#if CONFIG_BTDM_CTRL_MODEM_SLEEP_MODE_ORIG
10881089

10891090
btdm_lpclk_sel = BTDM_LPCLK_SEL_XTAL; // set default value
10901091
#if CONFIG_BTDM_LPCLK_SEL_EXT_32K_XTAL
@@ -1100,7 +1101,8 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg)
11001101
btdm_lpclk_sel = BTDM_LPCLK_SEL_XTAL; // set default value
11011102
#endif
11021103

1103-
bool select_src_ret, set_div_ret;
1104+
bool select_src_ret __attribute__((unused));
1105+
bool set_div_ret __attribute__((unused));
11041106
if (btdm_lpclk_sel == BTDM_LPCLK_SEL_XTAL) {
11051107
select_src_ret = btdm_lpclk_select_src(BTDM_LPCLK_SEL_XTAL);
11061108
set_div_ret = btdm_lpclk_set_div(rtc_clk_xtal_freq_get() * 2 / MHZ(1) - 1);
@@ -1207,6 +1209,11 @@ static void patch_apply(void)
12071209
#ifndef CONFIG_BTDM_CTRL_MODE_BR_EDR_ONLY
12081210
config_ble_funcs_reset();
12091211
#endif
1212+
1213+
#ifdef CONFIG_BTDM_BLE_VS_QA_SUPPORT
1214+
config_ble_vs_qa_funcs_reset();
1215+
#endif
1216+
12101217
}
12111218

12121219
esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)

0 commit comments

Comments
 (0)