esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
290 stars 34 forks source link

ESP32-C6 bluetooth not working #4909

Open cjc7373 opened 11 months ago

cjc7373 commented 11 months ago

The problem

When I tried to enable esp32_ble_tracker in my esp32-c6-devkitc-1 board, I encountered some compile error, see the logs below.

Which version of ESPHome has the issue?

2023.9.0b2

What type of installation are you using?

Home Assistant Add-on

Which version of Home Assistant has the issue?

No response

What platform are you using?

ESP32-IDF

Board

No response

Component causing the issue

No response

Example YAML snippet

# snippet of the full config
esp32:
  board: esp32-c6-devkitc-1
  # board: esp32dev
  framework:
    type: esp-idf
    platform_version: 6.4.0
    version: 5.1.1
  variant: esp32c6

esp32_ble_tracker:
  scan_parameters:
    active: true

Anything in the logs that might be useful for us?

INFO ESPHome 2023.9.0b2
INFO Reading configuration /config/esphome/esp32-c6.yaml...
WARNING The selected ESP-IDF framework version is not the recommended one. If there are connectivity or build issues please remove the manual version.
WARNING The selected ESP-IDF framework version is not the recommended one. If there are connectivity or build issues please remove the manual version.
INFO Generating C++ source...
INFO Updating https://github.com/espressif/esp-protocols.git@mdns-v1.2.0
INFO Compiling app...
Processing esp32-c6 (board: esp32-c6-devkitc-1; framework: espidf; platform: platformio/espressif32@6.4.0)
--------------------------------------------------------------------------------
HARDWARE: ESP32C6 160MHz, 512KB RAM, 8MB Flash
 - framework-espidf @ 3.50101.230828 (5.1.1) 
 - tool-cmake @ 3.16.4 
 - tool-ninja @ 1.7.1 
 - tool-riscv32-esp-elf-gdb @ 12.1.0+20221002 
 - tool-xtensa-esp-elf-gdb @ 12.1.0+20221002 
 - toolchain-esp32ulp @ 2.35.0-20220830 
 - toolchain-riscv32-esp @ 12.2.0+20230208
Reading CMake configuration...
Dependency Graph
|-- noise-c @ 0.1.4
Compiling .pioenvs/esp32-c6/src/esphome/components/api/api_connection.o
Compiling .pioenvs/esp32-c6/src/esphome/components/api/api_frame_helper.o
Compiling .pioenvs/esp32-c6/src/esphome/components/api/api_pb2.o
Compiling .pioenvs/esp32-c6/src/esphome/components/api/api_pb2_service.o
Compiling .pioenvs/esp32-c6/src/esphome/components/api/api_server.o
Compiling .pioenvs/esp32-c6/src/esphome/components/api/list_entities.o
Compiling .pioenvs/esp32-c6/src/esphome/components/api/proto.o
Compiling .pioenvs/esp32-c6/src/esphome/components/api/subscribe_state.o
Compiling .pioenvs/esp32-c6/src/esphome/components/api/user_services.o
Compiling .pioenvs/esp32-c6/src/esphome/components/binary_sensor/automation.o
Compiling .pioenvs/esp32-c6/src/esphome/components/binary_sensor/binary_sensor.o
Compiling .pioenvs/esp32-c6/src/esphome/components/binary_sensor/filter.o
Compiling .pioenvs/esp32-c6/src/esphome/components/bluetooth_proxy/bluetooth_connection.o
Compiling .pioenvs/esp32-c6/src/esphome/components/bluetooth_proxy/bluetooth_proxy.o
Compiling .pioenvs/esp32-c6/src/esphome/components/captive_portal/captive_portal.o
Compiling .pioenvs/esp32-c6/src/esphome/components/esp32/core.o
Compiling .pioenvs/esp32-c6/src/esphome/components/esp32/gpio.o
Compiling .pioenvs/esp32-c6/src/esphome/components/esp32/preferences.o
Compiling .pioenvs/esp32-c6/src/esphome/components/esp32_ble/ble.o
Compiling .pioenvs/esp32-c6/src/esphome/components/esp32_ble/ble_advertising.o
In file included from src/esphome/components/esp32_ble/ble.cpp:7:
src/esphome/components/esp32_ble/ble.cpp: In member function 'bool esphome::esp32_ble::ESP32BLE::ble_setup_()':
/data/cache/platformio/packages/framework-espidf/components/bt/include/esp32c6/include/esp_bt.h:263:1: warning: missing initializer for member 'esp_bt_controller_config_t::cca_drop_mode' [-Wmissing-field-initializers]
  263 | }
      | ^
src/esphome/components/esp32_ble/ble.cpp:62:40: note: in expansion of macro 'BT_CONTROLLER_INIT_CONFIG_DEFAULT'
   62 |       esp_bt_controller_config_t cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
      |                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/data/cache/platformio/packages/framework-espidf/components/bt/include/esp32c6/include/esp_bt.h:263:1: warning: missing initializer for member 'esp_bt_controller_config_t::cca_low_tx_pwr' [-Wmissing-field-initializers]
  263 | }
      | ^
src/esphome/components/esp32_ble/ble.cpp:62:40: note: in expansion of macro 'BT_CONTROLLER_INIT_CONFIG_DEFAULT'
   62 |       esp_bt_controller_config_t cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
      |                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/data/cache/platformio/packages/framework-espidf/components/bt/include/esp32c6/include/esp_bt.h:258:58: error: narrowing conversion of 'efuse_hal_chip_revision()' from 'uint32_t' {aka 'long unsigned int'} to 'uint8_t' {aka 'unsigned char'} [-Werror=narrowing]
  258 |     .version_num                = efuse_hal_chip_revision(),                            \
      |                                   ~~~~~~~~~~~~~~~~~~~~~~~^~
src/esphome/components/esp32_ble/ble.cpp:62:40: note: in expansion of macro 'BT_CONTROLLER_INIT_CONFIG_DEFAULT'
   62 |       esp_bt_controller_config_t cfg = BT_CONTROLLER_INIT_CONFIG_DEFAULT();
      |                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1plus: some warnings being treated as errors
*** [.pioenvs/esp32-c6/src/esphome/components/esp32_ble/ble.o] Error 1
========================= [FAILED] Took 54.26 seconds =========================

Additional information

No response

HeMan commented 11 months ago

One of those messages (/data/cache/platformio/packages/framework-espidf/components/bt/include/esp32c6/include/esp_bt.h:258:58: error: narrowing conversion of 'efuse_hal_chip_revision()' from 'uint32_t' {aka 'long unsigned int'} to 'uint8_t' {aka 'unsigned char'} [-Werror=narrowing]) seem to be an error in ESP-IDF for esp32c6. I'll create a PR for it.

HeMan commented 11 months ago

It looks like all of them is due to bugs in ESP-IDF.

cjc7373 commented 10 months ago

Thanks, I applied your patch locally and the compile error has gone.

However, the bluetooth is still not working. And when I set log level to debug, I see the following lines:

[14:36:18][C][esp32_ble:243]: ESP32 BLE: bluetooth stack is not enabled
[14:36:18][C][esp32_ble_tracker:617]: BLE Tracker:
[14:36:18][C][esp32_ble_tracker:618]:   Scan Duration: 300 s
[14:36:18][C][esp32_ble_tracker:619]:   Scan Interval: 320.0 ms
[14:36:18][C][esp32_ble_tracker:620]:   Scan Window: 30.0 ms
[14:36:18][C][esp32_ble_tracker:621]:   Scan Type: ACTIVE
[14:36:18][C][esp32_ble_tracker:622]:   Continuous Scanning: True

Any clue why this happens?

luomanruo commented 9 months ago

Thank you for bringing this to our attention, and we appreciate your patience. We have verified the issue you reported and provided a temporary solution. For this problem, we recommend modifying the esp_bt.h file by casting the return value of efuse_hal_chip_revision() to uint8_t as follows, matching the version_num structure member. .version_num = (uint8_t)efuse_hal_chip_revision(), This is a temporary workaround, and we plan to address this issue in future releases.

stefan-schweiger commented 2 months ago

@luomanruo can you be more specific what you mean by modifying the esp_bt.h file? Also maybe any update on a potential permanent fix for this?

mx5gr commented 1 month ago

Issue still persists with ESP-IDF 5.2.2, PlatformIO 6.7.0 and ESPHome 2024.6.4:

Compiling .pioenvs/sens-1st-bedroom-ac/bootloader_support/src/esp_image_format.c.o In file included from src/esphome.h:26, from src/main.cpp:3: src/esphome/components/esp32_ble/const_esp32c6.h:62:1: warning: missing initializer for member ‘esp_bt_controller_config_t::cca_drop_mode’ [-Wmissing-field-initializers] 62 | }; | ^ src/esphome/components/esp32_ble/const_esp32c6.h:62:1: warning: missing initializer for member ‘esp_bt_controller_config_t::cca_low_tx_pwr’ [-Wmissing-field-initializers] src/esphome/components/esp32_ble/const_esp32c6.h:62:1: warning: missing initializer for member ‘esp_bt_controller_config_t::csa2_select’ [-Wmissing-field-initializers]

mx5gr commented 3 weeks ago

Issue still persists with ESP-IDF 5.3.0, PlatformIO 6.8.1 and ESPHome 2024.7.2:

In file included from src/esphome/components/esp32_ble/ble.cpp:6: src/esphome/components/esp32_ble/const_esp32c6.h:62:1: warning: missing initializer for member 'esp_bt_controller_config_t::cca_drop_mode' [-Wmissing-field-initializers] 62 | }; | ^ src/esphome/components/esp32_ble/const_esp32c6.h:62:1: warning: missing initializer for member 'esp_bt_controller_config_t::cca_low_tx_pwr' [-Wmissing-field-initializers] src/esphome/components/esp32_ble/const_esp32c6.h:62:1: warning: missing initializer for member 'esp_bt_controller_config_t::csa2_select' [-Wmissing-field-initializers]