mirror of
https://github.com/espressif/esp-idf.git
synced 2026-10-02 11:10:54 +03:00
Merge branch 'bugfix/nimble_issues_17072026_v5.5' into 'release/v5.5'
fix(nimble): Fix few nimble issues 17072026 (v5.5) See merge request espressif/esp-idf!50922
This commit is contained in:
@@ -349,6 +349,16 @@ menu "GAP"
|
||||
Enable this option to send number-of-completed-packets event to
|
||||
controller after disconnection
|
||||
|
||||
config BT_NIMBLE_DEFER_CONN_EVENTS_UNTIL_CONNECT
|
||||
bool "Defer connection GAP/ATT events until CONNECT callback"
|
||||
depends on BT_NIMBLE_ENABLED
|
||||
default y
|
||||
help
|
||||
Queue connection-related GAP callbacks and ATT server requests until
|
||||
BLE_GAP_EVENT_CONNECT event is delivered for that connection handle.
|
||||
Required when the host delays CONNECT so applications never receive other
|
||||
events before CONNECT event.
|
||||
|
||||
endmenu #GAP
|
||||
|
||||
menu "GATT / ATT"
|
||||
@@ -992,6 +1002,20 @@ menu "Services"
|
||||
help
|
||||
Enable the DIS PnP ID characteristic
|
||||
|
||||
config BT_NIMBLE_SVC_DIS_IEEE
|
||||
depends on BT_NIMBLE_DIS_SERVICE
|
||||
bool "IEEE"
|
||||
default y
|
||||
help
|
||||
Enable the DIS IEEE characteristic
|
||||
|
||||
config BT_NIMBLE_SVC_DIS_UDI
|
||||
depends on BT_NIMBLE_DIS_SERVICE
|
||||
bool "UDI"
|
||||
default y
|
||||
help
|
||||
Enable the DIS UDI characteristic
|
||||
|
||||
config BT_NIMBLE_SVC_DIS_INCLUDED
|
||||
depends on BT_NIMBLE_DIS_SERVICE
|
||||
bool "DIS as an Included Service"
|
||||
|
||||
@@ -182,7 +182,6 @@ static void ble_hci_rx_acl(uint8_t *data, uint16_t len)
|
||||
{
|
||||
struct os_mbuf *m = NULL;
|
||||
int rc;
|
||||
int sr;
|
||||
|
||||
int retry_count = 1;
|
||||
|
||||
@@ -216,9 +215,7 @@ static void ble_hci_rx_acl(uint8_t *data, uint16_t len)
|
||||
os_mbuf_free_chain(m);
|
||||
return;
|
||||
}
|
||||
OS_ENTER_CRITICAL(sr);
|
||||
ble_transport_to_hs_acl(m);
|
||||
OS_EXIT_CRITICAL(sr);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Submodule components/bt/host/nimble/nimble updated: 685675c012...3cacd66e83
@@ -1842,6 +1842,18 @@
|
||||
#define MYNEWT_VAL_BLE_SVC_DIS_PNP_ID_READ_PERM (-1)
|
||||
#endif
|
||||
|
||||
#if CONFIG_BT_NIMBLE_SVC_DIS_IEEE
|
||||
#define MYNEWT_VAL_BLE_SVC_DIS_IEEE_READ_PERM (0)
|
||||
#else
|
||||
#define MYNEWT_VAL_BLE_SVC_DIS_IEEE_READ_PERM (-1)
|
||||
#endif
|
||||
|
||||
#if CONFIG_BT_NIMBLE_SVC_DIS_UDI
|
||||
#define MYNEWT_VAL_BLE_SVC_DIS_UDI_READ_PERM (0)
|
||||
#else
|
||||
#define MYNEWT_VAL_BLE_SVC_DIS_UDI_READ_PERM (-1)
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_SVC_DIS_INCLUDED
|
||||
#define MYNEWT_VAL_BLE_SVC_DIS_INCLUDED (CONFIG_BT_NIMBLE_SVC_DIS_INCLUDED)
|
||||
#endif
|
||||
@@ -2390,4 +2402,13 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef MYNEWT_VAL_BLE_DEFER_CONN_EVENTS
|
||||
#ifdef CONFIG_BT_NIMBLE_DEFER_CONN_EVENTS_UNTIL_CONNECT
|
||||
#define MYNEWT_VAL_BLE_DEFER_CONN_EVENTS CONFIG_BT_NIMBLE_DEFER_CONN_EVENTS_UNTIL_CONNECT
|
||||
#else
|
||||
#define MYNEWT_VAL_BLE_DEFER_CONN_EVENTS (0)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
@@ -17,6 +17,8 @@ void *nimble_mem_malloc(size_t size);
|
||||
|
||||
void *nimble_mem_calloc(size_t n, size_t size);
|
||||
|
||||
void *nimble_mem_realloc(void *ptr, size_t size);
|
||||
|
||||
void nimble_mem_free(void *ptr);
|
||||
|
||||
#if CONFIG_BT_LE_USED_MEM_STATISTICS_ENABLED
|
||||
@@ -89,17 +91,6 @@ void nimble_mem_dbg_set_section_end(uint8_t index);
|
||||
*/
|
||||
uint32_t nimble_mem_dbg_get_max_size_section(uint8_t index);
|
||||
|
||||
/**
|
||||
* @brief Reallocate memory with debug tracking
|
||||
*
|
||||
* @param ptr Pointer to memory to reallocate
|
||||
* @param new_size New size of allocation
|
||||
* @param func Function name where realloc occurred
|
||||
* @param line Line number where realloc occurred
|
||||
* @return Pointer to reallocated memory
|
||||
*/
|
||||
void *nimble_mem_dbg_realloc(void *ptr, size_t new_size, const char *func, int line);
|
||||
|
||||
#endif // CONFIG_BT_NIMBLE_MEM_DEBUG
|
||||
|
||||
|
||||
@@ -127,11 +118,17 @@ void *nimble_mem_dbg_realloc(void *ptr, size_t new_size, const char *func, int l
|
||||
|
||||
#define nimble_platform_mem_realloc(ptr, new_size) \
|
||||
({ \
|
||||
void *p; \
|
||||
do { \
|
||||
p = nimble_mem_dbg_realloc(ptr, new_size, __func__, __LINE__); \
|
||||
} while (0); \
|
||||
p; \
|
||||
void *_old = (void *)(ptr); \
|
||||
size_t _nsz = (size_t)(new_size); \
|
||||
void *_new = nimble_mem_realloc(_old, _nsz); \
|
||||
if (_new == NULL && _nsz > 0) { \
|
||||
/* realloc failed: original block still alive, keep its debug record */ \
|
||||
} else { \
|
||||
/* success or free (new_size==0): clean old, record new */ \
|
||||
if (_old) nimble_mem_dbg_clean(_old, __func__, __LINE__); \
|
||||
if (_new) nimble_mem_dbg_record(_new, _nsz, __func__, __LINE__); \
|
||||
} \
|
||||
_new; \
|
||||
})
|
||||
|
||||
#define nimble_platform_mem_free(ptr) \
|
||||
@@ -145,7 +142,7 @@ do { \
|
||||
|
||||
#define nimble_platform_mem_malloc nimble_mem_malloc
|
||||
#define nimble_platform_mem_calloc nimble_mem_calloc
|
||||
#define nimble_platform_mem_realloc realloc
|
||||
#define nimble_platform_mem_realloc nimble_mem_realloc
|
||||
#define nimble_platform_mem_free nimble_mem_free
|
||||
|
||||
#endif // CONFIG_BT_NIMBLE_MEM_DEBUG
|
||||
|
||||
@@ -79,6 +79,7 @@ void nimble_mem_dbg_record(void *p, int size, const char *func, int line)
|
||||
|
||||
if (i >= NIMBLE_MEM_DBG_INFO_MAX) {
|
||||
ESP_LOGE("BT_NIMBLE_MEM", "%s full %s %d !!\n", __func__, func, line);
|
||||
return;
|
||||
}
|
||||
|
||||
nimble_mem_dbg_current_size += size;
|
||||
@@ -190,66 +191,6 @@ uint32_t nimble_mem_dbg_get_max_size_section(uint8_t index)
|
||||
return nimble_mem_dbg_max_size_section[index].max_size;
|
||||
}
|
||||
|
||||
void *nimble_mem_dbg_realloc(void *ptr, size_t new_size, const char *func, int line)
|
||||
{
|
||||
size_t old_size = 0;
|
||||
int i;
|
||||
|
||||
void *new_ptr = realloc(ptr, new_size);
|
||||
if (new_ptr == NULL && new_size > 0) {
|
||||
// realloc failed, keep old ptr record
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// Find and clean old record if ptr is not NULL
|
||||
if (ptr != NULL) {
|
||||
for (i = 0; i < NIMBLE_MEM_DBG_INFO_MAX; i++) {
|
||||
if (nimble_mem_dbg_info[i].p == ptr) {
|
||||
old_size = nimble_mem_dbg_info[i].size;
|
||||
nimble_mem_dbg_current_size -= old_size;
|
||||
|
||||
nimble_mem_dbg_info[i].p = NULL;
|
||||
nimble_mem_dbg_info[i].size = 0;
|
||||
nimble_mem_dbg_info[i].func = NULL;
|
||||
nimble_mem_dbg_info[i].line = 0;
|
||||
nimble_mem_dbg_count--;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Record the new allocation if new_size > 0
|
||||
if (new_ptr != NULL && new_size > 0) {
|
||||
for (i = 0; i < NIMBLE_MEM_DBG_INFO_MAX; i++) {
|
||||
if (nimble_mem_dbg_info[i].p == NULL) {
|
||||
nimble_mem_dbg_info[i].p = new_ptr;
|
||||
nimble_mem_dbg_info[i].size = new_size;
|
||||
nimble_mem_dbg_info[i].func = func;
|
||||
nimble_mem_dbg_info[i].line = line;
|
||||
nimble_mem_dbg_count++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (i >= NIMBLE_MEM_DBG_INFO_MAX) {
|
||||
ESP_LOGE("BT_NIMBLE_MEM", "%s full %s %d !!\n", __func__, func, line);
|
||||
}
|
||||
|
||||
nimble_mem_dbg_current_size += new_size;
|
||||
if (nimble_mem_dbg_max_size < nimble_mem_dbg_current_size) {
|
||||
nimble_mem_dbg_max_size = nimble_mem_dbg_current_size;
|
||||
}
|
||||
|
||||
for (i = 0; i < NIMBLE_MEM_DBG_MAX_SECTION_NUM; i++) {
|
||||
if (nimble_mem_dbg_max_size_section[i].used &&
|
||||
nimble_mem_dbg_max_size_section[i].max_size < nimble_mem_dbg_current_size) {
|
||||
nimble_mem_dbg_max_size_section[i].max_size = nimble_mem_dbg_current_size;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return new_ptr;
|
||||
}
|
||||
#endif // CONFIG_BT_NIMBLE_MEM_DEBUG
|
||||
|
||||
#if !CONFIG_BT_NIMBLE_LOW_SPEED_MODE
|
||||
@@ -306,6 +247,44 @@ void *nimble_mem_calloc(size_t n, size_t size)
|
||||
return mem;
|
||||
}
|
||||
|
||||
#if !CONFIG_BT_NIMBLE_LOW_SPEED_MODE
|
||||
IRAM_ATTR
|
||||
#endif
|
||||
void *nimble_mem_realloc(void *ptr, size_t size)
|
||||
{
|
||||
void *mem = NULL;
|
||||
#if CONFIG_BT_LE_USED_MEM_STATISTICS_ENABLED
|
||||
size_t old_size = 0;
|
||||
if (ptr) {
|
||||
old_size = heap_caps_get_allocated_size(ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_INTERNAL
|
||||
mem = heap_caps_realloc(ptr, size, MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||
#elif CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_EXTERNAL
|
||||
mem = heap_caps_realloc(ptr, size, MALLOC_CAP_SPIRAM|MALLOC_CAP_8BIT);
|
||||
#elif CONFIG_BT_NIMBLE_MEM_ALLOC_MODE_IRAM_8BIT
|
||||
mem = heap_caps_realloc_prefer(ptr, size, 2,
|
||||
MALLOC_CAP_INTERNAL|MALLOC_CAP_IRAM_8BIT,
|
||||
MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT);
|
||||
#else
|
||||
mem = realloc(ptr, size);
|
||||
#endif
|
||||
|
||||
#if CONFIG_BT_LE_USED_MEM_STATISTICS_ENABLED
|
||||
if (mem) {
|
||||
size_t new_size = heap_caps_get_allocated_size(mem);
|
||||
host_mem_used_size = host_mem_used_size - old_size + new_size;
|
||||
} else if (ptr && size == 0) {
|
||||
host_mem_used_size -= old_size;
|
||||
}
|
||||
#endif // CONFIG_BT_LE_USED_MEM_STATISTICS_ENABLED
|
||||
|
||||
return mem;
|
||||
}
|
||||
|
||||
|
||||
#if !CONFIG_BT_NIMBLE_LOW_SPEED_MODE
|
||||
IRAM_ATTR
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user