From 82563128c8c3707e3d4b5f8778f5582701089f61 Mon Sep 17 00:00:00 2001 From: cjin Date: Wed, 18 Oct 2023 16:28:22 +0800 Subject: [PATCH 1/3] change(ble): update ble lib on c6 h2 and c2 chip --- components/bt/controller/lib_esp32c2/esp32c2-bt-lib | 2 +- components/esp_rom/esp32c2/ld/esp32c2.rom.ld | 6 ------ 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/components/bt/controller/lib_esp32c2/esp32c2-bt-lib b/components/bt/controller/lib_esp32c2/esp32c2-bt-lib index fc690c13c6..4fb60aa91d 160000 --- a/components/bt/controller/lib_esp32c2/esp32c2-bt-lib +++ b/components/bt/controller/lib_esp32c2/esp32c2-bt-lib @@ -1 +1 @@ -Subproject commit fc690c13c618d1cb8f94611c2bbe6aec2f1cc72e +Subproject commit 4fb60aa91de64b0f1d0eb6292d38b6c22a3aa005 diff --git a/components/esp_rom/esp32c2/ld/esp32c2.rom.ld b/components/esp_rom/esp32c2/ld/esp32c2.rom.ld index 871a99614b..fdb8e3b760 100644 --- a/components/esp_rom/esp32c2/ld/esp32c2.rom.ld +++ b/components/esp_rom/esp32c2/ld/esp32c2.rom.ld @@ -605,10 +605,8 @@ r_ble_hw_rng_stop = 0x40000b94; r_ble_hw_rx_local_is_resolved = 0x40000b98; r_ble_hw_rx_local_is_rpa = 0x40000b9c; r_ble_hw_whitelist_add = 0x40000ba0; -r_ble_hw_whitelist_clear = 0x40000ba4; r_ble_hw_whitelist_dev_num = 0x40000ba8; r_ble_hw_whitelist_get_base = 0x40000bac; -r_ble_hw_whitelist_rmv = 0x40000bb0; r_ble_hw_whitelist_search = 0x40000bb4; r_ble_hw_whitelist_sort = 0x40000bb8; r_ble_ll_acl_data_in = 0x40000bbc; @@ -1381,12 +1379,8 @@ r_os_memblock_put_from_cb = 0x40001a4c; r_os_mempool_clear = 0x40001a50; r_os_mempool_ext_clear = 0x40001a54; r_os_mempool_ext_init = 0x40001a58; -r_os_mempool_info_get_next = 0x40001a5c; r_os_mempool_init = 0x40001a60; -r_os_mempool_init_internal = 0x40001a64; r_os_mempool_is_sane = 0x40001a68; -r_os_mempool_module_init = 0x40001a6c; -r_os_mempool_unregister = 0x40001a70; r_os_mqueue_get = 0x40001a74; r_os_mqueue_init = 0x40001a78; r_os_mqueue_put = 0x40001a7c; From 3d381ba5606bfd62d8488a058fadd46b90096c2a Mon Sep 17 00:00:00 2001 From: luomanruo Date: Wed, 18 Oct 2023 16:51:42 +0800 Subject: [PATCH 2/3] ble: update controller log module for ESP32-C2 --- components/bt/controller/esp32c2/Kconfig.in | 14 ++++++ components/bt/controller/esp32c2/bt.c | 49 ++++++++++++------- .../bt/include/esp32c2/include/esp_bt.h | 8 +++ 3 files changed, 52 insertions(+), 19 deletions(-) diff --git a/components/bt/controller/esp32c2/Kconfig.in b/components/bt/controller/esp32c2/Kconfig.in index dac5534a58..f44f852680 100644 --- a/components/bt/controller/esp32c2/Kconfig.in +++ b/components/bt/controller/esp32c2/Kconfig.in @@ -256,9 +256,23 @@ config BT_LE_CONTROLLER_TASK_STACK_SIZE config BT_LE_CONTROLLER_LOG_ENABLED bool "Controller log enable" default n + help + Enable controller log + +config BT_LE_CONTROLLER_LOG_CTRL_ENABLED + bool "enable controller log module" + depends on BT_LE_CONTROLLER_LOG_ENABLED + default y help Enable controller log module +config BT_LE_CONTROLLER_LOG_HCI_ENABLED + bool "enable HCI log module" + depends on BT_LE_CONTROLLER_LOG_ENABLED + default y + help + Enable hci log module + config BT_LE_CONTROLLER_LOG_DUMP_ONLY bool "Controller log dump mode only" depends on BT_LE_CONTROLLER_LOG_ENABLED diff --git a/components/bt/controller/esp32c2/bt.c b/components/bt/controller/esp32c2/bt.c index ab22329294..c2d98c1305 100644 --- a/components/bt/controller/esp32c2/bt.c +++ b/components/bt/controller/esp32c2/bt.c @@ -125,7 +125,7 @@ extern int ble_osi_coex_funcs_register(struct osi_coex_funcs_t *coex_funcs); extern int coex_core_ble_conn_dyn_prio_get(bool *low, bool *high); extern int ble_controller_init(esp_bt_controller_config_t *cfg); #if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED -extern int ble_log_init_async(interface_func_t bt_controller_log_interface, bool task_create); +extern int ble_log_init_async(interface_func_t bt_controller_log_interface, bool task_create, uint8_t buffers, uint32_t *bufs_size); extern int ble_log_deinit_async(void); extern void ble_log_async_output_dump_all(bool output); #endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED @@ -201,6 +201,11 @@ static void esp_bt_controller_log_interface(uint32_t len, const uint8_t *addr, b /* Static variable declare */ static DRAM_ATTR esp_bt_controller_status_t ble_controller_status = ESP_BT_CONTROLLER_STATUS_IDLE; +#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED +const static uint32_t log_bufs_size[] = {2048, 1024, 1024}; +static uint8_t buffers = 0; +#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED + /* This variable tells if BLE is running */ static bool s_ble_active = false; #ifdef CONFIG_PM_ENABLE @@ -641,26 +646,33 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) #if CONFIG_SW_COEXIST_ENABLE coex_init(); #endif + +#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED + interface_func_t bt_controller_log_interface; + bt_controller_log_interface = esp_bt_controller_log_interface; +#if CONFIG_BT_LE_CONTROLLER_LOG_CTRL_ENABLED + buffers |= ESP_BLE_LOG_BUF_CONTROLLER; +#endif // CONFIG_BT_LE_CONTROLLER_LOG_CTRL_ENABLED +#if CONFIG_BT_LE_CONTROLLER_LOG_HCI_ENABLED + buffers |= ESP_BLE_LOG_BUF_HCI; +#endif // CONFIG_BT_LE_CONTROLLER_LOG_HCI_ENABLED +#if CONFIG_BT_LE_CONTROLLER_LOG_DUMP_ONLY + ret = ble_log_init_async(bt_controller_log_interface, false, buffers, (uint32_t *)log_bufs_size); +#else + ret = ble_log_init_async(bt_controller_log_interface, true, buffers, (uint32_t *)log_bufs_size); +#endif // CONFIG_BT_CONTROLLER_LOG_DUMP + if (ret != ESP_OK) { + ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ble_controller_log_init failed %d", ret); + goto modem_deint; + } +#endif // CONFIG_BT_CONTROLLER_LOG_ENABLED + ret = ble_controller_init(cfg); if (ret != ESP_OK) { ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ble_controller_init failed %d", ret); goto modem_deint; } -#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED - interface_func_t bt_controller_log_interface; - bt_controller_log_interface = esp_bt_controller_log_interface; -#if CONFIG_BT_LE_CONTROLLER_LOG_DUMP_ONLY - ret = ble_log_init_async(bt_controller_log_interface, false); -#else - ret = ble_log_init_async(bt_controller_log_interface, true); -#endif // CONFIG_BT_CONTROLLER_LOG_DUMP - if (ret != ESP_OK) { - ESP_LOGW(NIMBLE_PORT_LOG_TAG, "ble_controller_log_init failed %d", ret); - goto controller_init_err; - } -#endif // CONFIG_BT_CONTROLLER_LOG_ENABLED - ret = controller_sleep_init(); if (ret != ESP_OK) { ESP_LOGW(NIMBLE_PORT_LOG_TAG, "controller_sleep_init failed %d", ret); @@ -681,12 +693,11 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) return ESP_OK; free_controller: controller_sleep_deinit(); -#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED -controller_init_err: - ble_log_deinit_async(); -#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED ble_controller_deinit(); modem_deint: +#if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED + ble_log_deinit_async(); +#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED esp_phy_modem_deinit(); periph_module_disable(PERIPH_BT_MODULE); #if CONFIG_BT_NIMBLE_ENABLED diff --git a/components/bt/include/esp32c2/include/esp_bt.h b/components/bt/include/esp32c2/include/esp_bt.h index ae6a6bde78..6939470393 100644 --- a/components/bt/include/esp32c2/include/esp_bt.h +++ b/components/bt/include/esp32c2/include/esp_bt.h @@ -106,6 +106,14 @@ typedef enum { ESP_BLE_ENHANCED_PWR_TYPE_MAX, } esp_ble_enhanced_power_type_t; +/** + * @brief Select buffers +*/ +typedef enum { + ESP_BLE_LOG_BUF_HCI = 0x02, + ESP_BLE_LOG_BUF_CONTROLLER = 0x05, +} esp_ble_log_buf_t; + /** * @brief Address type and address value. */ From 8b7c87028be6dfc5b8d839839c9a35156e416e52 Mon Sep 17 00:00:00 2001 From: luomanruo Date: Wed, 18 Oct 2023 18:03:45 +0800 Subject: [PATCH 3/3] ble: update controller log module for ESP32-C2 --- components/bt/controller/esp32c2/bt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/bt/controller/esp32c2/bt.c b/components/bt/controller/esp32c2/bt.c index c2d98c1305..f7c0ceb68a 100644 --- a/components/bt/controller/esp32c2/bt.c +++ b/components/bt/controller/esp32c2/bt.c @@ -203,7 +203,6 @@ static DRAM_ATTR esp_bt_controller_status_t ble_controller_status = ESP_BT_CONTR #if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED const static uint32_t log_bufs_size[] = {2048, 1024, 1024}; -static uint8_t buffers = 0; #endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED /* This variable tells if BLE is running */ @@ -650,6 +649,7 @@ esp_err_t esp_bt_controller_init(esp_bt_controller_config_t *cfg) #if CONFIG_BT_LE_CONTROLLER_LOG_ENABLED interface_func_t bt_controller_log_interface; bt_controller_log_interface = esp_bt_controller_log_interface; + uint8_t buffers = 0; #if CONFIG_BT_LE_CONTROLLER_LOG_CTRL_ENABLED buffers |= ESP_BLE_LOG_BUF_CONTROLLER; #endif // CONFIG_BT_LE_CONTROLLER_LOG_CTRL_ENABLED