I'm experiencing the same problem with the ESP32S3. I'm using Bluedroid rather than Nimble for my BLE code, but otherwise my code setup and usb initialisation are almost identical. Similar to chris_zou, my BLE and USB code work as expected independently of one another, but when both are initialised, the BLE code always wins (and functions as expected), regardless of the order in which the USB and BLE are initialised. That said, if I initialise USB first, then BLE, I do briefly get successful USB enumeration, but the BLE initialisation quickly puts a stop to that.
I have narrowed down the point of failure to the inclusion of:
Code: Select all
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
esp_bt_controller_init(&bt_cfg);
Pretty much the first line in my BLE server initialisation - there's a lot going on in esp_bt_controller_init() so i didn't investigate any further yet.
Perhaps there is a conflicting configuration in BT_CONTROLLER_INIT_CONFIG_DEFAULT() for the ESP32S3? I have tried changing the default hci_uart_no from 1 to 2, to no avail, but to be honest I'm shooting in the dark here... My initial thought was that perhaps BLE and USB are using some shared physical resource, and only one can be active at a time, but that is entirely speculative on my part, and ESP_Sprite seems to be suggesting that this shouldn't be the case (is there any documentation to support this?). I've also tried changing the default BLE core from 1 to 2, but still no joy.
BT_CONTROLLER_INIT_CONFIG_DEFAULT() is defined as follows in esp_bt.h:
Code: Select all
#define BT_CONTROLLER_INIT_CONFIG_DEFAULT() { \
.controller_task_stack_size = ESP_TASK_BT_CONTROLLER_STACK, \
.controller_task_prio = ESP_TASK_BT_CONTROLLER_PRIO, \
.hci_uart_no = BT_HCI_UART_NO_DEFAULT, \
.hci_uart_baudrate = BT_HCI_UART_BAUDRATE_DEFAULT, \
.scan_duplicate_mode = SCAN_DUPLICATE_MODE, \
.scan_duplicate_type = SCAN_DUPLICATE_TYPE_VALUE, \
.normal_adv_size = NORMAL_SCAN_DUPLICATE_CACHE_SIZE, \
.mesh_adv_size = MESH_DUPLICATE_SCAN_CACHE_SIZE, \
.send_adv_reserved_size = SCAN_SEND_ADV_RESERVED_SIZE, \
.controller_debug_flag = CONTROLLER_ADV_LOST_DEBUG_BIT, \
.mode = BTDM_CONTROLLER_MODE_EFF, \
.ble_max_conn = CONFIG_BTDM_CTRL_BLE_MAX_CONN_EFF, \
.bt_max_acl_conn = CONFIG_BTDM_CTRL_BR_EDR_MAX_ACL_CONN_EFF, \
.bt_sco_datapath = CONFIG_BTDM_CTRL_BR_EDR_SCO_DATA_PATH_EFF, \
.auto_latency = BTDM_CTRL_AUTO_LATENCY_EFF, \
.bt_legacy_auth_vs_evt = BTDM_CTRL_LEGACY_AUTH_VENDOR_EVT_EFF, \
.bt_max_sync_conn = CONFIG_BTDM_CTRL_BR_EDR_MAX_SYNC_CONN_EFF, \
.ble_sca = CONFIG_BTDM_BLE_SLEEP_CLOCK_ACCURACY_INDEX_EFF, \
.pcm_role = CONFIG_BTDM_CTRL_PCM_ROLE_EFF, \
.pcm_polar = CONFIG_BTDM_CTRL_PCM_POLAR_EFF, \
.hli = BTDM_CTRL_HLI, \
.magic = ESP_BT_CONTROLLER_CONFIG_MAGIC_VAL, \
};
Do any of the parameters in here jump out as being possible suspects?