feat(bt/bluedroid): Add print and assert when failed to alloc memory

This commit is contained in:
chenjianhua
2024-06-20 12:22:37 +08:00
parent df432b8508
commit f8ad2871e6
8 changed files with 63 additions and 59 deletions

View File

@@ -1204,3 +1204,10 @@ config BT_BLE_HIGH_DUTY_ADV_INTERVAL
default n
help
This enable BLE high duty advertising interval feature
config BT_ABORT_WHEN_ALLOCATION_FAILS
bool "Abort when memory allocation fails in BT/BLE stack"
depends on BT_BLUEDROID_ENABLED
default n
help
This enables abort when memory allocation fails

View File

@@ -379,20 +379,6 @@
* Memory reference
**********************************************************/
//MEMORY ALLOCATOR
#ifdef CONFIG_BT_ALLOCATION_FROM_SPIRAM_FIRST
#define UC_HEAP_ALLOCATION_FROM_SPIRAM_FIRST CONFIG_BT_ALLOCATION_FROM_SPIRAM_FIRST
#else
#define UC_HEAP_ALLOCATION_FROM_SPIRAM_FIRST FALSE
#endif
//MEMORY DEBUG
#ifdef CONFIG_BT_BLUEDROID_MEM_DEBUG
#define UC_BT_BLUEDROID_MEM_DEBUG CONFIG_BT_BLUEDROID_MEM_DEBUG
#else
#define UC_BT_BLUEDROID_MEM_DEBUG FALSE
#endif
/**********************************************************
* Trace reference

View File

@@ -2378,12 +2378,6 @@ The maximum number of payload octets that the local device can receive in a sing
#define BTSNOOP_MEM FALSE
#endif
#if UC_HEAP_ALLOCATION_FROM_SPIRAM_FIRST
#define HEAP_ALLOCATION_FROM_SPIRAM_FIRST TRUE
#else
#define HEAP_ALLOCATION_FROM_SPIRAM_FIRST FALSE
#endif
#include "common/bt_trace.h"
#endif /* BT_TARGET_H */

View File

@@ -592,7 +592,7 @@ static int host_recv_pkt_cb(uint8_t *data, uint16_t len)
}
#endif
pkt_size = BT_PKT_LINKED_HDR_SIZE + BT_HDR_SIZE + len;
linked_pkt = (pkt_linked_item_t *) osi_calloc(pkt_size);
linked_pkt = (pkt_linked_item_t *) osi_calloc_base(pkt_size);
if (!linked_pkt) {
#if (BLE_ADV_REPORT_FLOW_CONTROL == TRUE)
hci_adv_credits_consumed(1);