feat(ble/controller): Added memory boundary check for ESP32-C5

This commit is contained in:
Shen Weilong
2025-03-17 18:11:31 +08:00
parent 66f5d3dd80
commit 11289ffe86
5 changed files with 65 additions and 1 deletions

View File

@@ -402,6 +402,10 @@ menu "Controller debug features"
default n default n
help help
Retain scene with GDB to capture info, requires disabling WDT (CONFIG_ESP_INT_WDT, CONFIG_ESP_TASK_WDT_EN). Retain scene with GDB to capture info, requires disabling WDT (CONFIG_ESP_INT_WDT, CONFIG_ESP_TASK_WDT_EN).
config BT_LE_PTR_CHECK_ENABLED
bool "Enable boundary check for internal memory"
default n
endmenu endmenu
config BT_LE_LL_RESOLV_LIST_SIZE config BT_LE_LL_RESOLV_LIST_SIZE

View File

@@ -7,6 +7,7 @@
#include "sdkconfig.h" #include "sdkconfig.h"
#include "esp_bt_cfg.h" #include "esp_bt_cfg.h"
#include "esp_bit_defs.h"
/* External functions or variables /* External functions or variables
************************************************************************ ************************************************************************
@@ -28,9 +29,50 @@ int conn_errorSim_enable(void);
void conn_errorSim_disable(void); void conn_errorSim_disable(void);
#endif // CONFIG_BT_LE_ERROR_SIM_ENABLED #endif // CONFIG_BT_LE_ERROR_SIM_ENABLED
#if (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
void adv_stack_enableClearLegacyAdvVsCmd(bool en);
void scan_stack_enableAdvFlowCtrlVsCmd(bool en);
void advFilter_stack_enableDupExcListVsCmd(bool en);
void arr_stack_enableMultiConnVsCmd(bool en);
void pcl_stack_enableSetRssiThreshVsCmd(bool en);
void chanSel_stack_enableSetCsaVsCmd(bool en);
void log_stack_enableLogsRelatedVsCmd(bool en);
void hci_stack_enableSetVsEvtMaskVsCmd(bool en);
void winWiden_stack_enableSetConstPeerScaVsCmd(bool en);
void adv_stack_enableScanReqRxdVsEvent(bool en);
void conn_stack_enableChanMapUpdCompVsEvent(bool en);
void sleep_stack_enableWakeupVsEvent(bool en);
#endif // (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
/* Local functions definition /* Local functions definition
*************************************************************************** ***************************************************************************
*/ */
#if (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
void ble_stack_enableVsCmds(bool en)
{
adv_stack_enableClearLegacyAdvVsCmd(en);
advFilter_stack_enableDupExcListVsCmd(en);
scan_stack_enableAdvFlowCtrlVsCmd(en);
arr_stack_enableMultiConnVsCmd(en);
pcl_stack_enableSetRssiThreshVsCmd(en);
chanSel_stack_enableSetCsaVsCmd(en);
log_stack_enableLogsRelatedVsCmd(en);
hci_stack_enableSetVsEvtMaskVsCmd(en);
winWiden_stack_enableSetConstPeerScaVsCmd(en);
}
void ble_stack_enableVsEvents(bool en)
{
adv_stack_enableScanReqRxdVsEvent(en);
conn_stack_enableChanMapUpdCompVsEvent(en);
#if CONFIG_BT_LE_SLEEP_ENABLE
sleep_stack_enableWakeupVsEvent(en);
#endif // CONFIG_BT_LE_SLEEP_ENABLE
}
#endif // (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
int ble_stack_initEnv(void) int ble_stack_initEnv(void)
{ {
int rc; int rc;
@@ -90,11 +132,21 @@ int ble_stack_enable(void)
#endif // CONFIG_BT_LE_ERROR_SIM_ENABLED #endif // CONFIG_BT_LE_ERROR_SIM_ENABLED
#endif // DEFAULT_BT_LE_MAX_CONNECTIONS #endif // DEFAULT_BT_LE_MAX_CONNECTIONS
#if (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
ble_stack_enableVsCmds(true);
ble_stack_enableVsEvents(true);
#endif // (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
return 0; return 0;
} }
void ble_stack_disable(void) void ble_stack_disable(void)
{ {
#if (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
ble_stack_enableVsEvents(false);
ble_stack_enableVsCmds(false);
#endif // (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
#if DEFAULT_BT_LE_MAX_CONNECTIONS #if DEFAULT_BT_LE_MAX_CONNECTIONS
#if CONFIG_BT_LE_ERROR_SIM_ENABLED #if CONFIG_BT_LE_ERROR_SIM_ENABLED
conn_errorSim_disable(); conn_errorSim_disable();

View File

@@ -204,6 +204,12 @@ extern "C" {
#define DEFAULT_BT_LE_VHCI_ENABLED (0) #define DEFAULT_BT_LE_VHCI_ENABLED (0)
#endif #endif
#ifdef CONFIG_BT_LE_PTR_CHECK_ENABLED
#define DEFAULT_BT_LE_PTR_CHECK_ENABLED (CONFIG_BT_LE_PTR_CHECK_ENABLED)
#else
#define DEFAULT_BT_LE_PTR_CHECK_ENABLED (0)
#endif
#ifdef CONFIG_BT_LE_SLEEP_ENABLE #ifdef CONFIG_BT_LE_SLEEP_ENABLE
#define NIMBLE_SLEEP_ENABLE CONFIG_BT_LE_SLEEP_ENABLE #define NIMBLE_SLEEP_ENABLE CONFIG_BT_LE_SLEEP_ENABLE
#else #else

View File

@@ -225,6 +225,7 @@ typedef struct {
- 0 - Disable (default) - 0 - Disable (default)
- 1 - Enable */ - 1 - Enable */
uint8_t vhci_enabled; /*!< VHCI mode is enabled */ uint8_t vhci_enabled; /*!< VHCI mode is enabled */
uint8_t ptr_check_enabled; /*!< Enable boundary check for internal memory. */
uint32_t config_magic; /*!< Magic number for configuration validation */ uint32_t config_magic; /*!< Magic number for configuration validation */
} esp_bt_controller_config_t; } esp_bt_controller_config_t;
@@ -279,6 +280,7 @@ typedef struct {
.ble_chan_ass_en = DEFAULT_BT_LE_CTRL_CHAN_ASS_EN, \ .ble_chan_ass_en = DEFAULT_BT_LE_CTRL_CHAN_ASS_EN, \
.ble_data_lenth_zero_aux = DEFAULT_BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX, \ .ble_data_lenth_zero_aux = DEFAULT_BT_LE_CTRL_ADV_DATA_LENGTH_ZERO_AUX, \
.vhci_enabled = DEFAULT_BT_LE_VHCI_ENABLED, \ .vhci_enabled = DEFAULT_BT_LE_VHCI_ENABLED, \
.ptr_check_enabled = DEFAULT_BT_LE_PTR_CHECK_ENABLED, \
.config_magic = CONFIG_MAGIC, \ .config_magic = CONFIG_MAGIC, \
} }