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.

  • I'm afraid I don't have an explanation for why it is failing to build now. I had a coworker try the same project I uploaded here, and he couldn't reproduce the issue either. 

    Here's a screenshot of what I'm seeing after building the project for comparison:

    But did you try with the Cellular: LTE Sensor Gateway sample? As mentioned earlier, I took must of my changes from that project, so it would be interesting to know if it results in the same errors or not.

  • I get similar messages if I just build the LTE App unchanged.

  • I started from scratch. I unzipped your file and opened existing application and rebuilt the application. I still get the errors. below is my screen shot similar to yours.  what am I doing wrong or missing?

  • I did get LTE_BLE_GATEWAY allpication to build and run. The output is what is shown below.

    *** Booting nRF Connect SDK v2.5.0 ***Resetting system
    [00:00:00.251,770] <inf> lte_ble_gw: LTE Sensor Gateway sample started
    [00:00:00.251,953] <inf> lte_ble_gw: Initializing Bluetooth..
    [00:00:00.499,328] <inf> lte_ble_gw: Establishing LTE link (this may take some time) ...
    ASSERTION FAIL [err == 0] @ WEST_TOPDIR/zephyr/subsys/bluetooth/host/hci_core.c:338
    command opcode 0x0c03 timeout with err -11
    [00:00:10.262,481] <err> os: r0/a1: 0x00000003 r1/a2: 0x00000000 r2/a3: 0x00000002
    [00:00:10.262,512] <err> os: r3/a4: 0x2000d218 r12/ip: 0x00000010 r14/lr: 0x000102b5
    [00:00:10.262,512] <err> os: xpsr: 0x41000000
    [00:00:10.262,542] <err> os: Faulting instruction address (r15/pc): 0x000102c0
    [00:00:10.262,573] <err> os: >>> ZEPHYR FATAL ERROR 3: Kernel oops on CPU 0
    [00:00:10.262,603] <err> os: Current thread: 0x2000f7e0 (unknown)
    *** Booting nRF Connect SDK v2.5.0 ***Resetting system

  • Timothy said:
    ASSERTION FAIL [err == 0] @ WEST_TOPDIR/zephyr/subsys/bluetooth/host/hci_core.c:338
    command opcode 0x0c03 timeout with err -11

    The assertion displayed when you programmed the gateway sample indicates that the Bluetooth host on the nRF9160 is failing to communicate with the Bluetooth controller on the nRF52840. Did you remember to program the controller?

    Vidar Berg said:
    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 

    Do you know what was done differently this time as you managed to build the LTE_BLE_GATEWAY without the errors mentioned earlier? I can't see any reason why you would be able to build this sample, but not the one I uploaded, given that the BLE configurations should be the same in both cases.

Reply Children
  • I think I understand what you are trying to say. The nrf9160 has a programmed flashed in that device. what is that program? the nrf%2840 on the DK board has a separate program flashed in that part. What is that program and how do I program the nRF52840 on the nRF9160 DK board? Thanks for your help.

  • The nRF9160 runs the Bluetooth host (i.e., the upper layers of the Bluetooth stack) and the application code, while the nRF52840 chip on the same nRF9160 DK board is supposed to run the Bluetooth controller firmware (Bluetooth: HCI low power UART) to enable the BLE connectivity since the 9160 doesn't have its own BLE RADIO.

    The nRF52840 must be programmed separately with the FW build from the Bluetooth: HCI low power UART project.

  • Vidor thanks for the quick response.

    so is C:\Nordic1\v2.5.0\nrf\samples\bluetooth\hci_lpuart the project that gets flashed into the nRF52840 on the nRF9160 DK board? I will flash that into the nRF52840 using the SW10 switch in the nRF52 position.

    what application is flashed into the nRF9160? is that the centarl_uart you sent me that I cannot get to build yet or some other from the list of samples?

  • No problem. Yes, "C:\Nordic1\v2.5.0\nrf\samples\Bluetooth\hci_lpuart" is the project you want to flash to the nRF52840.

    what application is flashed into the nRF9160? is that the centarl_uart you sent me that I cannot get to build yet or some other from the list of samples?

    Correct. The central UART sample I provided should be programmed to the nRF9160. If everything works it should try to connect to your nRF52 DK board programmed with the Peripheral UART example.

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

Related