BLE communication between a nRF52 DK board and a nRF9160 DK board

I am running V2.5.0 SDK. I have a nRF52 DK board that is running the V2.5.0/nrf/samples/Bluetooth/peripheral_uart application. It is working beautifully. I have nRF Toolbox installed on my iPhone. I can connect to the nRF52 DK Bluetooth running the NUS UART service. I can send text strings back and forth from my iPhone to the nrf52DK baord. We have been using the nRF9160 processor for years and we are very comfortable with its operation. We have never used the Bluetooth feature on the nRF9160. I have a nRF9160 dk board that I would like to implement the NUS UART Bluetooth connection like I have running with the iPhone using nRF Toolbox. I want an application on the nRF9160 to search for BLE devices advertising the UART service. I want to connect to that BLE device and be able to send text string back and forth like I can do on my iPhone. I tried the "Bluetooth central UART" but it does not support the nRF9160 as a valid board.

what do I need to do to implement a simple BLE connection between the nRF52DK and the nRF9160DK so I can send text strings back and forth simulating a UART.I have not used any BLE functions until we received the nrf52DK board. I am sure it is operator error. Our application depends on the BLE capability to talk between an nRF52 and a nRF9160. any help would be greatly appreciated.

Parents
  • Hello,

    Attached is a modified version of the Central UART sample, which you can program to the nRF9160 on the nRF9160 DK (use the 'nrf9160dk_nrf9160_ns' build target). You can see the changes I made in the 'changes.diff' file bundled with the zip. It was mostly just copy-and-paste from the Cellular: LTE Sensor Gateway sample.

    Attachment (tested with SDK v.2.5.0)

    6431.central_uart.zip

    Best regards,

    Vidar

    Edit: forgot to add that you need to program the LP HCI UART sample to the nRF52840 on the board for BLE connectivity: https://developer.nordicsemi.com/nRF_Connect_SDK/doc/2.5.0/nrf/samples/cellular/lte_ble_gateway/README.html#programming-the-sample 

  • Vidar: thank you for your quick response. I tried to build a configuration and it failed with the information shown below. what am I doing wrong? I unzipped the file and tried to configure as I have done with all of the other samples.

    -- Found devicetree overlay: boards/nrf9160dk_nrf9160_ns.overlay
    In file included from <command-line>:
    ./boards/nrf9160dk_nrf9160_ns.overlay:1:10: fatal error: nrf9160dk_nrf52840_reset_on_if5.dtsi: No such file or directory
    1 | #include <nrf9160dk_nrf52840_reset_on_if5.dtsi>
    | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    compilation terminated.
    CMake Error at C:/Nordic1/v2.5.0/zephyr/cmake/modules/extensions.cmake:3885 (message):
    failed to preprocess devicetree files (error code 1):
    C:/Nordic1/v2.5.0/zephyr/boards/arm/nrf21540dk_nrf52840/nrf21540dk_nrf52840.dts;boards/nrf9160dk_nrf9160_ns.overlay
    Call Stack (most recent call first):
    C:/Nordic1/v2.5.0/zephyr/cmake/modules/dts.cmake:226 (zephyr_dt_preprocess)
    C:/Nordic1/v2.5.0/zephyr/cmake/modules/zephyr_default.cmake:129 (include)
    C:/Nordic1/v2.5.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
    C:/Nordic1/v2.5.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
    CMakeLists.txt:8 (find_package)


    -- Configuring incomplete, errors occurred!
    FATAL ERROR: command exited with status 1: 'C:\Nordic1\toolchains\c57af46cb7\opt\bin\cmake.EXE' -DWEST_PYTHON=C:/Nordic1/toolchains/c57af46cb7/opt/bin/python.exe '-Bc:\Nordic1\test_n160\central_uart_n9160\build' -GNinja -DBOARD=nrf21540dk_nrf52840 -DNCS_TOOLCHAIN_VERSION:STRING=NONE -DCONF_FILE:STRING=c:/Nordic1/test_n160/central_uart_n9160/prj.conf -DDTC_OVERLAY_FILE:STRING=boards/nrf9160dk_nrf9160_ns.overlay '-DBOARD_ROOT:STRING=c:/nordic1/test/peripheral_uart;c:/nordic1/test/ble_prototype;c:/nordic1/test/i2c_api;c:/nordic1/test_n160/asset_tracker_v2_n9160;c:/nordic1/test_n160/central_uart_n9160;.' '-Sc:\Nordic1\test_n160\central_uart_n9160'

    * The terminal process terminated with exit code: 1.
    * Terminal will be reused by tasks, press any key to close it.

  • The build of hci_lpuart failed similar to all others. What am I missing.? it seems ...dts_ord... is always undefined on my system. is there something I need to set somehwre?

    [167/172] Linking C executable zephyr\zephyr_pre0.elf
    FAILED: zephyr/zephyr_pre0.elf zephyr/zephyr_pre0.map
    cmd.exe /C "cd . && C:\Nordic1\toolchains\c57af46cb7\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-gcc.exe -gdwarf-4 @CMakeFiles\zephyr_pre0.rsp -o zephyr\zephyr_pre0.elf && cmd.exe /C "cd /D C:\Nordic1\test\hci_lpuart\build\zephyr && C:\Nordic1\toolchains\c57af46cb7\opt\bin\cmake.exe -E true""
    c:/nordic1/toolchains/c57af46cb7/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: app/libapp.a(main.c.obj): in function `uart_irq_tx_ready':
    C:\Nordic1\v2.5.0\zephyr\include\zephyr\drivers\uart.h:939: undefined reference to `__device_dts_ord_107'
    c:/nordic1/toolchains/c57af46cb7/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: app/libapp.a(main.c.obj): in function `z_impl_uart_irq_tx_disable':
    C:\Nordic1\v2.5.0\zephyr\include\zephyr\drivers\uart.h:904: undefined reference to `__device_dts_ord_107'
    c:/nordic1/toolchains/c57af46cb7/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: app/libapp.a(main.c.obj): in function `uart_fifo_read':
    C:\Nordic1\v2.5.0\zephyr\include\zephyr\drivers\uart.h:820: undefined reference to `__device_dts_ord_107'
    c:/nordic1/toolchains/c57af46cb7/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: app/libapp.a(main.c.obj): in function `hci_uart_init':
    C:\Nordic1\v2.5.0\zephyr\samples\bluetooth\hci_uart\src\main.c:342: undefined reference to `__device_dts_ord_107'
    c:/nordic1/toolchains/c57af46cb7/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: app/libapp.a(main.c.obj): in function `rx_isr':
    C:\Nordic1\v2.5.0\zephyr\samples\bluetooth\hci_uart\src\main.c:193: undefined reference to `__device_dts_ord_107'
    c:/nordic1/toolchains/c57af46cb7/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: app/libapp.a(main.c.obj):C:\Nordic1\v2.5.0\zephyr\samples\bluetooth\hci_uart\src\main.c:403: more undefined references to `__device_dts_ord_107' follow
    collect2.exe: error: ld returned 1 exit status
    ninja: build stopped: subcommand failed.
    FATAL ERROR: command exited with status 1: 'C:\Nordic1\toolchains\c57af46cb7\opt\bin\cmake.EXE' --build 'c:\Nordic1\test\hci_lpuart\build'

    * The terminal process terminated with exit code: 1.
    * Terminal will be reused by tasks, press any key to close it.

  • Sorry, I'm puzzled as to why it's failing on your end. Initially, I suspected that some files in the SDK might have been corrupted or altered. However, since you were able to successfully build the gateway sample, it doesn't seem likely that this is the issue.

    Did you build the hci_lpuart sample for the 'nrf9160dk_nrf52840' board? 

      

  • yes I used nrf9160dk_nrf52840 and it's overlays. I think the problem is with the device tree. googling around others have seen a similar error but I do not see how to fix it. I can build other examples for the nRF52 and the nRF9160 (blinky, buttons). I will remove the hci_lpuart and try the entire process again.

  • I repeated the entire process and got the same error. I am stuck here. How do I move forward. I will repeat the process for the central application you sent me.

  • https://docs.zephyrproject.org/latest/build/dts/troubleshooting.html

    undefined reference to __device_dts_ord_<N>

    This usually happens on a line like this:

    const struct device *dev = DEVICE_DT_GET(NODE_ID);
    

    does this make any sense to you or help solve the problem?
Reply Children
  • C:\Nordic1\test_n160\central_uart\build\zephyr\include\generated\syscalls\uart.h:230: undefined reference to `__device_dts_ord_118'

    from devicetree_generated.h

    118 /soc/peripheral@40000000/uart@a000/nrf-sw-lpuart

    so where does this get set. the note says it is not being set. do I need to add this to an alias file somehow? How come it is set in your build. This is the unzipped central file you sent me with no changes.

  • I also see the following in autoconfig.h. Where does that get defined. I do not

    #define CONFIG_DT_HAS_NORDIC_NRF_SW_LPUART_ENABLED 1
  • I see a definition in overlay file. what is missing? do I need an alias statement or something?


    &uart2 {
    current-speed = <1000000>;
    status = "okay";
    /delete-property/ hw-flow-control;

    pinctrl-0 = <&uart2_default_alt>;
    pinctrl-1 = <&uart2_sleep_alt>;
    pinctrl-names = "default", "sleep";
    lpuart: nrf-sw-lpuart {
    compatible = "nordic,nrf-sw-lpuart";
    status = "okay";
    req-pin = <21>; /* <&interface_to_nrf52840 3 0>; */
    rdy-pin = <19>; /* <&interface_to_nrf52840 2 0>; */
    };
    };

  • Vidor: I found the problem Burt helped in determining that I needed to do a pristine build as soon as I created the build configuration. I was assuming that the first build would be pristine. the pristine build worked on hci_lpuart and I flashed it into the nRF52840. The pristine worked on central_uart that you sent me. I flashed it into the nrf9160 and all is working below is an example of messages seen on the nrf9160. The nrf52DK board is running uart_peripheral. I have a temp/humidity sensor connected that is sending data every 10 seconds. I see this on the nrf9160 console. I can also send commands over to the nRF52 board. All is good. Let me play with this for a few days and see if all problems are eliminated. Thanks for your patience and you help. my rookie mistake not using pristine first.

    *** Booting nRF Connect SDK v2.5.0 ***
    Starting Bluetooth Central UART example
    T: 25.26 H: 51.50
    T: 25.27 H: 51.46
    T: 25.27 H: 51.48
    T: 25.27 H: 51.51
    T: 25.27 H: 51.50
    T: 25.26 H: 51.54
    T: 25.26 H: 51.50
    T: 25.26 H: 51.57

  • It's great to hear that you've successfully built the projects now. 

    Timothy said:
    I was assuming that the first build would be pristine.

    If there is no existing 'build' folder in the project at the time of the first build, it should be same as performing a pristine build. So, I'm unsure why you encountered these build errors in the first place (I didn't include my build folder in the .zip). Despite multiple attempts, I have not been able to reproduce these errors on my end. 

    A pristine or clean build is necessary when adding new overlay files to a project, as CMake will not detect the new overlays otherwise.

    Timothy said:

    This usually happens on a line like this:

    const struct device *dev = DEVICE_DT_GET(NODE_ID);
    

    does this make any sense to you or help solve the problem?

    Yes, the issue in our case was that relevant configurations from the overlay files in central_build/boards/nrf9160dk_nrf9160_ns* were not being applied.

Related