change(ble): npl count is zero if nimble host is not used

change(ble): added npl eventq put to front

change(ble): added cache safe check in ble power save example

ble(update):
    Update c2 lib to 91b81332
    Update h2 lib to 620fbe79
    Update c6 lib to 620fbe79

fix(ble): fix stack overflow disable at sleep

Revert "change(ble): added ble cca en and thresh option"

This reverts commit 71901499b9.
This commit is contained in:
luomanruo 2023-12-29 15:30:07 +08:00
parent 6c5373911a
commit dededd1267
16 changed files with 55 additions and 93 deletions

View File

@ -464,23 +464,3 @@ config BT_CTRL_BLE_ADV_REPORT_DISCARD_THRSHOLD
config BT_LE_RELEASE_IRAM_SUPPORTED
bool
default y
config BT_LE_TX_CCA_ENABLED
bool "BLE enable TX CCA feature"
default n
help
Enable the BLE (Bluetooth Low Energy) LBT (Listen Before Talk) function. Before transmitting a packet,
monitor the in-band CCA (Clear Channel Assessment). If the airborne carrier energy is too high, abandon
the packet transmission. Enabling this feature may potentially decrease BLE performance. In certain
countries and regions, when the maximum transmission power exceeds a certain limit, support for LBT
interference avoidance mechanisms is required. If the maximum transmission power does not reach the limit,
it may not be necessary to enable this function.
Please refer to the relevant certification regulations for details.
config BT_LE_CCA_RSSI_THRESH
int "Power threshold to refrain packet transmission in unit of -1 dBm"
depends on BT_LE_TX_CCA_ENABLED
range 1 100
default 75
help
If a carrier signal above the threshold is detected in the air, refrain from packet transmission.

View File

@ -1019,7 +1019,7 @@ void esp_ble_controller_log_dump_all(bool output)
esp_panic_handler_reconfigure_wdts(5000);
BT_ASSERT_PRINT("\r\n[DUMP_START:");
ble_log_async_output_dump_all(output);
BT_ASSERT_PRINT("]\r\n");
BT_ASSERT_PRINT(":DUMP_END]\r\n");
portEXIT_CRITICAL_SAFE(&spinlock);
}
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED

View File

@ -382,7 +382,7 @@ config BT_LE_WHITELIST_SIZE
config BT_LE_LL_DUP_SCAN_LIST_COUNT
int "BLE duplicate scan list count"
range 1 100
range 5 100
default 20
help
config the max count of duplicate scan list
@ -543,15 +543,6 @@ config BT_LE_SCAN_DUPL_TYPE
default 2 if BT_LE_SCAN_DUPL_TYPE_DATA_DEVICE
default 0
config BT_LE_SCAN_DUPL_CACHE_SIZE
int "Maximum number of devices in scan duplicate filter"
depends on BT_LE_SCAN_DUPL
range 10 1000
default 100
help
Maximum number of devices which can be recorded in scan duplicate filter.
When the maximum amount of device in the filter is reached, the cache will be refreshed.
config BT_LE_SCAN_DUPL_CACHE_REFRESH_PERIOD
int "Duplicate scan list refresh period (seconds)"
depends on BT_LE_SCAN_DUPL
@ -571,23 +562,3 @@ config BT_LE_SCAN_DUPL_CACHE_REFRESH_PERIOD
config BT_LE_MSYS_INIT_IN_CONTROLLER
bool "Msys Mbuf Init in Controller"
default y
config BT_LE_TX_CCA_ENABLED
bool "BLE enable TX CCA feature"
default n
help
Enable the BLE (Bluetooth Low Energy) LBT (Listen Before Talk) function. Before transmitting a packet,
monitor the in-band CCA (Clear Channel Assessment). If the airborne carrier energy is too high, abandon
the packet transmission. Enabling this feature may potentially decrease BLE performance. In certain
countries and regions, when the maximum transmission power exceeds a certain limit, support for LBT
interference avoidance mechanisms is required. If the maximum transmission power does not reach the limit,
it may not be necessary to enable this function.
Please refer to the relevant certification regulations for details.
config BT_LE_CCA_RSSI_THRESH
int "Power threshold to refrain packet transmission in unit of -1 dBm"
depends on BT_LE_TX_CCA_ENABLED
range 1 100
default 75
help
If a carrier signal above the threshold is detected in the air, refrain from packet transmission.

View File

@ -665,7 +665,7 @@ void ble_controller_scan_duplicate_config(void)
uint32_t duplicate_mode = FILTER_DUPLICATE_DEFAULT;
uint32_t cache_size = 100;
#if CONFIG_BT_LE_SCAN_DUPL == true
cache_size = CONFIG_BT_LE_SCAN_DUPL_CACHE_SIZE;
cache_size = CONFIG_BT_LE_LL_DUP_SCAN_LIST_COUNT;
if (CONFIG_BT_LE_SCAN_DUPL_TYPE == 0) {
duplicate_mode = FILTER_DUPLICATE_ADDRESS | FILTER_DUPLICATE_PDUTYPE;
} else if (CONFIG_BT_LE_SCAN_DUPL_TYPE == 1) {
@ -911,9 +911,9 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
esp_pm_lock_acquire(s_pm_lock);
#endif // CONFIG_PM_ENABLE
esp_phy_enable(PHY_MODEM_BT);
esp_btbb_enable();
s_ble_active = true;
}
esp_btbb_enable();
#if CONFIG_SW_COEXIST_ENABLE
coex_enable();
#endif // CONFIG_SW_COEXIST_ENABLE
@ -929,8 +929,8 @@ error:
#if CONFIG_SW_COEXIST_ENABLE
coex_disable();
#endif
esp_btbb_disable();
if (s_ble_active) {
esp_btbb_disable();
esp_phy_disable(PHY_MODEM_BT);
#if CONFIG_PM_ENABLE
esp_pm_lock_release(s_pm_lock);
@ -952,8 +952,8 @@ esp_err_t esp_bt_controller_disable(void)
#if CONFIG_SW_COEXIST_ENABLE
coex_disable();
#endif
esp_btbb_disable();
if (s_ble_active) {
esp_btbb_disable();
esp_phy_disable(PHY_MODEM_BT);
#if CONFIG_PM_ENABLE
esp_pm_lock_release(s_pm_lock);
@ -1192,7 +1192,7 @@ void esp_ble_controller_log_dump_all(bool output)
esp_panic_handler_reconfigure_wdts(5000);
BT_ASSERT_PRINT("\r\n[DUMP_START:");
ble_log_async_output_dump_all(output);
BT_ASSERT_PRINT("]\r\n");
BT_ASSERT_PRINT(":DUMP_END]\r\n");
portEXIT_CRITICAL_SAFE(&spinlock);
}
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED

View File

@ -373,7 +373,7 @@ config BT_LE_WHITELIST_SIZE
config BT_LE_LL_DUP_SCAN_LIST_COUNT
int "BLE duplicate scan list count"
range 1 100
range 5 100
default 20
help
config the max count of duplicate scan list
@ -535,16 +535,6 @@ config BT_LE_SCAN_DUPL_TYPE
default 2 if BT_LE_SCAN_DUPL_TYPE_DATA_DEVICE
default 0
config BT_LE_SCAN_DUPL_CACHE_SIZE
int "Maximum number of devices in scan duplicate filter"
depends on BT_LE_SCAN_DUPL
range 10 1000
default 100
help
Maximum number of devices which can be recorded in scan duplicate filter.
When the maximum amount of device in the filter is reached, the cache will be refreshed.
config BT_LE_SCAN_DUPL_CACHE_REFRESH_PERIOD
int "Duplicate scan list refresh period (seconds)"
depends on BT_LE_SCAN_DUPL
@ -564,23 +554,3 @@ config BT_LE_SCAN_DUPL_CACHE_REFRESH_PERIOD
config BT_LE_MSYS_INIT_IN_CONTROLLER
bool
default y
config BT_LE_TX_CCA_ENABLED
bool "BLE enable TX CCA feature"
default n
help
Enable the BLE (Bluetooth Low Energy) LBT (Listen Before Talk) function. Before transmitting a packet,
monitor the in-band CCA (Clear Channel Assessment). If the airborne carrier energy is too high, abandon
the packet transmission. Enabling this feature may potentially decrease BLE performance. In certain
countries and regions, when the maximum transmission power exceeds a certain limit, support for LBT
interference avoidance mechanisms is required. If the maximum transmission power does not reach the limit,
it may not be necessary to enable this function.
Please refer to the relevant certification regulations for details.
config BT_LE_CCA_RSSI_THRESH
int "Power threshold to refrain packet transmission in unit of -1 dBm"
depends on BT_LE_TX_CCA_ENABLED
range 1 100
default 75
help
If a carrier signal above the threshold is detected in the air, refrain from packet transmission.

View File

@ -640,7 +640,7 @@ void ble_controller_scan_duplicate_config(void)
uint32_t duplicate_mode = FILTER_DUPLICATE_DEFAULT;
uint32_t cache_size = 100;
#if CONFIG_BT_LE_SCAN_DUPL == true
cache_size = CONFIG_BT_LE_SCAN_DUPL_CACHE_SIZE;
cache_size = CONFIG_BT_LE_LL_DUP_SCAN_LIST_COUNT;
if (CONFIG_BT_LE_SCAN_DUPL_TYPE == 0) {
duplicate_mode = FILTER_DUPLICATE_ADDRESS | FILTER_DUPLICATE_PDUTYPE;
} else if (CONFIG_BT_LE_SCAN_DUPL_TYPE == 1) {
@ -1164,7 +1164,7 @@ void esp_ble_controller_log_dump_all(bool output)
esp_panic_handler_reconfigure_wdts(5000);
BT_ASSERT_PRINT("\r\n[DUMP_START:");
ble_log_async_output_dump_all(output);
BT_ASSERT_PRINT("]\r\n");
BT_ASSERT_PRINT(":DUMP_END]\r\n");
portEXIT_CRITICAL_SAFE(&spinlock);
}
#endif // CONFIG_BT_LE_CONTROLLER_LOG_ENABLED

@ -1 +1 @@
Subproject commit 909c8bca55acdcbba1c32620482a7d1a10c28a07
Subproject commit 7f3eb5f5568439cdb32dfe9dbf69d99e9c72e69f

@ -1 +1 @@
Subproject commit c832dbc04d6894a380fe7b92c303602a5241ef16
Subproject commit e4d0d86b6f4fe4233f53e71d7dfa18faa0f19f27

@ -1 +1 @@
Subproject commit 49a90d0ad509a1ec95fcacfc67d578a97de4c1ee
Subproject commit 90793e83195547303e0fd190c890c8bff754d5d3

View File

@ -122,6 +122,7 @@ struct npl_funcs_t {
void (*p_ble_npl_hw_exit_critical)(uint32_t);
uint32_t (*p_ble_npl_get_time_forever)(void);
uint8_t (*p_ble_npl_hw_is_in_critical)(void);
void (*p_ble_npl_eventq_put_to_front)(struct ble_npl_eventq *, struct ble_npl_event *);
};
extern struct npl_funcs_t *npl_funcs;

View File

@ -3,7 +3,7 @@
*
* SPDX-License-Identifier: Apache-2.0
*
* SPDX-FileContributor: 2019-2022 Espressif Systems (Shanghai) CO LTD
* SPDX-FileContributor: 2019-2023 Espressif Systems (Shanghai) CO LTD
*/
#include <assert.h>
@ -37,11 +37,19 @@ static const char *TAG = "Timer";
#error "not defined SOC_ESP_NIMBLE_CONTROLLER or SOC_ESP_NIMBLE_CONTROLLER is zero"
#endif
#if CONFIG_BT_NIMBLE_ENABLED
#define BLE_HOST_CO_COUNT (8)
#define BLE_HOST_EV_COUNT (11 + BLE_HOST_CO_COUNT)
#define BLE_HOST_EVQ_COUNT (3)
#define BLE_HOST_SEM_COUNT (10)
#define BLE_HOST_MUTEX_COUNT (4)
#else
#define BLE_HOST_CO_COUNT (0)
#define BLE_HOST_EV_COUNT (0)
#define BLE_HOST_EVQ_COUNT (0)
#define BLE_HOST_SEM_COUNT (0)
#define BLE_HOST_MUTEX_COUNT (0)
#endif
struct os_mempool ble_freertos_ev_pool;
static os_membuf_t *ble_freertos_ev_buf = NULL;
@ -240,6 +248,32 @@ IRAM_ATTR npl_freertos_eventq_put(struct ble_npl_eventq *evq, struct ble_npl_eve
BLE_LL_ASSERT(ret == pdPASS);
}
void
IRAM_ATTR npl_freertos_eventq_put_to_front(struct ble_npl_eventq *evq, struct ble_npl_event *ev)
{
BaseType_t woken;
BaseType_t ret;
struct ble_npl_eventq_freertos *eventq = (struct ble_npl_eventq_freertos *)evq->eventq;
struct ble_npl_event_freertos *event = (struct ble_npl_event_freertos *)ev->event;
if (event->queued) {
return;
}
event->queued = true;
if (in_isr()) {
ret = xQueueSendToFrontFromISR(eventq->q, &ev, &woken);
if( woken == pdTRUE ) {
portYIELD_FROM_ISR();
}
} else {
ret = xQueueSendToFront(eventq->q, &ev, portMAX_DELAY);
}
BLE_LL_ASSERT(ret == pdPASS);
}
void
IRAM_ATTR npl_freertos_eventq_remove(struct ble_npl_eventq *evq,
struct ble_npl_event *ev)
@ -986,6 +1020,7 @@ const struct npl_funcs_t npl_funcs_ro = {
.p_ble_npl_eventq_deinit = npl_freertos_eventq_deinit,
.p_ble_npl_eventq_get = npl_freertos_eventq_get,
.p_ble_npl_eventq_put = npl_freertos_eventq_put,
.p_ble_npl_eventq_put_to_front = npl_freertos_eventq_put_to_front,
.p_ble_npl_eventq_remove = npl_freertos_eventq_remove,
.p_ble_npl_event_run = npl_freertos_event_run,
.p_ble_npl_eventq_is_empty = npl_freertos_eventq_is_empty,

View File

@ -16,4 +16,5 @@ CONFIG_PM_POWER_DOWN_CPU_IN_LIGHT_SLEEP=y
# Sleep Config
#
CONFIG_ESP_SLEEP_POWER_DOWN_FLASH=y
CONFIG_ESP_SLEEP_CACHE_SAFE_ASSERTION=y
# end of Sleep Config

View File

@ -19,4 +19,5 @@ CONFIG_FREERTOS_USE_TICKLESS_IDLE=y
#
CONFIG_ESP_SLEEP_POWER_DOWN_FLASH=y
CONFIG_ESP_PHY_MAC_BB_PD=y
CONFIG_ESP_SLEEP_CACHE_SAFE_ASSERTION=y
# end of Sleep Config

View File

@ -17,3 +17,4 @@ CONFIG_XTAL_FREQ=26
# Sleep Config
#
CONFIG_ESP_SLEEP_POWER_DOWN_FLASH=y
CONFIG_ESP_SLEEP_CACHE_SAFE_ASSERTION=y

View File

@ -20,6 +20,7 @@ CONFIG_FREERTOS_USE_TICKLESS_IDLE=y
#
CONFIG_ESP_SLEEP_POWER_DOWN_FLASH=y
CONFIG_ESP_PHY_MAC_BB_PD=y
CONFIG_ESP_SLEEP_CACHE_SAFE_ASSERTION=y
# end of Sleep Config
#

View File

@ -17,6 +17,7 @@ CONFIG_PM_POWER_DOWN_PERIPHERAL_IN_LIGHT_SLEEP=y
# Sleep Config
#
CONFIG_ESP_SLEEP_POWER_DOWN_FLASH=y
CONFIG_ESP_SLEEP_CACHE_SAFE_ASSERTION=y
# end of Sleep Config
#