From 1145aec2b86d7ee08060caad86f72bd370f19e69 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Sun, 23 Mar 2025 13:31:40 +0100 Subject: [PATCH 1/3] Fix error: simple_ble_start enable controller failed 259 --- cores/esp32/esp32-hal-misc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cores/esp32/esp32-hal-misc.c b/cores/esp32/esp32-hal-misc.c index 50e2973d27a..1ca7f279580 100644 --- a/cores/esp32/esp32-hal-misc.c +++ b/cores/esp32/esp32-hal-misc.c @@ -305,11 +305,11 @@ void initArduino() { if (err) { log_e("Failed to initialize NVS! Error: %u", err); } -#if defined(CONFIG_BT_ENABLED) && SOC_BT_SUPPORTED - if (!btInUse()) { - esp_bt_controller_mem_release(ESP_BT_MODE_BTDM); - } -#endif +//#if defined(CONFIG_BT_ENABLED) && SOC_BT_SUPPORTED +// if (!btInUse()) { +// esp_bt_controller_mem_release(ESP_BT_MODE_BTDM); +// } +//#endif init(); initVariant(); } From a35bf59557992a79aebfd8eeeaab0577f95b7956 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 26 Mar 2025 17:21:37 +0100 Subject: [PATCH 2/3] reemove duplicate `btInUse` define --- cores/esp32/esp32-hal-bt.c | 11 ----------- cores/esp32/esp32-hal-misc.c | 10 +++++----- 2 files changed, 5 insertions(+), 16 deletions(-) diff --git a/cores/esp32/esp32-hal-bt.c b/cores/esp32/esp32-hal-bt.c index 5f1148bd492..43c9fbe98f7 100644 --- a/cores/esp32/esp32-hal-bt.c +++ b/cores/esp32/esp32-hal-bt.c @@ -17,17 +17,6 @@ #if SOC_BT_SUPPORTED #ifdef CONFIG_BT_ENABLED -#if CONFIG_IDF_TARGET_ESP32 -bool btInUse() { - return true; -} -#else -// user may want to change it to free resources -__attribute__((weak)) bool btInUse() { - return true; -} -#endif - #include "esp_bt.h" #ifdef CONFIG_BTDM_CONTROLLER_MODE_BTDM diff --git a/cores/esp32/esp32-hal-misc.c b/cores/esp32/esp32-hal-misc.c index 1ca7f279580..50e2973d27a 100644 --- a/cores/esp32/esp32-hal-misc.c +++ b/cores/esp32/esp32-hal-misc.c @@ -305,11 +305,11 @@ void initArduino() { if (err) { log_e("Failed to initialize NVS! Error: %u", err); } -//#if defined(CONFIG_BT_ENABLED) && SOC_BT_SUPPORTED -// if (!btInUse()) { -// esp_bt_controller_mem_release(ESP_BT_MODE_BTDM); -// } -//#endif +#if defined(CONFIG_BT_ENABLED) && SOC_BT_SUPPORTED + if (!btInUse()) { + esp_bt_controller_mem_release(ESP_BT_MODE_BTDM); + } +#endif init(); initVariant(); } From 46fafa2f341d09b8ecf52d4719af3386c7acfd65 Mon Sep 17 00:00:00 2001 From: Jason2866 <24528715+Jason2866@users.noreply.github.com> Date: Wed, 26 Mar 2025 17:51:19 +0100 Subject: [PATCH 3/3] fix BT mem release logic --- cores/esp32/esp32-hal-misc.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/cores/esp32/esp32-hal-misc.c b/cores/esp32/esp32-hal-misc.c index 50e2973d27a..477ee7421b5 100644 --- a/cores/esp32/esp32-hal-misc.c +++ b/cores/esp32/esp32-hal-misc.c @@ -27,6 +27,15 @@ #include "esp_private/startup_internal.h" #if defined(CONFIG_BT_ENABLED) && SOC_BT_SUPPORTED #include "esp_bt.h" +#if CONFIG_IDF_TARGET_ESP32 +bool btInUse() { + return true; +} +#else +bool btInUse() { + return false; +} +#endif #endif //CONFIG_BT_ENABLED #include #include "soc/rtc.h" @@ -243,19 +252,6 @@ bool verifyRollbackLater() { } #endif -#ifdef CONFIG_BT_ENABLED -#if CONFIG_IDF_TARGET_ESP32 -//overwritten in esp32-hal-bt.c -bool btInUse() __attribute__((weak)); -bool btInUse() { - return false; -} -#else -//from esp32-hal-bt.c -extern bool btInUse(); -#endif -#endif - #if CONFIG_SPIRAM_SUPPORT || CONFIG_SPIRAM ESP_SYSTEM_INIT_FN(init_psram_new, CORE, BIT(0), 99) { psramInit();