From 5893323abc4fc5e9a93a27ac055e36aebed5b595 Mon Sep 17 00:00:00 2001 From: Zhou Xiao Date: Wed, 9 Jul 2025 13:13:59 +0800 Subject: [PATCH] feat(ble): support memory allocation check debug feature on ESP32-H2 (cherry picked from commit 265a8746dce7a1acb427c6f0a017a918dbbb1bef) Co-authored-by: cjin --- components/bt/controller/esp32h2/Kconfig.in | 6 ++++++ components/bt/controller/esp32h2/bt.c | 7 +++++++ components/bt/include/esp32h2/include/esp_bt.h | 4 ++++ 3 files changed, 17 insertions(+) diff --git a/components/bt/controller/esp32h2/Kconfig.in b/components/bt/controller/esp32h2/Kconfig.in index 2f914a1075..5ff989a8b4 100644 --- a/components/bt/controller/esp32h2/Kconfig.in +++ b/components/bt/controller/esp32h2/Kconfig.in @@ -441,6 +441,12 @@ menu "Controller debug features" config BT_LE_PTR_CHECK_ENABLED bool "Enable boundary check for internal memory" default n + + config BT_LE_MEM_CHECK_ENABLED + bool "Enable memory allocation check" + default n + help + Used in internal tests only. Enable the memory allocation check. endmenu config BT_LE_LL_RESOLV_LIST_SIZE diff --git a/components/bt/controller/esp32h2/bt.c b/components/bt/controller/esp32h2/bt.c index c04e881cc6..4e05ff91cd 100644 --- a/components/bt/controller/esp32h2/bt.c +++ b/components/bt/controller/esp32h2/bt.c @@ -1693,3 +1693,10 @@ ble_capture_info_user_handler(uint8_t type, uint32_t reason, uint32_t param1, ui } return 0; } + +#if CONFIG_BT_LE_MEM_CHECK_ENABLED +void ble_memory_count_limit_set(uint16_t count_limit) +{ + bt_osi_mem_count_limit_set(count_limit); +} +#endif // CONFIG_BT_LE_MEM_CHECK_ENABLED diff --git a/components/bt/include/esp32h2/include/esp_bt.h b/components/bt/include/esp32h2/include/esp_bt.h index b33f8b7359..601f5816a3 100644 --- a/components/bt/include/esp32h2/include/esp_bt.h +++ b/components/bt/include/esp32h2/include/esp_bt.h @@ -462,6 +462,10 @@ uint32_t esp_bt_get_lpclk_freq(void); void esp_bt_set_lpclk_freq(uint32_t clk_freq); +#if CONFIG_BT_LE_MEM_CHECK_ENABLED +void ble_memory_count_limit_set(uint16_t count_limit); +#endif // CONFIG_BT_LE_MEM_CHECK_ENABLED + #ifdef __cplusplus } #endif