components/bt: Fix broken API esp_bt_mem_release() for parameter ESP_BT_MODE_BTDM

Problem:
The new API esp_bt_mem_release() that was added freed BTDM data to heap from esp_bt_controller_mem_release().
Now with the BT memory optimization commit ee787085f9,
the BTDM data is optimized and reduced to only 32 bytes which is not sufficient amount to be added to heap.
So, using the API leads to assert saying that the region is too small.

Solution:
Modify heap_caps_add_region_with_caps to return ESP_ERR_INVALID_SIZE in case the range is too small to create a new heap.
Do not assert if return value is ESP_ERR_INVALID_SIZE

This also fixes using API esp_bt_controller_mem_release() with ESP_BT_MODE_BTDM

Signed-off-by: Hrishikesh Dhayagude <hrishi@espressif.com>
This commit is contained in:
Hrishikesh Dhayagude
2018-08-28 13:31:07 +05:30
committed by bot
parent a557e8cc14
commit 4abe47437f
3 changed files with 30 additions and 16 deletions

View File

@@ -81,6 +81,7 @@ esp_err_t heap_caps_add_region(intptr_t start, intptr_t end);
* - ESP_OK on success
* - ESP_ERR_INVALID_ARG if a parameter is invalid
* - ESP_ERR_NO_MEM if no memory to register new heap.
* - ESP_ERR_INVALID_SIZE if the memory region is too small to fit a heap
* - ESP_FAIL if region overlaps the start and/or end of an existing region
*/
esp_err_t heap_caps_add_region_with_caps(const uint32_t caps[], intptr_t start, intptr_t end);