Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bluetooth chip doesn't work on UART3 interface #13

Open
lihing1994 opened this issue Feb 1, 2025 · 5 comments
Open

Bluetooth chip doesn't work on UART3 interface #13

lihing1994 opened this issue Feb 1, 2025 · 5 comments

Comments

@lihing1994
Copy link

I am trying to bring up the WL1837 Wi-Fi + Bluetooth chip on the MA35D1 platform. According to the datasheet, the Bluetooth interface requires hardware flow control (RTS/CTS). It seems like the handshaking between UART and WL1837 is failed. Thanks in advance for any hint and help for solving this issue!

Steps Taken:

  • Verified the physical connection between the CTS and RTS pins on the SoC and the WL1837 module.
  • Enabled uart-has-rtscts; in the uart3 device tree node to enable hardware flow control.
  • Tried to add small delay before the handshake is being built.(this commit)
    Despite these changes, the Bluetooth chip fails during the probe process.

Here is the potion of kernel dmesg that related to the Bluetooth.

root@som-35d1f:~# dmesg | grep Blue
[    0.720442] Bluetooth: Core ver 2.22
[    0.728375] Bluetooth: HCI device and connection manager initialized
[    0.734708] Bluetooth: HCI socket layer initialized
[    0.739555] Bluetooth: L2CAP socket layer initialized
[    0.744596] Bluetooth: SCO socket layer initialized
[    2.442381] Bluetooth: HCI UART driver ver 2.3
[    2.446779] Bluetooth: HCI UART protocol H4 registered
[    2.451873] Bluetooth: HCI UART protocol BCSP registered
[    2.452029] Bluetooth: HCI UART protocol LL registered
[    2.464097] Bluetooth: HCI UART protocol ATH3K registered
[    2.464145] Bluetooth: HCI UART protocol Three-wire (H5) registered
[    4.775363] Bluetooth: hci0: command 0x1001 tx timeout
[    5.537772] Bluetooth: RFCOMM TTY layer initialized
[    5.542638] Bluetooth: RFCOMM socket layer initialized
[    5.547730] Bluetooth: RFCOMM ver 1.11
[    5.551439] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[    5.556712] Bluetooth: BNEP filters: protocol multicast
[    5.561919] Bluetooth: BNEP socket layer initialized
[    5.566852] Bluetooth: HIDP (Human Interface Emulation) ver 1.2
[    5.572751] Bluetooth: HIDP socket layer initialized
[   13.223357] Bluetooth: hci0: Reading TI version information failed (-110)
[   13.230108] Bluetooth: hci0: download firmware failed, retrying...
[   15.463352] Bluetooth: hci0: command 0x1001 tx timeout
[   23.463352] Bluetooth: hci0: Reading TI version information failed (-110)
[   23.463372] Bluetooth: hci0: download firmware failed, retrying...
[   25.703334] Bluetooth: hci0: command 0x1001 tx timeout
[   33.703350] Bluetooth: hci0: Reading TI version information failed (-110)
[   33.703368] Bluetooth: hci0: download firmware failed, retrying...
[   35.943336] Bluetooth: hci0: command 0x1001 tx timeout
[   43.943359] Bluetooth: hci0: Reading TI version information failed (-110)
[   43.943379] Bluetooth: hci0: download firmware failed, retrying...
root@som-35d1f:~#

Here is the potion of device tree that related to the Bluetooth.

&uart3 {
        /* uart3 interface is being utilized for Bluetooth functionality */
        status = "okay";
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_wl1837_bt>;
        /*  uart-has-rtscts; */
        bluetooth {
                compatible = "ti,wl1837-st";
                enable-gpios = <&gpio_expander_on_som 2 GPIO_ACTIVE_HIGH>;
                vio-supply = <&general_1v8_regulator>;
                vbat-supply = <&general_3v3_regulator>;
        };
};

&pinctrl {
      bt {
                pinctrl_wl1837_bt: wl1837_btgrp{
                        nuvoton,pins =
                                <SYS_GPA_MFPL_PA4MFP_UART3_nCTS     &pcfg_default>,
                                <SYS_GPA_MFPL_PA5MFP_UART3_nRTS     &pcfg_default>,
                                <SYS_GPA_MFPL_PA6MFP_UART3_RXD      &pcfg_default>,
                                <SYS_GPA_MFPL_PA7MFP_UART3_TXD      &pcfg_default>;
                };
        };
};

@lihing1994 lihing1994 changed the title Bluetooth chip doesn't work on UART4 interface Bluetooth chip doesn't work on UART3 interface Feb 1, 2025
@mjchen1
Copy link
Contributor

mjchen1 commented Feb 3, 2025

You can use the following setting in the application code:
options.c_cflag |= CRTSCTS;

@lihing1994
Copy link
Author

You can use the following setting in the application code:
options.c_cflag |= CRTSCTS;

Any chance you can elaborate on this? You meaning adding this in TI HCI_LL.c driver code? Thanks!

@mjchen1
Copy link
Contributor

mjchen1 commented Feb 3, 2025

Here is a simple example of setting up UART:

int main() {
int serial_fd;
struct termios options;

serial_fd = open("/dev/ttyS0", O_RDWR | O_NOCTTY | O_NDELAY);
if (serial_fd == -1) {
    perror("Unable to open UART");
    return -1;
}

tcgetattr(serial_fd, &options);

cfsetispeed(&options, B115200); 
cfsetospeed(&options, B115200); 

// Enable Flow control
options.c_cflag |= CRTSCTS;

options.c_cflag &= ~PARENB;
options.c_cflag &= ~CSTOPB;
options.c_cflag &= ~CSIZE;
options.c_cflag |= CS8;

options.c_cflag |= CREAD | CLOCAL;

tcsetattr(serial_fd, TCSANOW, &options);

write(serial_fd, "Hello UART with flow control!\n", 30);

close(serial_fd);

return 0;

}

@lihing1994
Copy link
Author

Here is a simple example of setting up UART:

int main() {
int serial_fd;
struct termios options;

serial_fd = open("/dev/ttyS0", O_RDWR | O_NOCTTY | O_NDELAY);
if (serial_fd == -1) {
    perror("Unable to open UART");
    return -1;
}

tcgetattr(serial_fd, &options);

cfsetispeed(&options, B115200); 
cfsetospeed(&options, B115200); 

// Enable Flow control
options.c_cflag |= CRTSCTS;

options.c_cflag &= ~PARENB;
options.c_cflag &= ~CSTOPB;
options.c_cflag &= ~CSIZE;
options.c_cflag |= CS8;

options.c_cflag |= CREAD | CLOCAL;

tcsetattr(serial_fd, TCSANOW, &options);

write(serial_fd, "Hello UART with flow control!\n", 30);

close(serial_fd);

return 0;

}

  • I’m not entirely sure why I need to use this code to set up the UART. It appears the dmesg I attached above saying that the Bluetooth driver fails during the initialization process. Shouldn’t I focus on identifying the issue causing the driver to fail to communicate with the UART controller instead?

@mjchen1
Copy link
Contributor

mjchen1 commented Feb 3, 2025

From the beginning, I thought you were asking about how to set up CTS/RTS, but it seems that’s not the case. You might need to first confirm whether the UART signals are being transmitted correctly and whether the CTS/RTS actions are functioning properly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants