mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-29 18:27:20 +02:00
feat(ble/controller): Added memory boundary check for ESP32-C2
This commit is contained in:
@ -97,7 +97,8 @@ if(CONFIG_BT_ENABLED)
|
||||
list(APPEND ldscripts "linker_rw_bt_controller.lf")
|
||||
|
||||
elseif(CONFIG_IDF_TARGET_ESP32C2)
|
||||
list(APPEND srcs "controller/esp32c2/bt.c")
|
||||
list(APPEND srcs "controller/esp32c2/bt.c"
|
||||
"controller/esp32c2/ble.c")
|
||||
if(CONFIG_BT_CTRL_RUN_IN_FLASH_ONLY)
|
||||
list(APPEND srcs "controller/esp32c2/dummy.c")
|
||||
endif()
|
||||
|
71
components/bt/controller/esp32c2/ble.c
Normal file
71
components/bt/controller/esp32c2/ble.c
Normal file
@ -0,0 +1,71 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2015-2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "sdkconfig.h"
|
||||
#include "esp_bt_cfg.h"
|
||||
|
||||
/* External functions or variables
|
||||
************************************************************************
|
||||
*/
|
||||
#if (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
|
||||
void scan_stack_enableAdvFlowCtrlVsCmd(bool en);
|
||||
void adv_stack_enableClearLegacyAdvVsCmd(bool en);
|
||||
void chanSel_stack_enableSetCsaVsCmd(bool en);
|
||||
void hci_stack_enableSetVsEvtMaskVsCmd(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
|
||||
***************************************************************************
|
||||
*/
|
||||
#if (CONFIG_BT_NIMBLE_ENABLED || CONFIG_BT_BLUEDROID_ENABLED)
|
||||
void ble_stack_enableVsCmds(bool en)
|
||||
{
|
||||
#if DEFAULT_BT_LE_ROLE_BROADCASTER
|
||||
adv_stack_enableClearLegacyAdvVsCmd(en);
|
||||
#endif // DEFAULT_BT_LE_ROLE_BROADCASTER
|
||||
|
||||
#if DEFAULT_BT_LE_ROLE_OBSERVER
|
||||
scan_stack_enableAdvFlowCtrlVsCmd(en);
|
||||
#endif // DEFAULT_BT_LE_ROLE_OBSERVER
|
||||
|
||||
chanSel_stack_enableSetCsaVsCmd(en);
|
||||
hci_stack_enableSetVsEvtMaskVsCmd(en);
|
||||
}
|
||||
|
||||
void ble_stack_enableVsEvents(bool en)
|
||||
{
|
||||
#if DEFAULT_BT_LE_ROLE_BROADCASTER
|
||||
adv_stack_enableScanReqRxdVsEvent(en);
|
||||
#endif // DEFAULT_BT_LE_ROLE_BROADCASTER
|
||||
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_enable(void)
|
||||
{
|
||||
#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;
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
13
components/bt/controller/esp32c2/ble_priv.h
Normal file
13
components/bt/controller/esp32c2/ble_priv.h
Normal file
@ -0,0 +1,13 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2025 Espressif Systems (Shanghai) CO LTD
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
#ifndef _BLE_PRIV_H_
|
||||
#define _BLE_PRIV_H_
|
||||
|
||||
int ble_stack_enable(void);
|
||||
|
||||
void ble_stack_disable(void);
|
||||
|
||||
#endif // _BLE_PRIV_H_
|
@ -35,6 +35,7 @@
|
||||
#include "os/endian.h"
|
||||
|
||||
#include "esp_bt.h"
|
||||
#include "ble_priv.h"
|
||||
#include "esp_intr_alloc.h"
|
||||
#include "esp_sleep.h"
|
||||
#include "esp_pm.h"
|
||||
@ -985,6 +986,12 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_enable();
|
||||
#endif
|
||||
|
||||
if (ble_stack_enable() != 0) {
|
||||
ret = ESP_FAIL;
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (ble_controller_enable(mode) != 0) {
|
||||
ret = ESP_FAIL;
|
||||
goto error;
|
||||
@ -994,6 +1001,7 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
|
||||
return ESP_OK;
|
||||
|
||||
error:
|
||||
ble_stack_disable();
|
||||
#if CONFIG_SW_COEXIST_ENABLE
|
||||
coex_disable();
|
||||
#endif
|
||||
@ -1016,7 +1024,7 @@ esp_err_t esp_bt_controller_disable(void)
|
||||
if (ble_controller_disable() != 0) {
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
ble_stack_disable();
|
||||
if (s_ble_active) {
|
||||
esp_phy_disable(PHY_MODEM_BT);
|
||||
#if CONFIG_PM_ENABLE
|
||||
|
Submodule components/bt/controller/lib_esp32c2/esp32c2-bt-lib updated: 3ce1675e0e...c0d98a9a03
@ -144,7 +144,7 @@ r_ble_ll_adv_reset = 0x40000c88;
|
||||
r_ble_ll_adv_rpa_timeout = 0x40000c8c;
|
||||
r_ble_ll_adv_rpa_update = 0x40000c90;
|
||||
r_ble_ll_adv_rx_pkt_in = 0x40000c94;
|
||||
r_ble_ll_adv_scan_req_rxd = 0x40000c98;
|
||||
//r_ble_ll_adv_scan_req_rxd = 0x40000c98;
|
||||
r_ble_ll_adv_scan_rsp_legacy_pdu_make = 0x40000c9c;
|
||||
r_ble_ll_adv_scan_rsp_pdu_make = 0x40000ca0;
|
||||
r_ble_ll_adv_scheduled = 0x40000ca4;
|
||||
@ -400,7 +400,7 @@ r_ble_ll_hci_set_adv_data = 0x40001088;
|
||||
r_ble_ll_hci_set_le_event_mask = 0x4000108c;
|
||||
r_ble_ll_hci_set_scan_rsp_data = 0x40001090;
|
||||
r_ble_ll_hci_status_params_cmd_proc = 0x40001094;
|
||||
r_ble_ll_hci_vs_cmd_proc = 0x40001098;
|
||||
//r_ble_ll_hci_vs_cmd_proc = 0x40001098;
|
||||
r_ble_ll_hci_vs_rd_static_addr = 0x4000109c;
|
||||
r_ble_ll_hw_err_timer_cb = 0x400010a0;
|
||||
r_ble_ll_hw_error = 0x400010a4;
|
||||
@ -755,7 +755,7 @@ r_ble_lll_hci_dtm_tx_test_v2 = 0x40001614;
|
||||
r_ble_lll_hci_dtm_tx_test_v2_ext = 0x40001618;
|
||||
r_ble_lll_init = 0x4000161c;
|
||||
r_ble_lll_init_pre_process = 0x40001620;
|
||||
r_ble_lll_init_rx_pkt_isr = 0x40001624;
|
||||
//r_ble_lll_init_rx_pkt_isr = 0x40001624;
|
||||
r_ble_lll_per_adv_coex_dpc_calc_pti_update_itvl = 0x40001628;
|
||||
r_ble_lll_per_adv_coex_dpc_process = 0x4000162c;
|
||||
r_ble_lll_per_adv_coex_dpc_pti_get = 0x40001630;
|
||||
@ -937,7 +937,7 @@ r_ble_phy_xcvr_state_get = 0x400018ec;
|
||||
r_ble_plf_set_log_level = 0x400018f0;
|
||||
r_ble_rtc_wake_up_cpu_init = 0x400018f4;
|
||||
r_ble_rtc_wake_up_state_clr = 0x400018f8;
|
||||
r_ble_vendor_hci_register = 0x400018fc;
|
||||
//r_ble_vendor_hci_register = 0x400018fc;
|
||||
r_bt_rf_coex_cfg_set = 0x40001900;
|
||||
r_bt_rf_coex_coded_txrx_time_upper_lim = 0x40001904;
|
||||
r_bt_rf_coex_dft_pti_set = 0x40001908;
|
||||
@ -1173,7 +1173,7 @@ r_ble_ll_get_npl_element_info = 0x40002f48;
|
||||
r_ble_rtc_wake_up_cpu_clr = 0x40002f4c;
|
||||
r_ble_ll_scan_hci_set_adv_report_flow_ctrl = 0x40002f50;
|
||||
r_ble_ll_scan_hci_update_adv_report_flow_ctrl = 0x40002f54;
|
||||
r_ble_ll_scan_send_adv_lost_report = 0x40002f58;
|
||||
//r_ble_ll_scan_send_adv_lost_report = 0x40002f58;
|
||||
r_ble_ll_scan_adv_report_cth_flow_is_enabled = 0x40002f5c;
|
||||
r_ble_ll_scan_adv_report_cth_flow_alloc_credit = 0x40002f60;
|
||||
r_ble_ll_scan_adv_report_cth_flow_free_credit = 0x40002f64;
|
||||
|
@ -118,7 +118,7 @@ r_ble_ll_adv_rd_sup_adv_sets = 0x40000c7c;
|
||||
r_ble_ll_adv_read_txpwr = 0x40000c80;
|
||||
r_ble_ll_adv_rpa_timeout = 0x40000c8c;
|
||||
r_ble_ll_adv_rpa_update = 0x40000c90;
|
||||
r_ble_ll_adv_scan_req_rxd = 0x40000c98;
|
||||
//r_ble_ll_adv_scan_req_rxd = 0x40000c98;
|
||||
r_ble_ll_adv_scan_rsp_legacy_pdu_make = 0x40000c9c;
|
||||
r_ble_ll_adv_scan_rsp_pdu_make = 0x40000ca0;
|
||||
r_ble_ll_adv_scheduled = 0x40000ca4;
|
||||
@ -320,7 +320,7 @@ r_ble_ll_hci_set_adv_data = 0x40001088;
|
||||
r_ble_ll_hci_set_le_event_mask = 0x4000108c;
|
||||
r_ble_ll_hci_set_scan_rsp_data = 0x40001090;
|
||||
r_ble_ll_hci_status_params_cmd_proc = 0x40001094;
|
||||
r_ble_ll_hci_vs_cmd_proc = 0x40001098;
|
||||
//r_ble_ll_hci_vs_cmd_proc = 0x40001098;
|
||||
r_ble_ll_hci_vs_rd_static_addr = 0x4000109c;
|
||||
r_ble_ll_hw_err_timer_cb = 0x400010a0;
|
||||
r_ble_ll_hw_error = 0x400010a4;
|
||||
@ -739,7 +739,7 @@ r_ble_phy_xcvr_state_get = 0x400018ec;
|
||||
r_ble_plf_set_log_level = 0x400018f0;
|
||||
r_ble_rtc_wake_up_cpu_init = 0x400018f4;
|
||||
r_ble_rtc_wake_up_state_clr = 0x400018f8;
|
||||
r_ble_vendor_hci_register = 0x400018fc;
|
||||
//r_ble_vendor_hci_register = 0x400018fc;
|
||||
r_bt_rf_coex_cfg_set = 0x40001900;
|
||||
r_bt_rf_coex_coded_txrx_time_upper_lim = 0x40001904;
|
||||
r_bt_rf_coex_dft_pti_set = 0x40001908;
|
||||
|
Reference in New Issue
Block a user