NimBLE-Arduino icon indicating copy to clipboard operation
NimBLE-Arduino copied to clipboard

ESP32-P4 Compilation Fails Due to Unconditional esp_bt.h Includes

Open landfishllc opened this issue 11 months ago • 4 comments

Hi NimBLE-Arduino maintainers!!!!🐟 👋 🤗 Thanks for your hard wizarding work ❤

I'm working with an ESP32P4 dev board, which includes a peripheral ESP32C6, pre-configured for ESP-Hosted

When I compile a minimal source file containing a #include <BleGamepad.h> statement, the build fails at libraries/NimBLE-Arduino/src/nimble/esp_port/esp-hci/esp_nimble_hci.c:18 due to an unconditional #include <esp_bt.h> (P4 has no onboard radio) even though commit 081bb7f added ESP32P4 include guards elsewhere/attempted to implement Hosted compatibility.

(My sdkconfig is correctly set up, I have been editing the template sdkconfig used by arduino-cli)

Steps to Reproduce:

Board: ESP32-P4 DevKit (Arduino IDE 2.3.2)
ESP32 Core: 3.2.0-RC1
Library: NimBLE-Arduino 2.2.2
Error:
  1. Create an Arduino project
  2. Install and include NimBLE-dependent library (such as ESP32-BLE-Gamepad)
  3. Compile

Expected Behavior:

Successful compilation when CONFIG_IDF_TARGET_ESP32P4 is defined.

Actual Behavior:

Used platform Version   Path
esp32:esp32   3.2.0-RC1 /home/ramblecube/.arduino15/packages/esp32/hardware/esp32/3.2.0-RC1
/home/ramblecube/Arduino/libraries/NimBLE-Arduino/src/nimble/esp_port/esp-hci/src/esp_nimble_hci.c:18:10: fatal error: esp_bt.h: No such file or directory
   18 | #include <esp_bt.h>
      |          ^~~~~~~~~~
compilation terminated.
Error during build: exit status 1

Workaround Attempt:

Wrapping the include with #if !defined(CONFIG_IDF_TARGET_ESP32P4) in affected files resolves the immediate error, but causes subsequent errors (undefined reference, etc.) that get worse as I include more wraps

Question:

Is ESP32P4 supported yet?

Environment:

-:: Linux x64

ESP-IDF: v5.2.1
Arduino Core: esp32:[email protected]

Thank you for your time! Let me know if more details would help.

landfishllc avatar Feb 28 '25 13:02 landfishllc

Hello @landfishllc, the CPP code in this repo mirrors esp-nimble-cpp which does support the P4. This repo cannot support it due to dependencies and conflicts in the Arduino core. You will need to use esp-nimble-cpp and esp-idf to support this board.

h2zero avatar Feb 28 '25 14:02 h2zero

h2zero, you are my h2hero, thanks for getting back to me so fast.

Unfortunately, my product parameters require the use of Arduino IDE (target developers will be children and teens).

I will attempt to incorporate the esp-nimble-cpp IDF component into the local esp-idf managed by Arduino, and work with that API.

If this does not work out, I will write custom C6 firmware and comm with AT commands.

I am doing my best Googling, but as of now, do you know of any BLE library for Arduino IDE supporting the Hosted architecture for P4?

landfishllc avatar Feb 28 '25 17:02 landfishllc

That's unfortunate but understandable. In that can you can make a custom arduino core and enable Nimble and add esp-nimble-cpp, Tasmota has a similar configuration. You'll need to add the hosted library as well of course.

I haven't seen anyone attempt this with Arduino so you're probably the first, good luck!

h2zero avatar Feb 28 '25 17:02 h2zero

is there any progress on that ? Recent Release 2.3.1 still gives build failure with ESP32-P4 and Arduino Core 3.x...

lyusupov avatar Jun 21 '25 23:06 lyusupov