mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
component/bt : fix btdm mem release cause 0x3ffbbb28-0x3ffbdb28 add to region but should not.
1. fix the bug. Modify the condition that esp_bt_controller_mem_release() shoud be only called before esp_bt_controller_init() or after esp_bt_controller_deinit() 2. modify the example to use esp_bt_controller_mem_release()
This commit is contained in:
parent
a7a861962d
commit
65bdb2d7ff
@ -398,10 +398,8 @@ esp_err_t esp_bt_controller_mem_release(esp_bt_mode_t mode)
|
|||||||
bool update = true;
|
bool update = true;
|
||||||
intptr_t mem_start, mem_end;
|
intptr_t mem_start, mem_end;
|
||||||
|
|
||||||
//get the mode which can be released, skip the mode which is running
|
if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) {
|
||||||
mode &= ~btdm_controller_get_mode();
|
return ESP_ERR_INVALID_STATE;
|
||||||
if (mode == 0x0) {
|
|
||||||
return ESP_ERR_INVALID_ARG;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//already relesed
|
//already relesed
|
||||||
|
@ -212,20 +212,18 @@ void esp_vhci_host_register_callback(const esp_vhci_host_callback_t *callback);
|
|||||||
* it can release the .bbs, .data and other section to heap.
|
* it can release the .bbs, .data and other section to heap.
|
||||||
* The total size is about 70k bytes.
|
* The total size is about 70k bytes.
|
||||||
*
|
*
|
||||||
* If esp_bt_controller_enable(mode) has already been called, calling
|
* esp_bt_controller_mem_release(mode) should be called only before esp_bt_controller_init()
|
||||||
* esp_bt_controller_mem_release(ESP_BT_MODE_BTDM) will automatically
|
* or after esp_bt_controller_deinit().
|
||||||
* release all memory which is not needed for the currently enabled
|
|
||||||
* Bluetooth controller mode.
|
|
||||||
*
|
*
|
||||||
* For example, calling esp_bt_controller_enable(ESP_BT_MODE_BLE) then
|
* Note that once BT controller memory is released, the process cannot be reversed. It means you can not use the bluetooth
|
||||||
* esp_bt_controller_mem_release(ESP_BT_MODE_BTDM) will enable BLE modes
|
* mode which you have released by this function.
|
||||||
* and release memory only used by BT Classic. Also, call esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT)
|
|
||||||
* is the same.
|
|
||||||
*
|
*
|
||||||
* Note that once BT controller memory is released, the process cannot be reversed.
|
|
||||||
* If your firmware will later upgrade the Bluetooth controller mode (BLE -> BT Classic or disabled -> enabled)
|
* If your firmware will later upgrade the Bluetooth controller mode (BLE -> BT Classic or disabled -> enabled)
|
||||||
* then do not call this function.
|
* then do not call this function.
|
||||||
*
|
*
|
||||||
|
* If the app calls esp_bt_controller_enable(ESP_BT_MODE_BLE) to use BLE only then it is safe to call
|
||||||
|
* esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT) at initialisation time to free unused BT Classic memory.
|
||||||
|
*
|
||||||
* If user never use bluetooth controller, could call esp_bt_controller_mem_release(ESP_BT_MODE_BTDM)
|
* If user never use bluetooth controller, could call esp_bt_controller_mem_release(ESP_BT_MODE_BTDM)
|
||||||
* before esp_bt_controller_init or after esp_bt_controller_deinit.
|
* before esp_bt_controller_init or after esp_bt_controller_deinit.
|
||||||
*
|
*
|
||||||
|
@ -83,6 +83,7 @@ void app_main()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_BLE));
|
||||||
|
|
||||||
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
|
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
|
||||||
if (esp_bt_controller_init(&bt_cfg) != ESP_OK) {
|
if (esp_bt_controller_init(&bt_cfg) != ESP_OK) {
|
||||||
|
@ -166,9 +166,10 @@ void esp_eddystone_init(void)
|
|||||||
void app_main()
|
void app_main()
|
||||||
{
|
{
|
||||||
ESP_ERROR_CHECK(nvs_flash_init());
|
ESP_ERROR_CHECK(nvs_flash_init());
|
||||||
|
ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT));
|
||||||
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
|
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
|
||||||
esp_bt_controller_init(&bt_cfg);
|
esp_bt_controller_init(&bt_cfg);
|
||||||
esp_bt_controller_enable(ESP_BT_MODE_BTDM);
|
esp_bt_controller_enable(ESP_BT_MODE_BLE);
|
||||||
|
|
||||||
esp_eddystone_init();
|
esp_eddystone_init();
|
||||||
|
|
||||||
|
@ -160,9 +160,10 @@ void ble_ibeacon_init(void)
|
|||||||
void app_main()
|
void app_main()
|
||||||
{
|
{
|
||||||
ESP_ERROR_CHECK(nvs_flash_init());
|
ESP_ERROR_CHECK(nvs_flash_init());
|
||||||
|
ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT));
|
||||||
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
|
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
|
||||||
esp_bt_controller_init(&bt_cfg);
|
esp_bt_controller_init(&bt_cfg);
|
||||||
esp_bt_controller_enable(ESP_BT_MODE_BTDM);
|
esp_bt_controller_enable(ESP_BT_MODE_BLE);
|
||||||
|
|
||||||
ble_ibeacon_init();
|
ble_ibeacon_init();
|
||||||
|
|
||||||
|
@ -956,6 +956,9 @@ static void spp_uart_init(void)
|
|||||||
void app_main()
|
void app_main()
|
||||||
{
|
{
|
||||||
esp_err_t ret;
|
esp_err_t ret;
|
||||||
|
|
||||||
|
ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT));
|
||||||
|
|
||||||
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
|
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
|
||||||
|
|
||||||
nvs_flash_init();
|
nvs_flash_init();
|
||||||
@ -965,7 +968,7 @@ void app_main()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = esp_bt_controller_enable(ESP_BT_MODE_BTDM);
|
ret = esp_bt_controller_enable(ESP_BT_MODE_BLE);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
ESP_LOGE(GATTC_TAG, "%s enable controller failed\n", __func__);
|
ESP_LOGE(GATTC_TAG, "%s enable controller failed\n", __func__);
|
||||||
return;
|
return;
|
||||||
|
@ -658,14 +658,23 @@ void app_main()
|
|||||||
esp_err_t ret;
|
esp_err_t ret;
|
||||||
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
|
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
|
||||||
|
|
||||||
nvs_flash_init();
|
// Initialize NVS
|
||||||
|
ret = nvs_flash_init();
|
||||||
|
if (ret == ESP_ERR_NVS_NO_FREE_PAGES) {
|
||||||
|
ESP_ERROR_CHECK(nvs_flash_erase());
|
||||||
|
ret = nvs_flash_init();
|
||||||
|
}
|
||||||
|
ESP_ERROR_CHECK( ret );
|
||||||
|
|
||||||
|
ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT));
|
||||||
|
|
||||||
ret = esp_bt_controller_init(&bt_cfg);
|
ret = esp_bt_controller_init(&bt_cfg);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
ESP_LOGE(GATTS_TABLE_TAG, "%s enable controller failed\n", __func__);
|
ESP_LOGE(GATTS_TABLE_TAG, "%s enable controller failed\n", __func__);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = esp_bt_controller_enable(ESP_BT_MODE_BTDM);
|
ret = esp_bt_controller_enable(ESP_BT_MODE_BLE);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
ESP_LOGE(GATTS_TABLE_TAG, "%s enable controller failed\n", __func__);
|
ESP_LOGE(GATTS_TABLE_TAG, "%s enable controller failed\n", __func__);
|
||||||
return;
|
return;
|
||||||
|
@ -331,13 +331,15 @@ void app_main()
|
|||||||
|
|
||||||
initialise_wifi();
|
initialise_wifi();
|
||||||
|
|
||||||
|
ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT));
|
||||||
|
|
||||||
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
|
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
|
||||||
ret = esp_bt_controller_init(&bt_cfg);
|
ret = esp_bt_controller_init(&bt_cfg);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
BLUFI_ERROR("%s initialize bt controller failed\n", __func__);
|
BLUFI_ERROR("%s initialize bt controller failed\n", __func__);
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = esp_bt_controller_enable(ESP_BT_MODE_BTDM);
|
ret = esp_bt_controller_enable(ESP_BT_MODE_BLE);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
BLUFI_ERROR("%s enable bt controller failed\n", __func__);
|
BLUFI_ERROR("%s enable bt controller failed\n", __func__);
|
||||||
return;
|
return;
|
||||||
|
@ -425,6 +425,8 @@ void app_main()
|
|||||||
}
|
}
|
||||||
ESP_ERROR_CHECK( ret );
|
ESP_ERROR_CHECK( ret );
|
||||||
|
|
||||||
|
ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT));
|
||||||
|
|
||||||
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
|
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
|
||||||
ret = esp_bt_controller_init(&bt_cfg);
|
ret = esp_bt_controller_init(&bt_cfg);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
@ -432,7 +434,7 @@ void app_main()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = esp_bt_controller_enable(ESP_BT_MODE_BTDM);
|
ret = esp_bt_controller_enable(ESP_BT_MODE_BLE);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
ESP_LOGE(GATTC_TAG, "%s enable controller failed, error code = %x\n", __func__, ret);
|
ESP_LOGE(GATTC_TAG, "%s enable controller failed, error code = %x\n", __func__, ret);
|
||||||
return;
|
return;
|
||||||
|
@ -468,6 +468,8 @@ void app_main()
|
|||||||
}
|
}
|
||||||
ESP_ERROR_CHECK( ret );
|
ESP_ERROR_CHECK( ret );
|
||||||
|
|
||||||
|
ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT));
|
||||||
|
|
||||||
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
|
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
|
||||||
ret = esp_bt_controller_init(&bt_cfg);
|
ret = esp_bt_controller_init(&bt_cfg);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
@ -475,7 +477,7 @@ void app_main()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = esp_bt_controller_enable(ESP_BT_MODE_BTDM);
|
ret = esp_bt_controller_enable(ESP_BT_MODE_BLE);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
ESP_LOGE(GATTC_TAG, "%s enable controller failed, error code = %x\n", __func__, ret);
|
ESP_LOGE(GATTC_TAG, "%s enable controller failed, error code = %x\n", __func__, ret);
|
||||||
return;
|
return;
|
||||||
|
@ -476,13 +476,15 @@ void app_main()
|
|||||||
}
|
}
|
||||||
ESP_ERROR_CHECK( ret );
|
ESP_ERROR_CHECK( ret );
|
||||||
|
|
||||||
|
ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT));
|
||||||
|
|
||||||
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
|
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
|
||||||
ret = esp_bt_controller_init(&bt_cfg);
|
ret = esp_bt_controller_init(&bt_cfg);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
ESP_LOGE(GATTS_TABLE_TAG, "%s init controller failed", __func__);
|
ESP_LOGE(GATTS_TABLE_TAG, "%s init controller failed", __func__);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ret = esp_bt_controller_enable(ESP_BT_MODE_BTDM);
|
ret = esp_bt_controller_enable(ESP_BT_MODE_BLE);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
ESP_LOGE(GATTS_TABLE_TAG, "%s enable controller failed", __func__);
|
ESP_LOGE(GATTS_TABLE_TAG, "%s enable controller failed", __func__);
|
||||||
return;
|
return;
|
||||||
|
@ -691,6 +691,8 @@ void app_main()
|
|||||||
}
|
}
|
||||||
ESP_ERROR_CHECK( ret );
|
ESP_ERROR_CHECK( ret );
|
||||||
|
|
||||||
|
ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT));
|
||||||
|
|
||||||
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
|
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
|
||||||
ret = esp_bt_controller_init(&bt_cfg);
|
ret = esp_bt_controller_init(&bt_cfg);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
@ -698,7 +700,7 @@ void app_main()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = esp_bt_controller_enable(ESP_BT_MODE_BTDM);
|
ret = esp_bt_controller_enable(ESP_BT_MODE_BLE);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
ESP_LOGE(GATTS_TAG, "%s enable controller failed\n", __func__);
|
ESP_LOGE(GATTS_TAG, "%s enable controller failed\n", __func__);
|
||||||
return;
|
return;
|
||||||
|
@ -522,6 +522,8 @@ void app_main()
|
|||||||
}
|
}
|
||||||
ESP_ERROR_CHECK( ret );
|
ESP_ERROR_CHECK( ret );
|
||||||
|
|
||||||
|
ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT));
|
||||||
|
|
||||||
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
|
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
|
||||||
ret = esp_bt_controller_init(&bt_cfg);
|
ret = esp_bt_controller_init(&bt_cfg);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
@ -529,7 +531,7 @@ void app_main()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = esp_bt_controller_enable(ESP_BT_MODE_BTDM);
|
ret = esp_bt_controller_enable(ESP_BT_MODE_BLE);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
ESP_LOGE(GATTS_TABLE_TAG, "%s enable controller failed\n", __func__);
|
ESP_LOGE(GATTS_TABLE_TAG, "%s enable controller failed\n", __func__);
|
||||||
return;
|
return;
|
||||||
|
@ -896,6 +896,8 @@ void app_main()
|
|||||||
}
|
}
|
||||||
ESP_ERROR_CHECK( ret );
|
ESP_ERROR_CHECK( ret );
|
||||||
|
|
||||||
|
ESP_ERROR_CHECK(esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT));
|
||||||
|
|
||||||
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
|
esp_bt_controller_config_t bt_cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
|
||||||
ret = esp_bt_controller_init(&bt_cfg);
|
ret = esp_bt_controller_init(&bt_cfg);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
@ -903,7 +905,7 @@ void app_main()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = esp_bt_controller_enable(ESP_BT_MODE_BTDM);
|
ret = esp_bt_controller_enable(ESP_BT_MODE_BLE);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
ESP_LOGE(GATTC_TAG, "%s enable controller failed\n", __func__);
|
ESP_LOGE(GATTC_TAG, "%s enable controller failed\n", __func__);
|
||||||
return;
|
return;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user