This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

nRF52840-DK as HCI-UART based on zephyr issue

There are two boards, Raspberry PI4 and nRF52840-DK. The task is for the nRF52840-DK on zephyr hci-uart firmware:

https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/samples/bluetooth/hci_uart/README.html

to operate in HCI-UART (HCI only driver) mode, and Raspberry PI4 to operate in host mode. On the host side, the version 5.50 BlueZ is installed. The boards are connected via UART interface, at 921600Kb/s speed. After connecting and initializing nRF52840 using the hciattach command, the device initializes and connects and even scans (hcitool lescan) and sees other LE devices, but when trying to connect to them or get information about them (leinfo), an error occurs for the first time:

Could not create connection: Connection timed out

An error occurs during further attempts:

Could not create connection: Input/output error

There is a similar problem with setting the device name. An error occurred while trying to read or set the name (hciconfig hci* name):

Can't read local name on hci1: Input/output error (5)

At the same time, the oscillograph shows that the exchange between the devices is in both directions… There were also attempts to change speed and flow control - but, they did not give results.

As a result, we have: you can scan and watch visible devices, but you can't get anything, connect or change anything. Only scan and device list - that's all.

Boards Connection:

RPI4 (PIN27) <-> NRFDK (P0.08); RPI4(PIN28) <-> NRFDK (P0.06); RPI4 (GND) <-> NRFDK (GND)

 

Raspberry PI4 board configuration and params:

OS: Raspbian (32bit), V: 1.4

BlueZ: 5.50

UART: UART2

TXD -> GPIO0 -> PIN27

RXD -> GPIO1 -> PIN28

UART Speed: 1000000 / 921600 / 115200 Kb/s (variants of test)

Flow Control: None

RX/TX TTL Voltage: 3.3V

 

nRF52840-DK board configuration and params:

FW: HCI-UART (Zephyr Bluetooth: HCI UART sample)

nRF Connect SDK: 1.5.0

Project name: hci-uart

Build: zephyr.elf

UART: UART0

UART Speed: 1000000 / 921600 / 115200 Kb/s (variants of test)

Flow Control: None

 

Bluez device attach command string (for variant of 921600Kb/s):

sudo hciattach -t 5 -s 921600 /dev/ttyAMA1 any 921600 noflow nosleep

  • btattach - NOT work - hangs, only hciattach works....

    sudo btattach -B /dev/ttyAMA1 -S 1000000 -P h4

    OR

    sudo btattach -B /dev/ttyAMA1 -S 1000000 -R

    Does not attach, just hangs...

    Debug info from nRF MC on tray to set local name:


    [00:23:01.439,422] <dbg> hci_uart.rx_isr: putting RX packet in queue.
    [00:23:01.439,453] <dbg> hci_uart.bt_uart_isr: spurious interrupt
    [00:23:01.439,544] <dbg> hci_uart.h4_send: buf 0x20009a20 type 1 len 7


    And console (on raspberry pi4) returns:

    Can't change local name on hci0: Input/output error (5)


    btmon data:

    Bluetooth monitor ver 5.56
    = Note: Linux version 5.4.83-v7l+ (armv7l)                                                              0.083328
    = Note: Bluetooth subsystem version 2.22                                                                0.083336
    = New Index: 00:00:00:00:00:00 (Primary,UART,hci0)                                               [hci0] 0.083340
    = Open Index: 00:00:00:00:00:00                                                                  [hci0] 0.083343
    = Index Info: 00:00:00:00:00:00 (The Linux Foundation)                                           [hci0] 0.083348
    @ MGMT Open: bluetoothd (privileged) version 1.14                                              {0x0001} 0.083351
    @ RAW Open: hciconfig (privileged) version 2.22                                                {0x0002} 3.129615
    @ RAW Open: hciconfig (privileged) version 2.22                                         {0x0003} [hci0] 3.129904
    < HCI Command: Write Local Name (0x03|0x0013) plen 248                                        #1 [hci0] 3.130119
            Name: xxx
    > HCI Event: Command Status (0x0f) plen 4                                                     #2 [hci0] 3.133205
          Write Local Name (0x03|0x0013) ncmd 1
            Status: Unknown HCI Command (0x01)
    @ RAW Close: hciconfig                                                                  {0x0003} [hci0] 3.134206
    @ RAW Close: hciconfig                                                                         {0x0002} 3.134404


    UART port config: RTS/CTS - ON, SPEED - 1000000, Parity - None...
  • Have you tried this on a PC running linux? Or by using hci_usb instead, or a different UART converter (USB/Uart one)? This might be a limitation with your rpi's uart interface / configuration. Is it even capable of doing 1MBaud?

    Kind regards,

    Håkon

  • No converters used, connected to direct... UART TTL, U = 3.3V (Lgic 1)... If you shorten TX on RX on raspberry pi4, everything works, forwards it to itself without distortion (on 1M speed). On UART2 there are no restrictions and RTS/CTS it supports...

    HCI-USB also tried, the result is the same, connects, after which you can only scan, and watch version information, and on this everything, when trying to set a local name or other configuration, we get IO error (*)...

    Interestingly, the regular BT (which is soldered on the RPI4) works perfectly, tunes, scans, etc.

  • AlexandrX said:
    If you shorten TX on RX on raspberry pi4, everything works, forwards it to itself without distortion (on 1M speed)

     This is an OK proof-of-concept, but if you have any error in frequency; it will not be shown here. Please check the waveform by outputting "0xAA" / "0x55" over UART and see what the frequency is.

    Or just test using 115k2 baud.

      

    AlexandrX said:

    HCI-USB also tried, the result is the same, connects, after which you can only scan, and watch version information, and on this everything, when trying to set a local name or other configuration, we get IO error (*)...

    As mentioned, you cannot change the name. it does not support that. This one also does not connect properly? How did you connect to the device??

    I have tested both now, and using the "hci*" prefixed tools, I get strange results. By using bluetoothd, I'm able to successfully connect, and see the connection afterwards in hcitool:

    $ sudo hcitool -i hci1 con
    Connections:
    	< LE C7:5C:54:47:7E:59 handle 0 state 1 lm MASTER AUTH ENCRYPT 

     

    note: I cannot use hcitool successfully for all functions; it can find devices but not create a connection. as this tool is deprecated, some features might not work anymore.

     

    Kind regards,

    Håkon

  • How to connect (pair) le devices on btmgmt ?

    sudo btmgmt --index 0

    Next step scan:

    [hci0]# find -l

    After I found the right device, I try the pair command, but it connects via BR/EDR. What parameters do I need to connect LE?

    >> pair [-c cap] [-t type] <remote address>

    [-c cap] [-t type] - Is there a detailed description? how to LE pair?

Related