Merge branch 'feat/bt_in_psram' into 'master'

feat(bluedroid): Add config to place btu and hci task stack in psram

Closes BT-4136

See merge request espressif/esp-idf!51002
This commit is contained in:
Wang Meng Yang
2026-07-29 14:49:19 +08:00
6 changed files with 102 additions and 11 deletions
+28
View File
@@ -1375,6 +1375,34 @@ config BT_ALLOCATION_FROM_SPIRAM_FIRST
help
This select can save the internal RAM if there have the PSRAM
config BT_BLUEDROID_TASK_STACK_IN_EXT_MEM
bool "Place BT task stack in external memory"
depends on FREERTOS_TASK_CREATE_ALLOW_EXT_MEM && (!IDF_TARGET_ESP32 || SPIRAM_CACHE_WORKAROUND)
default n
help
Common prerequisites for placing Bluedroid host
task stacks in PSRAM.
config BT_BLUEDROID_BTU_TASK_STACK_IN_EXT_MEM
bool "Place BTU task stack in external memory"
depends on BT_BLUEDROID_TASK_STACK_IN_EXT_MEM
default n
help
Allocate BTU_TASK stack from external SPIRAM using static task
allocation. TCB remains in internal DRAM.
BTU does not perform NVS operations directly.
config BT_BLUEDROID_HCI_TASK_STACK_IN_EXT_MEM
bool "Place HCI host task stack in external memory"
depends on BT_BLUEDROID_TASK_STACK_IN_EXT_MEM
default n
help
Allocate HCI host task (hciT) stack from external SPIRAM using
static task allocation. TCB remains in internal DRAM.
HCI does not perform NVS operations.
config BT_BLE_DYNAMIC_ENV_MEMORY
bool "Use dynamic memory allocation in BT/BLE stack"
depends on BT_BLUEDROID_ENABLED
+6 -1
View File
@@ -114,8 +114,13 @@ int hci_start_up(void)
}
const size_t workqueue_len[] = {HCI_HOST_TASK_WORKQUEUE0_LEN, HCI_HOST_TASK_WORKQUEUE1_LEN};
#if (!CONFIG_BT_BLUEDROID_HCI_TASK_STACK_IN_EXT_MEM)
hci_host_thread = osi_thread_create(HCI_HOST_TASK_NAME, HCI_HOST_TASK_STACK_SIZE, HCI_HOST_TASK_PRIO, HCI_HOST_TASK_PINNED_TO_CORE,
HCI_HOST_TASK_WORKQUEUE_NUM, workqueue_len);
HCI_HOST_TASK_WORKQUEUE_NUM, workqueue_len, false);
#else
hci_host_thread = osi_thread_create(HCI_HOST_TASK_NAME, HCI_HOST_TASK_STACK_SIZE, HCI_HOST_TASK_PRIO, HCI_HOST_TASK_PINNED_TO_CORE,
HCI_HOST_TASK_WORKQUEUE_NUM, workqueue_len, true);
#endif
if (hci_host_thread == NULL) {
goto error;
}
@@ -195,8 +195,13 @@ bool BTU_StartUp(void)
osi_mutex_new(&btu_l2cap_alarm_lock);
const size_t workqueue_len[] = {BTU_TASK_WORKQUEUE0_LEN};
#if (!CONFIG_BT_BLUEDROID_BTU_TASK_STACK_IN_EXT_MEM)
btu_thread = osi_thread_create(BTU_TASK_NAME, BTU_TASK_STACK_SIZE, BTU_TASK_PRIO, BTU_TASK_PINNED_TO_CORE,
BTU_TASK_WORKQUEUE_NUM, workqueue_len);
BTU_TASK_WORKQUEUE_NUM, workqueue_len, false);
#else
btu_thread = osi_thread_create(BTU_TASK_NAME, BTU_TASK_STACK_SIZE, BTU_TASK_PRIO, BTU_TASK_PINNED_TO_CORE,
BTU_TASK_WORKQUEUE_NUM, workqueue_len, true);
#endif
if (btu_thread == NULL) {
goto error_exit;
}