diff --git a/components/bt/ble_profiles/common/Kconfig.in b/components/bt/ble_profiles/common/Kconfig.in index eae3f0eb7a3..ab5402a943c 100644 --- a/components/bt/ble_profiles/common/Kconfig.in +++ b/components/bt/ble_profiles/common/Kconfig.in @@ -1,6 +1,7 @@ config BT_PRF_TASK_ENABLED bool "Enable the shared BLE profile task (event queue worker)" depends on BT_ENABLED + select BT_OSAL_ENABLED default n help Build the shared BLE profile task: a single process-wide event queue diff --git a/components/bt/common/CMakeLists.txt b/components/bt/common/CMakeLists.txt index 4bbf49754ea..718ca75f7e5 100644 --- a/components/bt/common/CMakeLists.txt +++ b/components/bt/common/CMakeLists.txt @@ -114,9 +114,14 @@ list(APPEND bt_common_srcs "${CMAKE_CURRENT_LIST_DIR}/osi/osi.c" "${CMAKE_CURRENT_LIST_DIR}/osi/semaphore.c" "${CMAKE_CURRENT_LIST_DIR}/ble_log/deprecated/ble_log_spi_out.c" - "${CMAKE_CURRENT_LIST_DIR}/osal/src/bt_osal_freertos.c" ) +if(CONFIG_BT_OSAL_ENABLED) + list(APPEND bt_common_srcs + "${CMAKE_CURRENT_LIST_DIR}/osal/src/bt_osal_freertos.c" + ) +endif() + list(APPEND bt_common_include_dirs "${CMAKE_CURRENT_LIST_DIR}/osi/include" "${CMAKE_CURRENT_LIST_DIR}/api/include/api" diff --git a/components/bt/common/Kconfig.in b/components/bt/common/Kconfig.in index 1ef7bf43dfe..4dba2732d5b 100644 --- a/components/bt/common/Kconfig.in +++ b/components/bt/common/Kconfig.in @@ -24,8 +24,22 @@ config BT_BLE_HOST_ALLOW_SUB_SPEC_MIN_CONN_INT menu "OSAL (OS abstraction layer)" depends on BT_ENABLED + config BT_OSAL_ENABLED + bool "Enable the Bluetooth OS abstraction layer" + default n + help + Build the Bluetooth OS abstraction layer (bt_osal): a host-agnostic + wrapper over the OS primitives the Bluetooth stack and the BLE + profiles rely on — event queues, mutexes, semaphores, callouts + (one-shot timers), time conversion and critical sections. + + Disable to leave the OSAL sources out of the build when nothing + uses them. A component that relies on the OSAL should + "select BT_OSAL_ENABLED" in its own Kconfig. + config BT_OSAL_USE_ESP_TIMER bool "Use esp_timer to implement the OSAL callout" + depends on BT_OSAL_ENABLED default y help Use esp_timer instead of the FreeRTOS software timer to implement the OSAL diff --git a/components/bt/common/osal/include/bt_osal_freertos.h b/components/bt/common/osal/include/bt_osal_freertos.h index f10503a46b3..b1578093fe5 100644 --- a/components/bt/common/osal/include/bt_osal_freertos.h +++ b/components/bt/common/osal/include/bt_osal_freertos.h @@ -128,6 +128,7 @@ uint32_t bt_osal_freertos_hw_enter_critical(void); void bt_osal_freertos_hw_exit_critical(uint32_t ctx); +#if CONFIG_BT_OSAL_ENABLED /** * @brief Allocate and populate the OSAL function table * @@ -140,6 +141,15 @@ void bt_osal_freertos_funcs_init(void); * @brief Free the OSAL function table allocated by bt_osal_freertos_funcs_init() */ void bt_osal_freertos_funcs_deinit(void); +#else +/* The OSAL implementation is not built. The hosts bring the function table up + * and down unconditionally during their init/deinit, so keep those two entry + * points available as no-ops instead of making every caller guard them. */ + +static inline void bt_osal_freertos_funcs_init(void) {} + +static inline void bt_osal_freertos_funcs_deinit(void) {} +#endif /* CONFIG_BT_OSAL_ENABLED */ /** * @brief Get the OSAL function table diff --git a/components/bt/test_apps/basic_unit_test/sdkconfig.defaults b/components/bt/test_apps/basic_unit_test/sdkconfig.defaults index f379cce0614..1c04b2207ea 100644 --- a/components/bt/test_apps/basic_unit_test/sdkconfig.defaults +++ b/components/bt/test_apps/basic_unit_test/sdkconfig.defaults @@ -1,3 +1,4 @@ CONFIG_BT_ENABLED=y +CONFIG_BT_OSAL_ENABLED=y CONFIG_BT_PRF_TASK_ENABLED=y CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0=n