This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit c188f3c93420dab25c602ae73aef6c15f344b645
Author: Eren Terzioglu <[email protected]>
AuthorDate: Mon May 25 12:01:17 2026 +0200

    arch/risc-v/espressif: Add BLE support for esp32[-c6|-h2]
    
    Add BLE support for esp32c6 and esp32h2
    
    Signed-off-by: Eren Terzioglu <[email protected]>
---
 arch/risc-v/src/common/espressif/CMakeLists.txt |   8 +-
 arch/risc-v/src/common/espressif/Kconfig        |   2 +-
 arch/risc-v/src/common/espressif/Make.defs      |   8 +-
 arch/risc-v/src/common/espressif/Wireless.cmake |  80 +++++-
 arch/risc-v/src/common/espressif/Wireless.mk    |  55 +++-
 arch/risc-v/src/esp32c6/CMakeLists.txt          |   5 +
 arch/risc-v/src/esp32c6/Make.defs               |   5 +
 arch/risc-v/src/esp32c6/esp_ble.c               | 333 ++++++++++++++++++++++++
 arch/risc-v/src/esp32c6/esp_ble.h               |  52 ++++
 arch/risc-v/src/esp32h2/CMakeLists.txt          |   5 +
 arch/risc-v/src/esp32h2/Make.defs               |   5 +
 arch/risc-v/src/esp32h2/esp_ble.c               | 333 ++++++++++++++++++++++++
 arch/risc-v/src/esp32h2/esp_ble.h               |  52 ++++
 13 files changed, 931 insertions(+), 12 deletions(-)

diff --git a/arch/risc-v/src/common/espressif/CMakeLists.txt 
b/arch/risc-v/src/common/espressif/CMakeLists.txt
index 470bbfe5254..7a347b2ea13 100644
--- a/arch/risc-v/src/common/espressif/CMakeLists.txt
+++ b/arch/risc-v/src/common/espressif/CMakeLists.txt
@@ -157,7 +157,9 @@ if(CONFIG_ESPRESSIF_WIRELESS)
     list(APPEND SRCS esp_wifi_api.c)
     list(APPEND SRCS esp_wlan_netdev.c)
   endif()
-  list(APPEND SRCS esp_wifi_utils.c)
+  if(NOT CONFIG_ARCH_CHIP_ESP32H2)
+    list(APPEND SRCS esp_wifi_utils.c)
+  endif()
 endif()
 
 if(CONFIG_ESP_MCPWM)
@@ -221,7 +223,7 @@ if(DEFINED ENV{ESP_HAL_3RDPARTY_VERSION})
       CACHE STRING "ESP HAL 3rdparty version")
 else()
   set(ESP_HAL_3RDPARTY_VERSION
-      e8d8638febf5310bf5b8f9bd04cf7fab9e9a4cb0
+      0eb59f7e02a4735f2b9a78797e691b66740fcadb
       CACHE STRING "ESP HAL 3rdparty version")
 endif()
 
@@ -321,6 +323,8 @@ if(NOT IS_DIRECTORY "${ESP_HAL_3RDPARTY_REPO}")
       COMMAND
         git submodule --quiet update --init --depth=1 components/esp_phy/lib
         components/esp_wifi/lib components/bt/controller/lib_esp32c3_family
+        components/bt/controller/lib_esp32c6/esp32c6-bt-lib
+        components/bt/controller/lib_esp32h2/esp32h2-bt-lib
         components/esp_coex/lib
       WORKING_DIRECTORY ${ESP_HAL_3RDPARTY_REPO}
       RESULT_VARIABLE GIT_SUBMODULE_RESULT)
diff --git a/arch/risc-v/src/common/espressif/Kconfig 
b/arch/risc-v/src/common/espressif/Kconfig
index 4aca18ec6f0..d983b2264e4 100644
--- a/arch/risc-v/src/common/espressif/Kconfig
+++ b/arch/risc-v/src/common/espressif/Kconfig
@@ -2062,7 +2062,7 @@ config ESPRESSIF_WIFI
 
 config ESPRESSIF_BLE
        bool "BLE"
-       depends on ARCH_CHIP_ESP32C3
+       depends on !ARCH_CHIP_ESP32P4
        default n
        select ESPRESSIF_WIRELESS
        ---help---
diff --git a/arch/risc-v/src/common/espressif/Make.defs 
b/arch/risc-v/src/common/espressif/Make.defs
index 56edce08301..bb6327201f0 100644
--- a/arch/risc-v/src/common/espressif/Make.defs
+++ b/arch/risc-v/src/common/espressif/Make.defs
@@ -162,7 +162,9 @@ ifeq ($(CONFIG_ESPRESSIF_WIRELESS),y)
                CHIP_CSRCS += esp_wifi_api.c
                CHIP_CSRCS += esp_wlan_netdev.c
        endif
-       CHIP_CSRCS += esp_wifi_utils.c
+       ifneq ($(CONFIG_ARCH_CHIP_ESP32H2),y)
+               CHIP_CSRCS += esp_wifi_utils.c
+       endif
 endif
 
 ifeq ($(CONFIG_ESP_MCPWM),y)
@@ -233,7 +235,7 @@ endif
 
 ESP_HAL_3RDPARTY_REPO   = esp-hal-3rdparty
 ifndef ESP_HAL_3RDPARTY_VERSION
-       ESP_HAL_3RDPARTY_VERSION = e8d8638febf5310bf5b8f9bd04cf7fab9e9a4cb0
+       ESP_HAL_3RDPARTY_VERSION = 0eb59f7e02a4735f2b9a78797e691b66740fcadb
 endif
 
 ifndef ESP_HAL_3RDPARTY_URL
@@ -283,7 +285,7 @@ endif
 ifeq ($(CONFIG_ESPRESSIF_WIRELESS),y)
 ifneq ($(USE_NXTMPDIR_ESP_REPO_DIRECTLY),y)
        $(Q) echo "Espressif HAL for 3rd Party Platforms: initializing 
submodules..."
-       $(Q) git -C chip/$(ESP_HAL_3RDPARTY_REPO) submodule --quiet update 
--init $(GIT_DEPTH_PARAMETER) components/esp_phy/lib components/esp_wifi/lib 
components/bt/controller/lib_esp32c3_family components/esp_coex/lib
+       $(Q) git -C chip/$(ESP_HAL_3RDPARTY_REPO) submodule --quiet update 
--init $(GIT_DEPTH_PARAMETER) components/esp_phy/lib components/esp_wifi/lib 
components/bt/controller/lib_esp32c3_family 
components/bt/controller/lib_esp32c6/esp32c6-bt-lib 
components/bt/controller/lib_esp32h2/esp32h2-bt-lib components/esp_coex/lib
        $(Q) git -C chip/$(ESP_HAL_3RDPARTY_REPO)/components/mbedtls/mbedtls 
reset --quiet --hard
 endif
        $(Q) echo "Applying patches..."
diff --git a/arch/risc-v/src/common/espressif/Wireless.cmake 
b/arch/risc-v/src/common/espressif/Wireless.cmake
index 1ca12b14270..cfd6a486b65 100644
--- a/arch/risc-v/src/common/espressif/Wireless.cmake
+++ b/arch/risc-v/src/common/espressif/Wireless.cmake
@@ -40,15 +40,86 @@ target_include_directories(
 
 nuttx_add_extra_library(
   ${ESP_HAL_3RDPARTY_REPO}/components/esp_phy/lib/${CHIP_SERIES}/libphy.a
-  ${ESP_HAL_3RDPARTY_REPO}/components/esp_coex/lib/${CHIP_SERIES}/libcoexist.a
-  ${ESP_HAL_3RDPARTY_REPO}/components/esp_wifi/lib/${CHIP_SERIES}/libmesh.a)
+  ${ESP_HAL_3RDPARTY_REPO}/components/esp_coex/lib/${CHIP_SERIES}/libcoexist.a)
+
+if(NOT CONFIG_ARCH_CHIP_ESP32H2)
+  nuttx_add_extra_library(
+    ${ESP_HAL_3RDPARTY_REPO}/components/esp_wifi/lib/${CHIP_SERIES}/libmesh.a
+    
${ESP_HAL_3RDPARTY_REPO}/components/esp_wifi/lib/${CHIP_SERIES}/libespnow.a)
+endif()
+
+# 
##############################################################################
+# ESP32-C6 / ESP32-H2 BLE host and controller sources
+# 
##############################################################################
+
+if((CONFIG_ARCH_CHIP_ESP32C6 OR CONFIG_ARCH_CHIP_ESP32H2)
+   AND CONFIG_ESPRESSIF_BLE)
+  target_include_directories(
+    arch
+    PRIVATE
+      ${ESP_HAL_3RDPARTY_REPO}/components/bt/common/osi/include
+      ${ESP_HAL_3RDPARTY_REPO}/components/bt/common/tinycrypt/include
+      ${ESP_HAL_3RDPARTY_REPO}/components/bt/common/tinycrypt/port
+      
${ESP_HAL_3RDPARTY_REPO}/components/bt/host/nimble/nimble/porting/nimble/include
+      ${ESP_HAL_3RDPARTY_REPO}/components/bt/host/nimble/port/include
+      ${ESP_HAL_3RDPARTY_REPO}/components/bt/include/${CHIP_SERIES}/include
+      ${ESP_HAL_3RDPARTY_REPO}/components/bt/porting/include
+      ${ESP_HAL_3RDPARTY_REPO}/components/bt/porting/transport/include
+      ${ESP_HAL_3RDPARTY_REPO}/components/esp_common/include
+      ${ESP_HAL_3RDPARTY_REPO}/components/esp_phy/include
+      ${ESP_HAL_3RDPARTY_REPO}/components/esp_phy/${CHIP_SERIES}/include
+      ${ESP_HAL_3RDPARTY_REPO}/nuttx/src/platform/nimble/include)
+
+  set(ESP_BLE_HOST_SRCS
+      ${ESP_HAL_3RDPARTY_REPO}/components/bt/common/tinycrypt/src/ecc.c
+      ${ESP_HAL_3RDPARTY_REPO}/components/bt/common/tinycrypt/src/ecc_dh.c
+      
${ESP_HAL_3RDPARTY_REPO}/components/bt/common/tinycrypt/src/ecc_platform_specific.c
+      
${ESP_HAL_3RDPARTY_REPO}/components/bt/common/tinycrypt/port/esp_tinycrypt_port.c
+      ${ESP_HAL_3RDPARTY_REPO}/components/bt/common/tinycrypt/src/sha256.c
+      ${ESP_HAL_3RDPARTY_REPO}/components/bt/common/tinycrypt/src/utils.c
+      ${ESP_HAL_3RDPARTY_REPO}/components/bt/porting/mem/bt_osi_mem.c
+      ${ESP_HAL_3RDPARTY_REPO}/components/bt/porting/mem/os_msys_init.c
+      
${ESP_HAL_3RDPARTY_REPO}/components/bt/porting/transport/src/hci_transport.c
+      
${ESP_HAL_3RDPARTY_REPO}/components/bt/porting/transport/driver/vhci/hci_driver_standard.c
+      ${ESP_HAL_3RDPARTY_REPO}/components/bt/controller/${CHIP_SERIES}/ble.c
+      ${ESP_HAL_3RDPARTY_REPO}/components/bt/controller/${CHIP_SERIES}/bt.c
+      ${ESP_HAL_3RDPARTY_REPO}/components/esp_hal_security/ecc_hal.c
+      ${ESP_HAL_3RDPARTY_REPO}/components/esp_phy/src/btbb_init.c
+      ${ESP_HAL_3RDPARTY_REPO}/nuttx/src/platform/nimble/src/npl_os.c)
+
+  target_sources(arch PRIVATE ${ESP_BLE_HOST_SRCS})
+
+  target_compile_definitions(arch PRIVATE ESP_PLATFORM=1)
+
+  if(CONFIG_ARCH_CHIP_ESP32H2)
+    target_sources(
+      arch
+      PRIVATE
+        ${ESP_HAL_3RDPARTY_REPO}/components/esp_phy/src/lib_printf.c
+        ${ESP_HAL_3RDPARTY_REPO}/components/esp_phy/src/phy_common.c
+        ${ESP_HAL_3RDPARTY_REPO}/components/esp_phy/src/phy_init_esp32hxx.c)
+  endif()
+endif()
+
+# 
##############################################################################
+# BLE prebuilt libraries (Wireless.mk lines 30-32, 65-72; chip Make.defs)
+# 
##############################################################################
 
 if(CONFIG_ESPRESSIF_BLE)
   nuttx_add_extra_library(
     ${ESP_HAL_3RDPARTY_REPO}/components/esp_phy/lib/${CHIP_SERIES}/libbtbb.a)
+
   if(CONFIG_ARCH_CHIP_ESP32C3)
     nuttx_add_extra_library(
-      
${ESP_HAL_3RDPARTY_REPO}/components/bt/controller/lib_esp32c3_family/esp32c3/libbtdm_app.a
+      
${ESP_HAL_3RDPARTY_REPO}/components/bt/controller/lib_esp32c3_family/${CHIP_SERIES}/libbtdm_app.a
+    )
+  elseif(CONFIG_ARCH_CHIP_ESP32C6)
+    nuttx_add_extra_library(
+      
${ESP_HAL_3RDPARTY_REPO}/components/bt/controller/lib_esp32c6/esp32c6-bt-lib/esp32c6/libble_app.a
+    )
+  elseif(CONFIG_ARCH_CHIP_ESP32H2)
+    nuttx_add_extra_library(
+      
${ESP_HAL_3RDPARTY_REPO}/components/bt/controller/lib_esp32h2/esp32h2-bt-lib/libble_app.a
     )
   endif()
 endif()
@@ -57,8 +128,7 @@ if(CONFIG_ESPRESSIF_WIFI)
   nuttx_add_extra_library(
     ${ESP_HAL_3RDPARTY_REPO}/components/esp_wifi/lib/${CHIP_SERIES}/libcore.a
     
${ESP_HAL_3RDPARTY_REPO}/components/esp_wifi/lib/${CHIP_SERIES}/libnet80211.a
-    ${ESP_HAL_3RDPARTY_REPO}/components/esp_wifi/lib/${CHIP_SERIES}/libpp.a
-    
${ESP_HAL_3RDPARTY_REPO}/components/esp_wifi/lib/${CHIP_SERIES}/libespnow.a)
+    ${ESP_HAL_3RDPARTY_REPO}/components/esp_wifi/lib/${CHIP_SERIES}/libpp.a)
   if(CONFIG_WPA_WAPI_PSK)
     nuttx_add_extra_library(
       
${ESP_HAL_3RDPARTY_REPO}/components/esp_wifi/lib/${CHIP_SERIES}/libwapi.a)
diff --git a/arch/risc-v/src/common/espressif/Wireless.mk 
b/arch/risc-v/src/common/espressif/Wireless.mk
index a30f6527c6d..d3c1389d31a 100644
--- a/arch/risc-v/src/common/espressif/Wireless.mk
+++ b/arch/risc-v/src/common/espressif/Wireless.mk
@@ -27,12 +27,65 @@ INCLUDES += 
$(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY
 INCLUDES += 
$(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)nuttx$(DELIM)$(CHIP_SERIES)$(DELIM)include
 INCLUDES += 
$(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)nuttx$(DELIM)include$(DELIM)esp_wifi
 
+ifeq ($(CONFIG_ARCH_CHIP_ESP32C3),y)
 EXTRA_LIBPATHS += -L 
$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)bt$(DELIM)controller$(DELIM)lib_esp32c3_family$(DELIM)$(CHIP_SERIES)
+endif
+ifneq ($(filter y,$(CONFIG_ARCH_CHIP_ESP32C6) $(CONFIG_ARCH_CHIP_ESP32H2)),)
+ifeq ($(CONFIG_ESPRESSIF_BLE),y)
+INCLUDES += 
$(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)bt$(DELIM)common$(DELIM)osi$(DELIM)include
+INCLUDES += 
$(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)bt$(DELIM)common$(DELIM)tinycrypt$(DELIM)include
+INCLUDES += 
$(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)bt$(DELIM)common$(DELIM)tinycrypt$(DELIM)port
+INCLUDES += 
$(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)bt$(DELIM)host$(DELIM)nimble$(DELIM)nimble$(DELIM)porting$(DELIM)nimble$(DELIM)include
+INCLUDES += 
$(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)bt$(DELIM)host$(DELIM)nimble$(DELIM)port$(DELIM)include
+INCLUDES += 
$(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)bt$(DELIM)include$(DELIM)$(CHIP_SERIES)$(DELIM)include
+INCLUDES += 
$(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)bt$(DELIM)porting$(DELIM)include
+INCLUDES += 
$(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)bt$(DELIM)porting$(DELIM)transport$(DELIM)include
+INCLUDES += 
$(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_common$(DELIM)include
+INCLUDES += 
$(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_phy$(DELIM)include
+INCLUDES += 
$(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_phy$(DELIM)$(CHIP_SERIES)$(DELIM)include
+INCLUDES += 
$(INCDIR_PREFIX)$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)nuttx$(DELIM)src$(DELIM)platform$(DELIM)nimble$(DELIM)include
+
+CHIP_CSRCS += 
chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)bt$(DELIM)common$(DELIM)tinycrypt$(DELIM)src$(DELIM)ecc.c
+CHIP_CSRCS += 
chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)bt$(DELIM)common$(DELIM)tinycrypt$(DELIM)src$(DELIM)ecc_dh.c
+CHIP_CSRCS += 
chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)bt$(DELIM)common$(DELIM)tinycrypt$(DELIM)src$(DELIM)ecc_platform_specific.c
+CHIP_CSRCS += 
chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)bt$(DELIM)common$(DELIM)tinycrypt$(DELIM)port$(DELIM)esp_tinycrypt_port.c
+CHIP_CSRCS += 
chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)bt$(DELIM)common$(DELIM)tinycrypt$(DELIM)src$(DELIM)sha256.c
+CHIP_CSRCS += 
chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)bt$(DELIM)common$(DELIM)tinycrypt$(DELIM)src$(DELIM)utils.c
+CHIP_CSRCS += 
chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)bt$(DELIM)porting$(DELIM)mem$(DELIM)bt_osi_mem.c
+CHIP_CSRCS += 
chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)bt$(DELIM)porting$(DELIM)mem$(DELIM)os_msys_init.c
+CHIP_CSRCS += 
chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)bt$(DELIM)porting$(DELIM)transport$(DELIM)src$(DELIM)hci_transport.c
+CHIP_CSRCS += 
chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)bt$(DELIM)porting$(DELIM)transport$(DELIM)driver$(DELIM)vhci$(DELIM)hci_driver_standard.c
+CHIP_CSRCS += 
chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)bt$(DELIM)controller$(DELIM)$(CHIP_SERIES)$(DELIM)ble.c
+CHIP_CSRCS += 
chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)bt$(DELIM)controller$(DELIM)$(CHIP_SERIES)$(DELIM)bt.c
+CHIP_CSRCS += 
chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_hal_security$(DELIM)ecc_hal.c
+CHIP_CSRCS += 
chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_phy$(DELIM)src$(DELIM)btbb_init.c
+CHIP_CSRCS += 
chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)nuttx$(DELIM)src$(DELIM)platform$(DELIM)nimble$(DELIM)src$(DELIM)npl_os.c
+
+CFLAGS += $(DEFINE_PREFIX)ESP_PLATFORM=1
+
+ifeq ($(CONFIG_ARCH_CHIP_ESP32C6),y)
+EXTRA_LIBPATHS += -L 
$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)bt$(DELIM)controller$(DELIM)lib_esp32c6$(DELIM)esp32c6-bt-lib$(DELIM)esp32c6
+endif
+
+ifeq ($(CONFIG_ARCH_CHIP_ESP32H2),y)
+EXTRA_LIBPATHS += -L 
$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)bt$(DELIM)controller$(DELIM)lib_esp32h2$(DELIM)esp32h2-bt-lib
+
+CHIP_CSRCS += 
chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_phy$(DELIM)src$(DELIM)lib_printf.c
+CHIP_CSRCS += 
chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_phy$(DELIM)src$(DELIM)phy_common.c
+CHIP_CSRCS += 
chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_phy$(DELIM)src$(DELIM)phy_init_esp32hxx.c
+endif
+endif
+endif
+
 EXTRA_LIBPATHS += -L 
$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_coex$(DELIM)lib$(DELIM)$(CHIP_SERIES)
 EXTRA_LIBPATHS += -L 
$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_phy$(DELIM)lib$(DELIM)$(CHIP_SERIES)
 EXTRA_LIBPATHS += -L 
$(ARCH_SRCDIR)$(DELIM)chip$(DELIM)$(ESP_HAL_3RDPARTY_REPO)$(DELIM)components$(DELIM)esp_wifi$(DELIM)lib$(DELIM)$(CHIP_SERIES)
 
-EXTRA_LIBS += -lphy -lcoexist -lmesh -lespnow
+EXTRA_LIBS += -lphy -lcoexist
+
+ifneq ($(CONFIG_ARCH_CHIP_ESP32H2),y)
+EXTRA_LIBS += -lmesh -lespnow
+endif
 
 ifeq ($(CONFIG_ESPRESSIF_WIFI),y)
 
diff --git a/arch/risc-v/src/esp32c6/CMakeLists.txt 
b/arch/risc-v/src/esp32c6/CMakeLists.txt
index 877cf78ae45..12a654ea07d 100644
--- a/arch/risc-v/src/esp32c6/CMakeLists.txt
+++ b/arch/risc-v/src/esp32c6/CMakeLists.txt
@@ -29,6 +29,11 @@ if(CONFIG_ESPRESSIF_WIFI)
   list(APPEND SRCS esp_coex_adapter.c esp_wifi_adapter.c)
 endif()
 
+if(CONFIG_ESPRESSIF_BLE)
+  list(APPEND SRCS esp_ble.c)
+  target_compile_definitions(arch PRIVATE ESP_PLATFORM)
+endif()
+
 target_compile_definitions(arch PRIVATE _RETARGETABLE_LOCKING)
 
 if(SRCS)
diff --git a/arch/risc-v/src/esp32c6/Make.defs 
b/arch/risc-v/src/esp32c6/Make.defs
index 13a3e6bf657..925d542db48 100644
--- a/arch/risc-v/src/esp32c6/Make.defs
+++ b/arch/risc-v/src/esp32c6/Make.defs
@@ -32,4 +32,9 @@ CHIP_CSRCS += esp_coex_adapter.c esp_wifi_adapter.c
 EXTRA_LIBS += -lcore -lnet80211 -lpp
 endif
 
+ifeq ($(CONFIG_ESPRESSIF_BLE),y)
+CHIP_CSRCS += esp_ble.c
+EXTRA_LIBS +=  -lbtbb -lble_app
+endif
+
 CFLAGS += ${DEFINE_PREFIX}_RETARGETABLE_LOCKING
diff --git a/arch/risc-v/src/esp32c6/esp_ble.c 
b/arch/risc-v/src/esp32c6/esp_ble.c
new file mode 100644
index 00000000000..02c177efb1d
--- /dev/null
+++ b/arch/risc-v/src/esp32c6/esp_ble.c
@@ -0,0 +1,333 @@
+/****************************************************************************
+ * arch/risc-v/src/esp32c6/esp_ble.c
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <sys/types.h>
+
+#include <sys/socket.h>
+
+#include <stdbool.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+#include <nuttx/debug.h>
+
+#include <nuttx/nuttx.h>
+#include <nuttx/kmalloc.h>
+#include <nuttx/wqueue.h>
+#include <nuttx/net/bluetooth.h>
+#include <nuttx/wireless/bluetooth/bt_driver.h>
+#include <nuttx/wireless/bluetooth/bt_uart.h>
+
+#if defined(CONFIG_UART_BTH4)
+#  include <nuttx/serial/uart_bth4.h>
+#endif
+
+#include "esp_bt.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* BLE packet buffer max size */
+
+#define BLE_BUF_SIZE      1024
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+struct esp_ble_priv_s
+{
+  struct bt_driver_s drv;   /* NuttX BT/BLE driver data */
+};
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+static int esp_ble_open(struct bt_driver_s *drv);
+static int esp_ble_send(struct bt_driver_s *drv,
+                        enum bt_buf_type_e type,
+                        void *data, size_t len);
+static void esp_ble_close(struct bt_driver_s *drv);
+static void esp_ble_send_ready(void);
+static int esp_ble_recv_cb(uint8_t *data, uint16_t len);
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static struct esp_ble_priv_s g_ble_priv =
+{
+  .drv =
+    {
+      .head_reserve = H4_HEADER_SIZE,
+      .open         = esp_ble_open,
+      .send         = esp_ble_send,
+      .close        = esp_ble_close
+    }
+};
+
+static esp_vhci_host_callback_t vhci_host_cb =
+{
+  .notify_host_send_available = esp_ble_send_ready,
+  .notify_host_recv           = esp_ble_recv_cb
+};
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: esp_ble_send_ready
+ *
+ * Description:
+ *   If the controller could send HCI command will callback this function.
+ *
+ * Input Parameters:
+ *   None
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+static void esp_ble_send_ready(void)
+{
+}
+
+/****************************************************************************
+ * Name: esp_ble_recv_cb
+ *
+ * Description:
+ *   BLE receive callback function when BLE hardware receive packet
+ *
+ * Input Parameters:
+ *   data - BLE packet data pointer
+ *   len  - BLE packet length
+ *
+ * Returned Value:
+ *   0 on success or a negated value on failure.
+ *
+ ****************************************************************************/
+
+static int esp_ble_recv_cb(uint8_t *data, uint16_t len)
+{
+  int ret;
+  bool valid;
+  enum bt_buf_type_e type;
+  struct esp_ble_priv_s *priv = &g_ble_priv;
+
+  switch (data[0])
+    {
+      case H4_EVT:
+        type = BT_EVT;
+        valid = true;
+        break;
+      case H4_ACL:
+        type = BT_ACL_IN;
+        valid = true;
+        break;
+      case H4_ISO:
+        type = BT_ISO_IN;
+        valid = true;
+        break;
+      default:
+        valid = false;
+        break;
+    }
+
+  if (!valid)
+    {
+      ret = ERROR;
+    }
+  else
+    {
+      /* send packet to host */
+
+      ret = bt_netdev_receive(&priv->drv, type,
+                              &data[H4_HEADER_SIZE],
+                              len - H4_HEADER_SIZE);
+      if (ret < 0)
+        {
+          wlerr("Failed to receive ret=%d\n", ret);
+        }
+    }
+
+  return ret;
+}
+
+/****************************************************************************
+ * Name: esp_ble_send
+ *
+ * Description:
+ *   ESP32-C6 BLE send callback function for BT driver.
+ *
+ * Input Parameters:
+ *   drv  - BT driver pointer
+ *   type - BT packet type
+ *   data - BT packet data buffer pointer
+ *   len  - BT packet length
+ *
+ * Returned Value:
+ *   Sent bytes on success or a negated value on failure.
+ *
+ ****************************************************************************/
+
+static int esp_ble_send(struct bt_driver_s *drv,
+                        enum bt_buf_type_e type,
+                        void *data, size_t len)
+{
+  uint8_t *hdr = (uint8_t *)data - drv->head_reserve;
+
+  if ((len + H4_HEADER_SIZE) > BLE_BUF_SIZE)
+    {
+      return -EINVAL;
+    }
+
+  if (type == BT_CMD)
+    {
+      *hdr = H4_CMD;
+    }
+  else if (type == BT_ACL_OUT)
+    {
+      *hdr = H4_ACL;
+    }
+  else if (type == BT_ISO_OUT)
+    {
+      *hdr = H4_ISO;
+    }
+  else
+    {
+      return -EINVAL;
+    }
+
+  if (esp_vhci_host_check_send_available())
+    {
+      esp_vhci_host_send_packet(hdr, len + drv->head_reserve);
+    }
+
+  return len;
+}
+
+/****************************************************************************
+ * Name: esp_ble_close
+ *
+ * Description:
+ *   ESP32-C6 BLE close callback function for BT driver.
+ *
+ * Input Parameters:
+ *   drv - BT driver pointer
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+static void esp_ble_close(struct bt_driver_s *drv)
+{
+}
+
+/****************************************************************************
+ * Name: esp_ble_open
+ *
+ * Description:
+ *   ESP32-C6 BLE open callback function for BT driver.
+ *
+ * Input Parameters:
+ *   drv - BT driver pointer
+ *
+ * Returned Value:
+ *   OK on success or a negated value on failure.
+ *
+ ****************************************************************************/
+
+static int esp_ble_open(struct bt_driver_s *drv)
+{
+  return OK;
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: esp_ble_initialize
+ *
+ * Description:
+ *   Init BT controller
+ *
+ * Input Parameters:
+ *   None
+ *
+ * Returned Value:
+ *   success or fail
+ *
+ ****************************************************************************/
+
+int esp_ble_initialize(void)
+{
+  int ret;
+  esp_bt_controller_config_t cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
+
+  cfg.controller_task_stack_size = CONFIG_ESPRESSIF_BLE_TASK_STACK_SIZE;
+  cfg.controller_task_prio       = CONFIG_ESPRESSIF_BLE_TASK_PRIORITY;
+  cfg.controller_run_cpu         = CONFIG_BT_CTRL_PINNED_TO_CORE;
+
+  if (esp_bt_controller_init(&cfg) != ESP_OK)
+    {
+      wlerr("Failed to initialize BLE\n");
+      return ERROR;
+    }
+
+  if (esp_bt_controller_enable(ESP_BT_MODE_BLE) != ESP_OK)
+    {
+      wlerr("Failed to Enable BLE\n");
+      return ERROR;
+    }
+
+  ret = esp_vhci_host_register_callback(&vhci_host_cb);
+  if (ret != ESP_OK)
+    {
+      esp_bt_controller_disable();
+      wlerr("Failed to register BLE callback ret=%d\n", ret);
+      return ERROR;
+    }
+
+#if defined(CONFIG_UART_BTH4)
+  ret = uart_bth4_register(CONFIG_ESPRESSIF_BLE_TTY_NAME, &g_ble_priv.drv);
+#else
+  ret = bt_netdev_register(&g_ble_priv.drv);
+#endif
+  if (ret < 0)
+    {
+      wlerr("bt_netdev_register error: %d\n", ret);
+      return ret;
+    }
+
+  return OK;
+}
diff --git a/arch/risc-v/src/esp32c6/esp_ble.h 
b/arch/risc-v/src/esp32c6/esp_ble.h
new file mode 100644
index 00000000000..4413c53ea67
--- /dev/null
+++ b/arch/risc-v/src/esp32c6/esp_ble.h
@@ -0,0 +1,52 @@
+/****************************************************************************
+ * arch/risc-v/src/esp32c6/esp_ble.h
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+#ifndef __ARCH_RISCV_SRC_ESP32C6_ESP_BLE_H
+#define __ARCH_RISCV_SRC_ESP32C6_ESP_BLE_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: esp_ble_initialize
+ *
+ * Description:
+ *   Init BT controller
+ *
+ * Input Parameters:
+ *   None
+ *
+ * Returned Value:
+ *   success or fail
+ *
+ ****************************************************************************/
+
+int esp_ble_initialize(void);
+
+#endif /* __ARCH_RISCV_SRC_ESP32C6_ESP_BLE_H */
diff --git a/arch/risc-v/src/esp32h2/CMakeLists.txt 
b/arch/risc-v/src/esp32h2/CMakeLists.txt
index fa39d89da07..ac555ff464a 100644
--- a/arch/risc-v/src/esp32h2/CMakeLists.txt
+++ b/arch/risc-v/src/esp32h2/CMakeLists.txt
@@ -25,6 +25,11 @@ 
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/../common/espressif espressif)
 
 set(SRCS esp_chip_rev.c)
 
+if(CONFIG_ESPRESSIF_BLE)
+  list(APPEND SRCS esp_ble.c)
+  target_compile_definitions(arch PRIVATE ESP_PLATFORM)
+endif()
+
 target_compile_definitions(arch PRIVATE _RETARGETABLE_LOCKING)
 
 if(SRCS)
diff --git a/arch/risc-v/src/esp32h2/Make.defs 
b/arch/risc-v/src/esp32h2/Make.defs
index 25416b30e95..06c36319668 100644
--- a/arch/risc-v/src/esp32h2/Make.defs
+++ b/arch/risc-v/src/esp32h2/Make.defs
@@ -25,4 +25,9 @@ include common/espressif/Make.defs
 
 CHIP_CSRCS += esp_chip_rev.c
 
+ifeq ($(CONFIG_ESPRESSIF_BLE),y)
+CHIP_CSRCS += esp_ble.c
+EXTRA_LIBS += -lbtbb -lble_app
+endif
+
 CFLAGS += ${DEFINE_PREFIX}_RETARGETABLE_LOCKING
diff --git a/arch/risc-v/src/esp32h2/esp_ble.c 
b/arch/risc-v/src/esp32h2/esp_ble.c
new file mode 100644
index 00000000000..013e79e365d
--- /dev/null
+++ b/arch/risc-v/src/esp32h2/esp_ble.c
@@ -0,0 +1,333 @@
+/****************************************************************************
+ * arch/risc-v/src/esp32h2/esp_ble.c
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <sys/types.h>
+
+#include <sys/socket.h>
+
+#include <stdbool.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <errno.h>
+#include <nuttx/debug.h>
+
+#include <nuttx/nuttx.h>
+#include <nuttx/kmalloc.h>
+#include <nuttx/wqueue.h>
+#include <nuttx/net/bluetooth.h>
+#include <nuttx/wireless/bluetooth/bt_driver.h>
+#include <nuttx/wireless/bluetooth/bt_uart.h>
+
+#if defined(CONFIG_UART_BTH4)
+#  include <nuttx/serial/uart_bth4.h>
+#endif
+
+#include "esp_bt.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* BLE packet buffer max size */
+
+#define BLE_BUF_SIZE      1024
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+struct esp_ble_priv_s
+{
+  struct bt_driver_s drv;   /* NuttX BT/BLE driver data */
+};
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+static int esp_ble_open(struct bt_driver_s *drv);
+static int esp_ble_send(struct bt_driver_s *drv,
+                        enum bt_buf_type_e type,
+                        void *data, size_t len);
+static void esp_ble_close(struct bt_driver_s *drv);
+static void esp_ble_send_ready(void);
+static int esp_ble_recv_cb(uint8_t *data, uint16_t len);
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static struct esp_ble_priv_s g_ble_priv =
+{
+  .drv =
+    {
+      .head_reserve = H4_HEADER_SIZE,
+      .open         = esp_ble_open,
+      .send         = esp_ble_send,
+      .close        = esp_ble_close
+    }
+};
+
+static esp_vhci_host_callback_t vhci_host_cb =
+{
+  .notify_host_send_available = esp_ble_send_ready,
+  .notify_host_recv           = esp_ble_recv_cb
+};
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: esp_ble_send_ready
+ *
+ * Description:
+ *   If the controller could send HCI command will callback this function.
+ *
+ * Input Parameters:
+ *   None
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+static void esp_ble_send_ready(void)
+{
+}
+
+/****************************************************************************
+ * Name: esp_ble_recv_cb
+ *
+ * Description:
+ *   BLE receive callback function when BLE hardware receive packet
+ *
+ * Input Parameters:
+ *   data - BLE packet data pointer
+ *   len  - BLE packet length
+ *
+ * Returned Value:
+ *   0 on success or a negated value on failure.
+ *
+ ****************************************************************************/
+
+static int esp_ble_recv_cb(uint8_t *data, uint16_t len)
+{
+  int ret;
+  bool valid;
+  enum bt_buf_type_e type;
+  struct esp_ble_priv_s *priv = &g_ble_priv;
+
+  switch (data[0])
+    {
+      case H4_EVT:
+        type = BT_EVT;
+        valid = true;
+        break;
+      case H4_ACL:
+        type = BT_ACL_IN;
+        valid = true;
+        break;
+      case H4_ISO:
+        type = BT_ISO_IN;
+        valid = true;
+        break;
+      default:
+        valid = false;
+        break;
+    }
+
+  if (!valid)
+    {
+      ret = ERROR;
+    }
+  else
+    {
+      /* send packet to host */
+
+      ret = bt_netdev_receive(&priv->drv, type,
+                              &data[H4_HEADER_SIZE],
+                              len - H4_HEADER_SIZE);
+      if (ret < 0)
+        {
+          wlerr("Failed to receive ret=%d\n", ret);
+        }
+    }
+
+  return ret;
+}
+
+/****************************************************************************
+ * Name: esp_ble_send
+ *
+ * Description:
+ *   ESP32-C6 BLE send callback function for BT driver.
+ *
+ * Input Parameters:
+ *   drv  - BT driver pointer
+ *   type - BT packet type
+ *   data - BT packet data buffer pointer
+ *   len  - BT packet length
+ *
+ * Returned Value:
+ *   Sent bytes on success or a negated value on failure.
+ *
+ ****************************************************************************/
+
+static int esp_ble_send(struct bt_driver_s *drv,
+                        enum bt_buf_type_e type,
+                        void *data, size_t len)
+{
+  uint8_t *hdr = (uint8_t *)data - drv->head_reserve;
+
+  if ((len + H4_HEADER_SIZE) > BLE_BUF_SIZE)
+    {
+      return -EINVAL;
+    }
+
+  if (type == BT_CMD)
+    {
+      *hdr = H4_CMD;
+    }
+  else if (type == BT_ACL_OUT)
+    {
+      *hdr = H4_ACL;
+    }
+  else if (type == BT_ISO_OUT)
+    {
+      *hdr = H4_ISO;
+    }
+  else
+    {
+      return -EINVAL;
+    }
+
+  if (esp_vhci_host_check_send_available())
+    {
+      esp_vhci_host_send_packet(hdr, len + drv->head_reserve);
+    }
+
+  return len;
+}
+
+/****************************************************************************
+ * Name: esp_ble_close
+ *
+ * Description:
+ *   ESP32-C6 BLE close callback function for BT driver.
+ *
+ * Input Parameters:
+ *   drv - BT driver pointer
+ *
+ * Returned Value:
+ *   None
+ *
+ ****************************************************************************/
+
+static void esp_ble_close(struct bt_driver_s *drv)
+{
+}
+
+/****************************************************************************
+ * Name: esp_ble_open
+ *
+ * Description:
+ *   ESP32-C6 BLE open callback function for BT driver.
+ *
+ * Input Parameters:
+ *   drv - BT driver pointer
+ *
+ * Returned Value:
+ *   OK on success or a negated value on failure.
+ *
+ ****************************************************************************/
+
+static int esp_ble_open(struct bt_driver_s *drv)
+{
+  return OK;
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: esp_ble_initialize
+ *
+ * Description:
+ *   Init BT controller
+ *
+ * Input Parameters:
+ *   None
+ *
+ * Returned Value:
+ *   success or fail
+ *
+ ****************************************************************************/
+
+int esp_ble_initialize(void)
+{
+  int ret;
+  esp_bt_controller_config_t cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
+
+  cfg.controller_task_stack_size = CONFIG_ESPRESSIF_BLE_TASK_STACK_SIZE;
+  cfg.controller_task_prio       = CONFIG_ESPRESSIF_BLE_TASK_PRIORITY;
+  cfg.controller_run_cpu         = CONFIG_BT_CTRL_PINNED_TO_CORE;
+
+  if (esp_bt_controller_init(&cfg) != ESP_OK)
+    {
+      wlerr("Failed to initialize BLE\n");
+      return ERROR;
+    }
+
+  if (esp_bt_controller_enable(ESP_BT_MODE_BLE) != ESP_OK)
+    {
+      wlerr("Failed to Enable BLE\n");
+      return ERROR;
+    }
+
+  ret = esp_vhci_host_register_callback(&vhci_host_cb);
+  if (ret != ESP_OK)
+    {
+      esp_bt_controller_disable();
+      wlerr("Failed to register BLE callback ret=%d\n", ret);
+      return ERROR;
+    }
+
+#if defined(CONFIG_UART_BTH4)
+  ret = uart_bth4_register(CONFIG_ESPRESSIF_BLE_TTY_NAME, &g_ble_priv.drv);
+#else
+  ret = bt_netdev_register(&g_ble_priv.drv);
+#endif
+  if (ret < 0)
+    {
+      wlerr("bt_netdev_register error: %d\n", ret);
+      return ret;
+    }
+
+  return OK;
+}
diff --git a/arch/risc-v/src/esp32h2/esp_ble.h 
b/arch/risc-v/src/esp32h2/esp_ble.h
new file mode 100644
index 00000000000..8c6490bbcaf
--- /dev/null
+++ b/arch/risc-v/src/esp32h2/esp_ble.h
@@ -0,0 +1,52 @@
+/****************************************************************************
+ * arch/risc-v/src/esp32h2/esp_ble.h
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+#ifndef __ARCH_RISCV_SRC_ESP32H2_ESP_BLE_H
+#define __ARCH_RISCV_SRC_ESP32H2_ESP_BLE_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: esp_ble_initialize
+ *
+ * Description:
+ *   Init BT controller
+ *
+ * Input Parameters:
+ *   None
+ *
+ * Returned Value:
+ *   success or fail
+ *
+ ****************************************************************************/
+
+int esp_ble_initialize(void);
+
+#endif /* __ARCH_RISCV_SRC_ESP32H2_ESP_BLE_H */


Reply via email to