espressif / esp-hosted

Hosted Solution (Linux/MCU) with ESP32 (Wi-Fi + BT + BLE)
Other
705 stars 167 forks source link

esp-hosted-ng: WiFi SPI + BLE HCI - Bluetooth interface doesn't go up #440

Closed QuiGonRazor closed 3 months ago

QuiGonRazor commented 3 months ago

Hello all, I've correctly setup an ESP32-C3 with NG fw. It correctly talks, brings up wlan0 interface and it works as expected (it connects via WiFi + communicates via Internet)

I'm now interested in having the BLE interface working. I've tried with both WiFi and BLE via SPI and all worked fine. Now I'm trying to switch to BLE HCI (H4). I followed the guide into the repo and connected all related GPIOs (CST, RTS, BLE RX, BLE TX).

It seems not working. When I launched the command hciattach [PORT] 115200 any flow my system tries to bring up the BLE interface, failing miserably. Using dmesg I can clearly see that hci bring up commands are failing due to timeout.

Since I correctly managed to use the BLE via SPI I don't think it is an issue with the BLE module but something related with HCI communication

Can you help me please? What am I missing?

mantriyogesh commented 3 months ago

Bluetooth over uart, is actually pass through for ESP-Hosted.

Have you configured your host uart pins to use bluetooth?

Screenshot_2024-07-29-23-19-59-858_com brave browser_beta-edit

If you configure your Linux gpios in device tree or any other way, it should work.

Make sure you connect the uart pins correctly.

Check uart setup: https://github.com/espressif/esp-hosted/blob/master/esp_hosted_ng/docs/setup.md#23-sdiospi--uart-configuration

Here instead of Raspberry Pi setup, you need to configure for your host. ESP side setup steps can be referred from documentation.

mantriyogesh commented 3 months ago

ESP side controller directly supports standard HCI interface.

Check if you have configured ESP correctly from setup document. Also check the HCI over UART baud rate used in IDF.py menuconfig. Is it two pin or four pin uart, accordingly flow control enabled or disabled in both ESP and host,

Check if pin connection are correct (rx to tx and vice versa, rts to CTS and vice versa)

mantriyogesh commented 3 months ago

Once you setup Linux uart driver in HCI mode, it should just work. These messages are pass through for ESP-Hosted, meaning the HCI over UART messages from Linux directly end from Linux driver to ESP controller. These messages do not enter hosted kernel module at Linux and hosted slave driver at esp.

HCI over UART is independent of ESP-Hosted code.

QuiGonRazor commented 3 months ago

I reply you per steps

This uart I'm 100% works (used before for other meanings)

mantriyogesh commented 3 months ago

As fas I remember ESP32 had default bad rate set to 921600, unless explicitly changed.

Also for c3, there was no default config from esp-idf, so we had added manual option that time. (Setup doc should be covering this, also you can search manually for 'UART.*BAUD' in sdkconfig generated after idf.py menuconfig. I will also check if any default option introduced and being used newly in esp-idf.

mantriyogesh commented 3 months ago

Could you try with 921600?

$ hciconfig -a
$ sudo killall hciattach
$ sudo hciattach -s <baud_rate> <serial_device_name> /dev/serial0 any <baud_rate> flow
$ hciconfig -a
: ~~921600~~ 115200 : uart serial device exposed through host device tree config, to use for `hci over uart` Edit1: Change baud rate as per configured/used at esp side
QuiGonRazor commented 3 months ago

Hello, sorry for being late.

Yesterday I tried with a second devkit I have and it worked correctly (setting HCI baud rate to 115200), same flashed binary

Today I'll try with the first one flashing it again with the default baud rate you've suggested

mantriyogesh commented 3 months ago

oh okay. Can you share your sdkconfig generated while building, for chipset you had experienced the problem?

QuiGonRazor commented 3 months ago

Yeah sure, here attached I had to add txt extension to be able to upload it

sdkconfig.txt

mantriyogesh commented 3 months ago

considering

CONFIG_EXAMPLE_HCI_UART_BAUDRATE=115200

Edited https://github.com/espressif/esp-hosted/issues/440#issuecomment-2259588979 to correct baud rate for your case.

QuiGonRazor commented 3 months ago

Hello, restoring the BAUDRATE to the default one (921600) works for both the devkits.

It seems all is working good.