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

Parents
  • Hi,

     

    You shall use flow control with H4, as described in the description of the sample:

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

     

    The baudrate of 921k6 is quite inaccurate, and you should rather use 1M baud. Here's the actual baudrate, as per the comment from nrf52_bitfields.h:

     

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

     hciattach is a deprecated tool, you should use btattach instead (with hwfc).

     

    Kind regards,

    Håkon

  • 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:




    And console (on raspberry pi4) returns:



    btmon data:



    UART port config: RTS/CTS - ON, SPEED - 1000000, Parity - None...
  • 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:

     

    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 ?

    Next step scan:

    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?

  • Hi,

     

    I usually use some sort of bluetooth daemon, as its much easier than going directly on low-level.

    Here's my output after finding the mac address of my advertising device ("power on", then issue "find -l")

    Pairing failed here, but the connection is kept afterwards.

    btmgmt isn't very well documented, so I would recommend checking forums like stackoverflow etc for more info on this application.

     

    Kind regards,

    Håkon

  • What about Long Range? Can Zephyr LR? And does the BlueZ 5.56 work with him adequately? Which commands and parameters?))

Reply Children