kopia lustrzana https://github.com/espressif/esp-idf
change(bt): Rename linker script file names and symbol names
1. rename linker files 2. support memory release in case that ESP_ALLOW_BSS_SEG_EXTERNAL_MEMORY is enabled 3. improve the implementation of memory releaserelease/v5.1
rodzic
d01f09044e
commit
cc0485e40d
|
@ -24,8 +24,7 @@ if(CONFIG_BT_ENABLED)
|
||||||
elseif(CONFIG_IDF_TARGET_ESP32C2)
|
elseif(CONFIG_IDF_TARGET_ESP32C2)
|
||||||
list(APPEND srcs "controller/esp32c2/bt.c")
|
list(APPEND srcs "controller/esp32c2/bt.c")
|
||||||
list(APPEND include_dirs include/esp32c2/include)
|
list(APPEND include_dirs include/esp32c2/include)
|
||||||
set(ldscripts "linker_common_esp32c2.lf")
|
set(ldscripts "linker_esp32c2.lf")
|
||||||
list(APPEND ldscripts "linker_esp_ble_controller.lf")
|
|
||||||
|
|
||||||
elseif(CONFIG_IDF_TARGET_ESP32C6)
|
elseif(CONFIG_IDF_TARGET_ESP32C6)
|
||||||
list(APPEND srcs "controller/esp32c6/bt.c")
|
list(APPEND srcs "controller/esp32c6/bt.c")
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2024 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
|
@ -756,7 +756,7 @@ static int32_t queue_send_hlevel_wrapper(void *queue, void *item, uint32_t block
|
||||||
* @param item The message which will be send
|
* @param item The message which will be send
|
||||||
* @param hptw need do task yield or not
|
* @param hptw need do task yield or not
|
||||||
* @return send success or not
|
* @return send success or not
|
||||||
* There is an issue here: When the queue is full, it may reture true but it send fail to the queue, sometimes.
|
* There is an issue here: When the queue is full, it may return true but it send fail to the queue, sometimes.
|
||||||
* But in Bluetooth controller's isr, We don't care about the return value.
|
* But in Bluetooth controller's isr, We don't care about the return value.
|
||||||
* It only required tp send success when the queue is empty all the time.
|
* It only required tp send success when the queue is empty all the time.
|
||||||
* So, this function meets the requirement.
|
* So, this function meets the requirement.
|
||||||
|
@ -1296,7 +1296,26 @@ static esp_err_t esp_bt_mem_release_area(const bt_area_t *area)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t esp_bt_controller_mem_release(esp_bt_mode_t mode)
|
static esp_err_t esp_bt_mem_release_areas(const bt_area_t *area1, const bt_area_t *area2)
|
||||||
|
{
|
||||||
|
esp_err_t ret = ESP_OK;
|
||||||
|
|
||||||
|
if (area1->end == area2->start) {
|
||||||
|
bt_area_t merged_area = {
|
||||||
|
.start = area1->start,
|
||||||
|
.end = area2->end,
|
||||||
|
.name = area1->name
|
||||||
|
};
|
||||||
|
ret = esp_bt_mem_release_area(&merged_area);
|
||||||
|
} else {
|
||||||
|
esp_bt_mem_release_area(area1);
|
||||||
|
ret = esp_bt_mem_release_area(area2);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static esp_err_t esp_bt_controller_rom_mem_release(esp_bt_mode_t mode)
|
||||||
{
|
{
|
||||||
bool update = true;
|
bool update = true;
|
||||||
intptr_t mem_start=(intptr_t) NULL, mem_end=(intptr_t) NULL;
|
intptr_t mem_start=(intptr_t) NULL, mem_end=(intptr_t) NULL;
|
||||||
|
@ -1347,6 +1366,17 @@ esp_err_t esp_bt_controller_mem_release(esp_bt_mode_t mode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
esp_err_t esp_bt_controller_mem_release(esp_bt_mode_t mode)
|
||||||
|
{
|
||||||
|
esp_err_t ret = ESP_OK;
|
||||||
|
|
||||||
|
if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) {
|
||||||
|
return ESP_ERR_INVALID_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
if (mode == ESP_BT_MODE_BTDM) {
|
if (mode == ESP_BT_MODE_BTDM) {
|
||||||
bt_area_t cont_bss = {
|
bt_area_t cont_bss = {
|
||||||
.start = (intptr_t)&_bt_controller_bss_start,
|
.start = (intptr_t)&_bt_controller_bss_start,
|
||||||
|
@ -1358,51 +1388,64 @@ esp_err_t esp_bt_controller_mem_release(esp_bt_mode_t mode)
|
||||||
.end = (intptr_t)&_bt_controller_data_end,
|
.end = (intptr_t)&_bt_controller_data_end,
|
||||||
.name = "BT Controller Data"
|
.name = "BT Controller Data"
|
||||||
};
|
};
|
||||||
esp_bt_mem_release_area(&cont_bss);
|
|
||||||
esp_bt_mem_release_area(&cont_data);
|
ret = esp_bt_mem_release_areas(&cont_data, &cont_bss);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ESP_OK;
|
if (ret == ESP_OK) {
|
||||||
|
ret = esp_bt_controller_rom_mem_release(mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
esp_err_t esp_bt_mem_release(esp_bt_mode_t mode)
|
esp_err_t esp_bt_mem_release(esp_bt_mode_t mode)
|
||||||
{
|
{
|
||||||
int ret;
|
esp_err_t ret = ESP_OK;
|
||||||
intptr_t mem_start, mem_end;
|
|
||||||
|
|
||||||
ret = esp_bt_controller_mem_release(mode);
|
if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) {
|
||||||
if (ret != ESP_OK) {
|
return ESP_ERR_INVALID_STATE;
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bt_area_t bss = {
|
||||||
|
.start = (intptr_t)&_bt_bss_start,
|
||||||
|
.end = (intptr_t)&_bt_bss_end,
|
||||||
|
.name = "BT BSS",
|
||||||
|
};
|
||||||
|
bt_area_t cont_bss = {
|
||||||
|
.start = (intptr_t)&_bt_controller_bss_start,
|
||||||
|
.end = (intptr_t)&_bt_controller_bss_end,
|
||||||
|
.name = "BT Controller BSS",
|
||||||
|
};
|
||||||
|
bt_area_t data = {
|
||||||
|
.start = (intptr_t)&_bt_data_start,
|
||||||
|
.end = (intptr_t)&_bt_data_end,
|
||||||
|
.name = "BT Data",
|
||||||
|
};
|
||||||
|
bt_area_t cont_data = {
|
||||||
|
.start = (intptr_t)&_bt_controller_data_start,
|
||||||
|
.end = (intptr_t)&_bt_controller_data_end,
|
||||||
|
.name = "BT Controller Data"
|
||||||
|
};
|
||||||
|
|
||||||
if (mode == ESP_BT_MODE_BTDM) {
|
if (mode == ESP_BT_MODE_BTDM) {
|
||||||
mem_start = (intptr_t)&_bt_bss_start;
|
/* Start by freeing Bluetooth BSS section */
|
||||||
mem_end = (intptr_t)&_bt_bss_end;
|
if (ret == ESP_OK) {
|
||||||
if (mem_start != mem_end) {
|
ret = esp_bt_mem_release_areas(&bss, &cont_bss);
|
||||||
ESP_LOGD(BTDM_LOG_TAG, "Release BT BSS [0x%08x] - [0x%08x]", mem_start, mem_end);
|
|
||||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
|
||||||
}
|
|
||||||
mem_start = (intptr_t)&_bt_data_start;
|
|
||||||
mem_end = (intptr_t)&_bt_data_end;
|
|
||||||
if (mem_start != mem_end) {
|
|
||||||
ESP_LOGD(BTDM_LOG_TAG, "Release BT Data [0x%08x] - [0x%08x]", mem_start, mem_end);
|
|
||||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
mem_start = (intptr_t)&_bt_controller_bss_start;
|
/* Do the same thing with the Bluetooth data section */
|
||||||
mem_end = (intptr_t)&_bt_controller_bss_end;
|
if (ret == ESP_OK) {
|
||||||
if (mem_start != mem_end) {
|
ret = esp_bt_mem_release_areas(&data, &cont_data);
|
||||||
ESP_LOGD(BTDM_LOG_TAG, "Release Controller BSS [0x%08x] - [0x%08x]", mem_start, mem_end);
|
|
||||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
|
||||||
}
|
|
||||||
mem_start = (intptr_t)&_bt_controller_data_start;
|
|
||||||
mem_end = (intptr_t)&_bt_controller_data_end;
|
|
||||||
if (mem_start != mem_end) {
|
|
||||||
ESP_LOGD(BTDM_LOG_TAG, "Release Controller Data [0x%08x] - [0x%08x]", mem_start, mem_end);
|
|
||||||
ESP_ERROR_CHECK(try_heap_caps_add_region(mem_start, mem_end));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ESP_OK;
|
|
||||||
|
/* free data and BSS section for Bluetooth controller ROM code */
|
||||||
|
if (ret == ESP_OK) {
|
||||||
|
ret = esp_bt_controller_rom_mem_release(mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CONFIG_BTDM_CTRL_HLI
|
#if CONFIG_BTDM_CTRL_HLI
|
||||||
|
@ -1711,7 +1754,7 @@ esp_err_t esp_bt_controller_enable(esp_bt_mode_t mode)
|
||||||
|
|
||||||
sdk_config_set_bt_pll_track_enable(true);
|
sdk_config_set_bt_pll_track_enable(true);
|
||||||
|
|
||||||
// inititalize bluetooth baseband
|
// initialize bluetooth baseband
|
||||||
btdm_check_and_init_bb();
|
btdm_check_and_init_bb();
|
||||||
|
|
||||||
ret = btdm_controller_enable(mode);
|
ret = btdm_controller_enable(mode);
|
||||||
|
@ -1874,7 +1917,7 @@ esp_err_t esp_ble_scan_dupilcate_list_flush(void)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function re-write controller's function,
|
* This function re-write controller's function,
|
||||||
* As coredump can not show paramerters in function which is in a .a file.
|
* As coredump can not show parameters in function which is in a .a file.
|
||||||
*
|
*
|
||||||
* After coredump fixing this issue, just delete this function.
|
* After coredump fixing this issue, just delete this function.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -915,6 +915,7 @@ static esp_err_t esp_bt_mem_release_area(const bt_area_t *area)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifndef CONFIG_BT_RELEASE_IRAM
|
||||||
static esp_err_t esp_bt_mem_release_areas(const bt_area_t *area1, const bt_area_t *area2)
|
static esp_err_t esp_bt_mem_release_areas(const bt_area_t *area1, const bt_area_t *area2)
|
||||||
{
|
{
|
||||||
esp_err_t ret = ESP_OK;
|
esp_err_t ret = ESP_OK;
|
||||||
|
@ -933,6 +934,7 @@ static esp_err_t esp_bt_mem_release_areas(const bt_area_t *area1, const bt_area_
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
esp_err_t esp_bt_mem_release(esp_bt_mode_t mode)
|
esp_err_t esp_bt_mem_release(esp_bt_mode_t mode)
|
||||||
{
|
{
|
||||||
|
@ -945,18 +947,21 @@ esp_err_t esp_bt_mem_release(esp_bt_mode_t mode)
|
||||||
* memory into 3 different regions (IRAM, BLE-IRAM, DRAM). So `ESP_SYSTEM_PMP_IDRAM_SPLIT` needs
|
* memory into 3 different regions (IRAM, BLE-IRAM, DRAM). So `ESP_SYSTEM_PMP_IDRAM_SPLIT` needs
|
||||||
* to be disabled.
|
* to be disabled.
|
||||||
*/
|
*/
|
||||||
ESP_LOGE(NIMBLE_PORT_LOG_TAG, "`ESP_SYSTEM_PMP_IDRAM_SPLIT` should be disabled!");
|
#error "ESP_SYSTEM_PMP_IDRAM_SPLIT should be disabled to allow BT to be released"
|
||||||
assert(0);
|
|
||||||
#endif // CONFIG_BT_RELEASE_IRAM && CONFIG_ESP_SYSTEM_PMP_IDRAM_SPLIT
|
#endif // CONFIG_BT_RELEASE_IRAM && CONFIG_ESP_SYSTEM_PMP_IDRAM_SPLIT
|
||||||
|
|
||||||
|
if (ble_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) {
|
||||||
|
return ESP_ERR_INVALID_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
if ((mode & ESP_BT_MODE_BLE) == 0) {
|
if ((mode & ESP_BT_MODE_BLE) == 0) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if CONFIG_BT_RELEASE_IRAM
|
#if CONFIG_BT_RELEASE_IRAM
|
||||||
bt_area_t merged_region = {
|
bt_area_t merged_region = {
|
||||||
.start = (intptr_t)MAP_IRAM_TO_DRAM((intptr_t)&_iram_bt_text_start);
|
.start = (intptr_t)MAP_IRAM_TO_DRAM((intptr_t)&_iram_bt_text_start),
|
||||||
.end = (intptr_t)&_bss_bt_end;
|
.end = (intptr_t)&_bss_bt_end,
|
||||||
.name = "BT Text, BSS and Data"
|
.name = "BT Text, BSS and Data"
|
||||||
};
|
};
|
||||||
ret = esp_bt_mem_release_area(&merged_region);
|
ret = esp_bt_mem_release_area(&merged_region);
|
||||||
|
|
|
@ -947,42 +947,45 @@ typedef struct {
|
||||||
const char* name;
|
const char* name;
|
||||||
} bt_area_t;
|
} bt_area_t;
|
||||||
|
|
||||||
static esp_err_t esp_bt_mem_release_areas(const bt_area_t* area1, const bt_area_t* area2)
|
static esp_err_t esp_bt_mem_release_area(const bt_area_t *area)
|
||||||
{
|
{
|
||||||
esp_err_t ret = ESP_OK;
|
esp_err_t ret = ESP_OK;
|
||||||
intptr_t mem_start = 0;
|
intptr_t mem_start = area->start;
|
||||||
intptr_t mem_end = 0;
|
intptr_t mem_end = area->end;
|
||||||
|
|
||||||
if(area1->end == area2->start) {
|
|
||||||
mem_start = area1->start;
|
|
||||||
mem_end = area2->end;
|
|
||||||
if (mem_start != mem_end) {
|
if (mem_start != mem_end) {
|
||||||
ESP_LOGD(BT_LOG_TAG, "Release %s [0x%08x] - [0x%08x], len %d", area1->name, mem_start, mem_end, mem_end - mem_start);
|
ESP_LOGD(BT_LOG_TAG, "Release %s [0x%08x] - [0x%08x], len %d", area->name, mem_start, mem_end, mem_end - mem_start);
|
||||||
ret = try_heap_caps_add_region(mem_start, mem_end);
|
ret = try_heap_caps_add_region(mem_start, mem_end);
|
||||||
}
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static esp_err_t esp_bt_mem_release_areas(const bt_area_t *area1, const bt_area_t *area2)
|
||||||
|
{
|
||||||
|
esp_err_t ret = ESP_OK;
|
||||||
|
|
||||||
|
if (area1->end == area2->start) {
|
||||||
|
bt_area_t merged_area = {
|
||||||
|
.start = area1->start,
|
||||||
|
.end = area2->end,
|
||||||
|
.name = area1->name
|
||||||
|
};
|
||||||
|
ret = esp_bt_mem_release_area(&merged_area);
|
||||||
} else {
|
} else {
|
||||||
mem_start = area1->start;
|
esp_bt_mem_release_area(area1);
|
||||||
mem_end = area1->end;
|
ret = esp_bt_mem_release_area(area2);
|
||||||
if (mem_start != mem_end) {
|
|
||||||
ESP_LOGD(BT_LOG_TAG, "Release %s [0x%08x] - [0x%08x], len %d", area1->name, mem_start, mem_end, mem_end - mem_start);
|
|
||||||
ret = try_heap_caps_add_region(mem_start, mem_end);
|
|
||||||
}
|
|
||||||
|
|
||||||
mem_start = area2->start;
|
|
||||||
mem_end = area2->end;
|
|
||||||
if (ret == ESP_OK && mem_start != mem_end) {
|
|
||||||
ESP_LOGD(BT_LOG_TAG, "Release %s [0x%08x] - [0x%08x], len %d", area2->name, mem_start, mem_end, mem_end - mem_start);
|
|
||||||
ret = try_heap_caps_add_region(mem_start, mem_end);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
esp_err_t esp_bt_controller_rom_mem_release(esp_bt_mode_t mode)
|
||||||
esp_err_t esp_bt_controller_mem_release(esp_bt_mode_t mode)
|
|
||||||
{
|
{
|
||||||
esp_err_t ret = ESP_OK;
|
esp_err_t ret = ESP_OK;
|
||||||
|
|
||||||
|
if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) {
|
||||||
|
return ESP_ERR_INVALID_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
bt_area_t rom_btdm_data = {
|
bt_area_t rom_btdm_data = {
|
||||||
.start = (intptr_t) ets_rom_layout_p->data_start_btdm,
|
.start = (intptr_t) ets_rom_layout_p->data_start_btdm,
|
||||||
.end = (intptr_t) ets_rom_layout_p->data_end_btdm,
|
.end = (intptr_t) ets_rom_layout_p->data_end_btdm,
|
||||||
|
@ -1004,7 +1007,6 @@ esp_err_t esp_bt_controller_mem_release(esp_bt_mode_t mode)
|
||||||
.name = "ROM interface btdm BSS",
|
.name = "ROM interface btdm BSS",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) {
|
if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) {
|
||||||
ret = ESP_ERR_INVALID_STATE;
|
ret = ESP_ERR_INVALID_STATE;
|
||||||
}
|
}
|
||||||
|
@ -1023,9 +1025,48 @@ esp_err_t esp_bt_controller_mem_release(esp_bt_mode_t mode)
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
esp_err_t esp_bt_controller_mem_release(esp_bt_mode_t mode)
|
||||||
|
{
|
||||||
|
esp_err_t ret = ESP_OK;
|
||||||
|
|
||||||
|
if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) {
|
||||||
|
return ESP_ERR_INVALID_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
bt_area_t cont_bss = {
|
||||||
|
.start = (intptr_t)&_bt_controller_bss_start,
|
||||||
|
.end = (intptr_t)&_bt_controller_bss_end,
|
||||||
|
.name = "BT Controller BSS",
|
||||||
|
};
|
||||||
|
|
||||||
|
bt_area_t cont_data = {
|
||||||
|
.start = (intptr_t)&_bt_controller_data_start,
|
||||||
|
.end = (intptr_t)&_bt_controller_data_end,
|
||||||
|
.name = "BT Controller Data"
|
||||||
|
};
|
||||||
|
|
||||||
|
if (mode & ESP_BT_MODE_BLE) {
|
||||||
|
/* free data and BSS section for libbtdm_app.a */
|
||||||
|
if (ret == ESP_OK) {
|
||||||
|
ret = esp_bt_mem_release_areas(&cont_data, &cont_bss);
|
||||||
|
}
|
||||||
|
/* free data and BSS section for Bluetooth controller ROM code */
|
||||||
|
if (ret == ESP_OK) {
|
||||||
|
ret = esp_bt_controller_rom_mem_release(mode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
esp_err_t esp_bt_mem_release(esp_bt_mode_t mode)
|
esp_err_t esp_bt_mem_release(esp_bt_mode_t mode)
|
||||||
{
|
{
|
||||||
esp_err_t ret = ESP_OK;
|
esp_err_t ret = ESP_OK;
|
||||||
|
|
||||||
|
if (btdm_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) {
|
||||||
|
return ESP_ERR_INVALID_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
bt_area_t bss = {
|
bt_area_t bss = {
|
||||||
.start = (intptr_t)&_bt_bss_start,
|
.start = (intptr_t)&_bt_bss_start,
|
||||||
.end = (intptr_t)&_bt_bss_end,
|
.end = (intptr_t)&_bt_bss_end,
|
||||||
|
@ -1047,8 +1088,6 @@ esp_err_t esp_bt_mem_release(esp_bt_mode_t mode)
|
||||||
.name = "BT Controller Data"
|
.name = "BT Controller Data"
|
||||||
};
|
};
|
||||||
|
|
||||||
ret = esp_bt_controller_mem_release(mode);
|
|
||||||
|
|
||||||
if (mode & ESP_BT_MODE_BLE) {
|
if (mode & ESP_BT_MODE_BLE) {
|
||||||
/* Start by freeing Bluetooth BSS section */
|
/* Start by freeing Bluetooth BSS section */
|
||||||
if (ret == ESP_OK) {
|
if (ret == ESP_OK) {
|
||||||
|
@ -1059,6 +1098,11 @@ esp_err_t esp_bt_mem_release(esp_bt_mode_t mode)
|
||||||
if (ret == ESP_OK) {
|
if (ret == ESP_OK) {
|
||||||
ret = esp_bt_mem_release_areas(&data, &cont_data);
|
ret = esp_bt_mem_release_areas(&data, &cont_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* free data and BSS section for Bluetooth controller ROM code */
|
||||||
|
if (ret == ESP_OK) {
|
||||||
|
ret = esp_bt_controller_rom_mem_release(mode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -991,43 +991,45 @@ typedef struct {
|
||||||
const char* name;
|
const char* name;
|
||||||
} bt_area_t;
|
} bt_area_t;
|
||||||
|
|
||||||
|
static esp_err_t esp_bt_mem_release_area(const bt_area_t *area)
|
||||||
static esp_err_t esp_bt_mem_release_areas(const bt_area_t* area1, const bt_area_t* area2)
|
|
||||||
{
|
{
|
||||||
esp_err_t ret = ESP_OK;
|
esp_err_t ret = ESP_OK;
|
||||||
intptr_t mem_start = 0;
|
intptr_t mem_start = area->start;
|
||||||
intptr_t mem_end = 0;
|
intptr_t mem_end = area->end;
|
||||||
|
|
||||||
if(area1->end == area2->start) {
|
|
||||||
mem_start = area1->start;
|
|
||||||
mem_end = area2->end;
|
|
||||||
if (mem_start != mem_end) {
|
if (mem_start != mem_end) {
|
||||||
ESP_LOGD(NIMBLE_PORT_LOG_TAG, "Release %s [0x%08x] - [0x%08x], len %d", area1->name, mem_start, mem_end, mem_end - mem_start);
|
ESP_LOGD(NIMBLE_PORT_LOG_TAG, "Release %s [0x%08x] - [0x%08x], len %d", area->name, mem_start, mem_end, mem_end - mem_start);
|
||||||
ret = try_heap_caps_add_region(mem_start, mem_end);
|
ret = try_heap_caps_add_region(mem_start, mem_end);
|
||||||
}
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static esp_err_t esp_bt_mem_release_areas(const bt_area_t *area1, const bt_area_t *area2)
|
||||||
|
{
|
||||||
|
esp_err_t ret = ESP_OK;
|
||||||
|
|
||||||
|
if (area1->end == area2->start) {
|
||||||
|
bt_area_t merged_area = {
|
||||||
|
.start = area1->start,
|
||||||
|
.end = area2->end,
|
||||||
|
.name = area1->name
|
||||||
|
};
|
||||||
|
ret = esp_bt_mem_release_area(&merged_area);
|
||||||
} else {
|
} else {
|
||||||
mem_start = area1->start;
|
esp_bt_mem_release_area(area1);
|
||||||
mem_end = area1->end;
|
ret = esp_bt_mem_release_area(area2);
|
||||||
if (mem_start != mem_end) {
|
|
||||||
ESP_LOGD(NIMBLE_PORT_LOG_TAG, "Release %s [0x%08x] - [0x%08x], len %d", area1->name, mem_start, mem_end, mem_end - mem_start);
|
|
||||||
ret = try_heap_caps_add_region(mem_start, mem_end);
|
|
||||||
}
|
|
||||||
|
|
||||||
mem_start = area2->start;
|
|
||||||
mem_end = area2->end;
|
|
||||||
if (ret == ESP_OK && mem_start != mem_end) {
|
|
||||||
ESP_LOGD(NIMBLE_PORT_LOG_TAG, "Release %s [0x%08x] - [0x%08x], len %d", area2->name, mem_start, mem_end, mem_end - mem_start);
|
|
||||||
ret = try_heap_caps_add_region(mem_start, mem_end);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
esp_err_t esp_bt_mem_release(esp_bt_mode_t mode)
|
esp_err_t esp_bt_mem_release(esp_bt_mode_t mode)
|
||||||
{
|
{
|
||||||
esp_err_t ret = ESP_OK;
|
esp_err_t ret = ESP_OK;
|
||||||
|
|
||||||
|
if (ble_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) {
|
||||||
|
return ESP_ERR_INVALID_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
bt_area_t bss = {
|
bt_area_t bss = {
|
||||||
.start = (intptr_t)&_bt_bss_start,
|
.start = (intptr_t)&_bt_bss_start,
|
||||||
.end = (intptr_t)&_bt_bss_end,
|
.end = (intptr_t)&_bt_bss_end,
|
||||||
|
|
|
@ -964,33 +964,32 @@ typedef struct {
|
||||||
const char* name;
|
const char* name;
|
||||||
} bt_area_t;
|
} bt_area_t;
|
||||||
|
|
||||||
static esp_err_t esp_bt_mem_release_areas(const bt_area_t* area1, const bt_area_t* area2)
|
static esp_err_t esp_bt_mem_release_area(const bt_area_t *area)
|
||||||
{
|
{
|
||||||
esp_err_t ret = ESP_OK;
|
esp_err_t ret = ESP_OK;
|
||||||
intptr_t mem_start = 0;
|
intptr_t mem_start = area->start;
|
||||||
intptr_t mem_end = 0;
|
intptr_t mem_end = area->end;
|
||||||
|
|
||||||
if(area1->end == area2->start) {
|
|
||||||
mem_start = area1->start;
|
|
||||||
mem_end = area2->end;
|
|
||||||
if (mem_start != mem_end) {
|
if (mem_start != mem_end) {
|
||||||
ESP_LOGD(NIMBLE_PORT_LOG_TAG, "Release %s [0x%08x] - [0x%08x], len %d", area1->name, mem_start, mem_end, mem_end - mem_start);
|
ESP_LOGD(NIMBLE_PORT_LOG_TAG, "Release %s [0x%08x] - [0x%08x], len %d", area->name, mem_start, mem_end, mem_end - mem_start);
|
||||||
ret = try_heap_caps_add_region(mem_start, mem_end);
|
ret = try_heap_caps_add_region(mem_start, mem_end);
|
||||||
}
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
static esp_err_t esp_bt_mem_release_areas(const bt_area_t *area1, const bt_area_t *area2)
|
||||||
|
{
|
||||||
|
esp_err_t ret = ESP_OK;
|
||||||
|
|
||||||
|
if (area1->end == area2->start) {
|
||||||
|
bt_area_t merged_area = {
|
||||||
|
.start = area1->start,
|
||||||
|
.end = area2->end,
|
||||||
|
.name = area1->name
|
||||||
|
};
|
||||||
|
ret = esp_bt_mem_release_area(&merged_area);
|
||||||
} else {
|
} else {
|
||||||
mem_start = area1->start;
|
esp_bt_mem_release_area(area1);
|
||||||
mem_end = area1->end;
|
ret = esp_bt_mem_release_area(area2);
|
||||||
if (mem_start != mem_end) {
|
|
||||||
ESP_LOGD(NIMBLE_PORT_LOG_TAG, "Release %s [0x%08x] - [0x%08x], len %d", area1->name, mem_start, mem_end, mem_end - mem_start);
|
|
||||||
ret = try_heap_caps_add_region(mem_start, mem_end);
|
|
||||||
}
|
|
||||||
|
|
||||||
mem_start = area2->start;
|
|
||||||
mem_end = area2->end;
|
|
||||||
if (ret == ESP_OK && mem_start != mem_end) {
|
|
||||||
ESP_LOGD(NIMBLE_PORT_LOG_TAG, "Release %s [0x%08x] - [0x%08x], len %d", area2->name, mem_start, mem_end, mem_end - mem_start);
|
|
||||||
ret = try_heap_caps_add_region(mem_start, mem_end);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -999,6 +998,11 @@ static esp_err_t esp_bt_mem_release_areas(const bt_area_t* area1, const bt_area_
|
||||||
esp_err_t esp_bt_mem_release(esp_bt_mode_t mode)
|
esp_err_t esp_bt_mem_release(esp_bt_mode_t mode)
|
||||||
{
|
{
|
||||||
esp_err_t ret = ESP_OK;
|
esp_err_t ret = ESP_OK;
|
||||||
|
|
||||||
|
if (ble_controller_status != ESP_BT_CONTROLLER_STATUS_IDLE) {
|
||||||
|
return ESP_ERR_INVALID_STATE;
|
||||||
|
}
|
||||||
|
|
||||||
bt_area_t bss = {
|
bt_area_t bss = {
|
||||||
.start = (intptr_t)&_bt_bss_start,
|
.start = (intptr_t)&_bt_bss_start,
|
||||||
.end = (intptr_t)&_bt_bss_end,
|
.end = (intptr_t)&_bt_bss_end,
|
||||||
|
|
|
@ -6,7 +6,7 @@ entries:
|
||||||
entries:
|
entries:
|
||||||
COMMON
|
COMMON
|
||||||
|
|
||||||
[scheme:bt_start_end]
|
[scheme:bt_default]
|
||||||
entries:
|
entries:
|
||||||
bt_bss -> dram0_bss
|
bt_bss -> dram0_bss
|
||||||
bt_common -> dram0_bss
|
bt_common -> dram0_bss
|
||||||
|
@ -30,7 +30,13 @@ entries:
|
||||||
[mapping:bt]
|
[mapping:bt]
|
||||||
archive: libbt.a
|
archive: libbt.a
|
||||||
entries:
|
entries:
|
||||||
* (bt_start_end);
|
if ESP_ALLOW_BSS_SEG_EXTERNAL_MEMORY = y:
|
||||||
|
* (bt_extram_bss);
|
||||||
|
bt_bss -> extern_ram ALIGN(4) ALIGN(4, post) SURROUND(bt_bss),
|
||||||
|
bt_common -> extern_ram ALIGN(4) ALIGN(4, post) SURROUND(bt_common),
|
||||||
|
data -> dram0_data ALIGN(4) ALIGN(4, post) SURROUND(bt_data)
|
||||||
|
else:
|
||||||
|
* (bt_default);
|
||||||
bt_bss -> dram0_bss ALIGN(4) ALIGN(4, post) SURROUND(bt_bss),
|
bt_bss -> dram0_bss ALIGN(4) ALIGN(4, post) SURROUND(bt_bss),
|
||||||
bt_common -> dram0_bss ALIGN(4) ALIGN(4, post) SURROUND(bt_common),
|
bt_common -> dram0_bss ALIGN(4) ALIGN(4, post) SURROUND(bt_common),
|
||||||
data -> dram0_data ALIGN(4) ALIGN(4, post) SURROUND(bt_data)
|
data -> dram0_data ALIGN(4) ALIGN(4, post) SURROUND(bt_data)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
[sections:bt_text]
|
[sections:bt_iram_text]
|
||||||
entries:
|
entries:
|
||||||
.iram1+
|
.iram1+
|
||||||
|
|
||||||
|
@ -17,9 +17,9 @@ entries:
|
||||||
entries:
|
entries:
|
||||||
COMMON
|
COMMON
|
||||||
|
|
||||||
[scheme:bt_start_end]
|
[scheme:bt_default]
|
||||||
entries:
|
entries:
|
||||||
bt_text -> iram0_bt_text
|
bt_iram_text -> iram0_bt_text
|
||||||
bt_bss -> dram0_bt_bss
|
bt_bss -> dram0_bt_bss
|
||||||
bt_common -> dram0_bt_bss
|
bt_common -> dram0_bt_bss
|
||||||
bt_data -> dram0_bt_data
|
bt_data -> dram0_bt_data
|
||||||
|
@ -36,7 +36,15 @@ entries:
|
||||||
[mapping:bt]
|
[mapping:bt]
|
||||||
archive: libbt.a
|
archive: libbt.a
|
||||||
entries:
|
entries:
|
||||||
* (bt_start_end);
|
* (bt_default);
|
||||||
bt_bss -> dram0_bt_bss ALIGN(4) ALIGN(4, post) SURROUND(bt_bss),
|
bt_bss -> dram0_bt_bss ALIGN(4) ALIGN(4, post) SURROUND(bt_bss),
|
||||||
bt_common -> dram0_bt_bss ALIGN(4) ALIGN(4, post) SURROUND(bt_common),
|
bt_common -> dram0_bt_bss ALIGN(4) ALIGN(4, post) SURROUND(bt_common),
|
||||||
bt_data -> dram0_bt_data ALIGN(4) ALIGN(4, post) SURROUND(bt_data)
|
bt_data -> dram0_bt_data ALIGN(4) ALIGN(4, post) SURROUND(bt_data)
|
||||||
|
|
||||||
|
[mapping:ble_app]
|
||||||
|
archive: libble_app.a
|
||||||
|
entries:
|
||||||
|
* (bt_default);
|
||||||
|
bt_bss -> dram0_bt_bss ALIGN(4) ALIGN(4, post) SURROUND(bt_controller_bss),
|
||||||
|
bt_common -> dram0_bt_bss ALIGN(4) ALIGN(4, post) SURROUND(bt_controller_common),
|
||||||
|
bt_data -> dram0_bt_data ALIGN(4) ALIGN(4, post) SURROUND(bt_controller_data)
|
|
@ -1,7 +1,7 @@
|
||||||
[mapping:ble_app]
|
[mapping:ble_app]
|
||||||
archive: libble_app.a
|
archive: libble_app.a
|
||||||
entries:
|
entries:
|
||||||
* (bt_start_end);
|
* (bt_default);
|
||||||
bt_bss -> dram0_bss ALIGN(4) ALIGN(4, post) SURROUND(bt_controller_bss),
|
bt_bss -> dram0_bss ALIGN(4) ALIGN(4, post) SURROUND(bt_controller_bss),
|
||||||
bt_common -> dram0_bss ALIGN(4) ALIGN(4, post) SURROUND(bt_controller_common),
|
bt_common -> dram0_bss ALIGN(4) ALIGN(4, post) SURROUND(bt_controller_common),
|
||||||
data -> dram0_data ALIGN(4) ALIGN(4, post) SURROUND(bt_controller_data)
|
data -> dram0_data ALIGN(4) ALIGN(4, post) SURROUND(bt_controller_data)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
[mapping:btdm]
|
[mapping:btdm]
|
||||||
archive: libbtdm_app.a
|
archive: libbtdm_app.a
|
||||||
entries:
|
entries:
|
||||||
* (bt_start_end);
|
* (bt_default);
|
||||||
bt_bss -> dram0_bss ALIGN(4) ALIGN(4, post) SURROUND(bt_controller_bss),
|
bt_bss -> dram0_bss ALIGN(4) ALIGN(4, post) SURROUND(bt_controller_bss),
|
||||||
bt_common -> dram0_bss ALIGN(4) ALIGN(4, post) SURROUND(bt_controller_common),
|
bt_common -> dram0_bss ALIGN(4) ALIGN(4, post) SURROUND(bt_controller_common),
|
||||||
data -> dram0_data ALIGN(4) ALIGN(4, post) SURROUND(bt_controller_data)
|
data -> dram0_data ALIGN(4) ALIGN(4, post) SURROUND(bt_controller_data)
|
||||||
|
|
Ładowanie…
Reference in New Issue