mirror of
https://github.com/espressif/esp-idf.git
synced 2025-07-30 02:37:19 +02:00
Change BTC BTU Queue from INTERNALRAM to PSRAM and Increase the BTC BTU HCI_HOST queue size
Add CONFIG_SPIRAM_USE_MALLOC check and Add free mem when btc btu deinit in use psram mode Assign NULL to btc btu queue when deinit
This commit is contained in:
@ -186,10 +186,33 @@ bt_status_t btc_transfer_context(btc_msg_t *msg, void *arg, int arg_len, btc_arg
|
||||
return btc_task_post(&lmsg, TASK_POST_BLOCKING);
|
||||
}
|
||||
|
||||
#if (CONFIG_SPIRAM_USE_MALLOC && CONFIG_BT_ALLOCATION_FROM_SPIRAM_FIRST)
|
||||
StaticQueue_t *btc_queue_buffer = NULL;
|
||||
uint8_t *btc_queue_storage = NULL;
|
||||
#endif
|
||||
|
||||
int btc_init(void)
|
||||
{
|
||||
#if (CONFIG_SPIRAM_USE_MALLOC && CONFIG_BT_ALLOCATION_FROM_SPIRAM_FIRST)
|
||||
|
||||
btc_queue_buffer = heap_caps_malloc(sizeof(StaticQueue_t), MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||
if (!btc_queue_buffer) {
|
||||
BTC_TRACE_ERROR("Btc Queue malloc fail in PSRAM.\n");
|
||||
return BT_STATUS_NOMEM;
|
||||
}
|
||||
|
||||
btc_queue_storage = heap_caps_malloc((BTC_TASK_QUEUE_LEN*sizeof(btc_msg_t)), MALLOC_CAP_SPIRAM|MALLOC_CAP_8BIT);
|
||||
if (!btc_queue_storage ) {
|
||||
BTC_TRACE_ERROR("Btc Queue malloc fail in PSRAM.\n");
|
||||
return BT_STATUS_NOMEM;
|
||||
}
|
||||
|
||||
xBtcQueue = xQueueCreateStatic(BTC_TASK_QUEUE_LEN, sizeof(btc_msg_t), btc_queue_storage, btc_queue_buffer);
|
||||
BTC_TRACE_API("Btc Queue malloc in PSRAM Success.\n");
|
||||
#else
|
||||
BTC_TRACE_API("xBtcQueue in internal RAM.");
|
||||
xBtcQueue = xQueueCreate(BTC_TASK_QUEUE_LEN, sizeof(btc_msg_t));
|
||||
#endif
|
||||
xTaskCreatePinnedToCore(btc_task, "Btc_task", BTC_TASK_STACK_SIZE, NULL, BTC_TASK_PRIO, &xBtcTaskHandle, BTC_TASK_PINNED_TO_CORE);
|
||||
if (xBtcTaskHandle == NULL || xBtcQueue == 0){
|
||||
return BT_STATUS_NOMEM;
|
||||
@ -209,6 +232,17 @@ void btc_deinit(void)
|
||||
#if SCAN_QUEUE_CONGEST_CHECK
|
||||
btc_adv_list_deinit();
|
||||
#endif
|
||||
|
||||
#if (CONFIG_SPIRAM_USE_MALLOC && CONFIG_BT_ALLOCATION_FROM_SPIRAM_FIRST)
|
||||
if(btc_queue_buffer){
|
||||
heap_caps_free(btc_queue_buffer);
|
||||
btc_queue_buffer = NULL;
|
||||
}
|
||||
if(btc_queue_storage){
|
||||
heap_caps_free(btc_queue_storage);
|
||||
btc_queue_storage = NULL;
|
||||
}
|
||||
#endif
|
||||
xBtcTaskHandle = NULL;
|
||||
xBtcQueue = 0;
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ typedef enum {
|
||||
#define HCI_HOST_TASK_STACK_SIZE (2048 + BT_TASK_EXTRA_STACK_SIZE)
|
||||
#define HCI_HOST_TASK_PRIO (configMAX_PRIORITIES - 3)
|
||||
#define HCI_HOST_TASK_NAME "hciHostT"
|
||||
#define HCI_HOST_QUEUE_LEN 40
|
||||
#define HCI_HOST_QUEUE_LEN 190//40
|
||||
|
||||
#define HCI_H4_TASK_PINNED_TO_CORE (TASK_PINNED_TO_CORE)
|
||||
#define HCI_H4_TASK_STACK_SIZE (2048 + BT_TASK_EXTRA_STACK_SIZE)
|
||||
@ -75,13 +75,13 @@ typedef enum {
|
||||
#define BTU_TASK_STACK_SIZE (CONFIG_BTU_TASK_STACK_SIZE + BT_TASK_EXTRA_STACK_SIZE)
|
||||
#define BTU_TASK_PRIO (configMAX_PRIORITIES - 5)
|
||||
#define BTU_TASK_NAME "btuT"
|
||||
#define BTU_QUEUE_LEN 200
|
||||
#define BTU_QUEUE_LEN 200//50
|
||||
|
||||
#define BTC_TASK_PINNED_TO_CORE (TASK_PINNED_TO_CORE)
|
||||
#define BTC_TASK_STACK_SIZE (CONFIG_BTC_TASK_STACK_SIZE + BT_TASK_EXTRA_STACK_SIZE) //by menuconfig
|
||||
#define BTC_TASK_NAME "btcT"
|
||||
#define BTC_TASK_PRIO (configMAX_PRIORITIES - 6)
|
||||
#define BTC_TASK_QUEUE_LEN 60
|
||||
#define BTC_TASK_QUEUE_LEN 300//60
|
||||
|
||||
#define BTC_A2DP_SINK_TASK_PINNED_TO_CORE (TASK_PINNED_TO_CORE)
|
||||
#define BTC_A2DP_SINK_TASK_STACK_SIZE (CONFIG_A2DP_SINK_TASK_STACK_SIZE + BT_TASK_EXTRA_STACK_SIZE) // by menuconfig
|
||||
|
@ -146,6 +146,10 @@ void btu_free_core(void)
|
||||
** Returns void
|
||||
**
|
||||
******************************************************************************/
|
||||
#if (CONFIG_SPIRAM_USE_MALLOC && CONFIG_BT_ALLOCATION_FROM_SPIRAM_FIRST)
|
||||
StaticQueue_t *btu_queue_buffer = NULL;
|
||||
uint8_t *btu_queue_storage = NULL;
|
||||
#endif
|
||||
void BTU_StartUp(void)
|
||||
{
|
||||
#if BTU_DYNAMIC_MEMORY
|
||||
@ -178,14 +182,33 @@ void BTU_StartUp(void)
|
||||
|
||||
osi_mutex_new(&btu_l2cap_alarm_lock);
|
||||
|
||||
#if (CONFIG_SPIRAM_USE_MALLOC && CONFIG_BT_ALLOCATION_FROM_SPIRAM_FIRST)
|
||||
btu_queue_buffer = heap_caps_malloc(sizeof(StaticQueue_t), MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||
if (!btu_queue_buffer) {
|
||||
BTC_TRACE_ERROR("Btu Queue malloc fail in PSRAM.\n");
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
btu_queue_storage = heap_caps_malloc((BTU_QUEUE_LEN*sizeof(BtTaskEvt_t)), MALLOC_CAP_SPIRAM|MALLOC_CAP_8BIT);
|
||||
if (!btu_queue_storage ) {
|
||||
BTC_TRACE_ERROR("Btu Queue malloc fail in PSRAM.\n");
|
||||
goto error_exit;
|
||||
}
|
||||
|
||||
xBtuQueue = xQueueCreateStatic(BTU_QUEUE_LEN, sizeof(BtTaskEvt_t), btu_queue_storage, btu_queue_buffer);
|
||||
BTC_TRACE_API("Btu Queue malloc in PSRAM Success.\n");
|
||||
#else
|
||||
BTC_TRACE_API("xBtuQueue in internal RAM.");
|
||||
xBtuQueue = xQueueCreate(BTU_QUEUE_LEN, sizeof(BtTaskEvt_t));
|
||||
#endif
|
||||
|
||||
xTaskCreatePinnedToCore(btu_task_thread_handler, BTU_TASK_NAME, BTU_TASK_STACK_SIZE, NULL, BTU_TASK_PRIO, &xBtuTaskHandle, BTU_TASK_PINNED_TO_CORE);
|
||||
|
||||
btu_task_post(SIG_BTU_START_UP, NULL, TASK_POST_BLOCKING);
|
||||
|
||||
return;
|
||||
|
||||
error_exit:;
|
||||
error_exit:
|
||||
LOG_ERROR("%s Unable to allocate resources for bt_workqueue", __func__);
|
||||
BTU_ShutDown();
|
||||
}
|
||||
@ -209,6 +232,17 @@ void BTU_ShutDown(void)
|
||||
vTaskDelete(xBtuTaskHandle);
|
||||
vQueueDelete(xBtuQueue);
|
||||
|
||||
#if (CONFIG_SPIRAM_USE_MALLOC && CONFIG_BT_ALLOCATION_FROM_SPIRAM_FIRST)
|
||||
if(btu_queue_buffer){
|
||||
heap_caps_free(btu_queue_buffer);
|
||||
btu_queue_buffer = NULL;
|
||||
}
|
||||
if(btu_queue_storage){
|
||||
heap_caps_free(btu_queue_storage);
|
||||
btu_queue_storage = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
btu_general_alarm_hash_map = NULL;
|
||||
|
||||
btu_oneshot_alarm_hash_map = NULL;
|
||||
|
Reference in New Issue
Block a user