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 had left out the second overlay file. It does build a configuration file now but when I go to build it I get the following errors. I am still missing something. any ideas?

    [291/298] 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_n160\central_uart_n9160\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: zephyr/drivers/bluetooth/libdrivers__bluetooth.a(h4.c.obj): in function `uart_irq_rx_disable':
    C:\Nordic1\test_n160\central_uart_n9160\build\zephyr\include\generated\syscalls\uart.h:278: undefined reference to `__device_dts_ord_118'
    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: zephyr/drivers/bluetooth/libdrivers__bluetooth.a(h4.c.obj): in function `z_impl_uart_irq_rx_enable':
    C:\Nordic1\v2.5.0\zephyr\include\zephyr\drivers\uart.h:960: undefined reference to `__device_dts_ord_118'
    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: zephyr/drivers/bluetooth/libdrivers__bluetooth.a(h4.c.obj): in function `uart_irq_tx_disable':
    C:\Nordic1\test_n160\central_uart_n9160\build\zephyr\include\generated\syscalls\uart.h:230: undefined reference to `__device_dts_ord_118'
    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: zephyr/drivers/bluetooth/libdrivers__bluetooth.a(h4.c.obj): in function `h4_send':
    C:\Nordic1\v2.5.0\zephyr\drivers\bluetooth\hci\h4.c:490: undefined reference to `__device_dts_ord_118'
    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: zephyr/drivers/bluetooth/libdrivers__bluetooth.a(h4.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_118'
    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: zephyr/drivers/bluetooth/libdrivers__bluetooth.a(h4.c.obj):C:\Nordic1\v2.5.0\zephyr\drivers\bluetooth\hci\h4.c:560: more undefined references to `__device_dts_ord_118' 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_n160\central_uart_n9160\build'

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

  • Not sure what I'm missing, but it should not have been neccessary to add the overlay manually. As I test, can you try to remove the build folder, then set up the build configuration again, but this time with the board revision set to 1.1.0?

    Edit: the "\hci\h4.c:560: more undefined references to `__device_dts_ord_118' follow" error likely means the CONFIG_NRF_SW_LPUART symbol did not get enabled in your build. It should habe been enabled by the central_uart/boards/nrf9160dk_nrf9160_ns.conf file.

  • errors now are shown below. A different undefined.  I was hoping the sample Bluetooth/central_uart would be the simple way to connect to the Bluetooth/peripheral_uart but that does not seem to work.

    what am I missing?

    zephyr/CMakeFiles/offsets.dir/./arch/arm/core/offsets/offsets.c.obj -L"c:/nordic1/toolchains/c57af46cb7/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/thumb/v8-m.main/nofp" -LC:/Nordic1/test_n160/central_uart_n9160/build/zephyr -lgcc zephyr/arch/common/libisr_tables.a -mcpu=cortex-m33 -mthumb -mabi=aapcs -mfp16-format=ieee -Wl,--gc-sections -Wl,--build-id=none -Wl,--sort-common=descending -Wl,--sort-section=alignment -Wl,-u,_OffsetAbsSyms -Wl,-u,_ConfigAbsSyms -nostdlib -static -Wl,-X -Wl,-N -Wl,--orphan-handling=warn -Wl,-no-pie -DPICOLIBC_INTEGER_PRINTF_SCANF C:/Nordic1/v2.5.0/nrfxlib/crypto/nrf_cc310_platform/lib/cortex-m33/soft-float/no-interrupts/libnrf_cc310_platform_0.9.18.a --specs=picolibc.specs -lc -lgcc && cmd.exe /C "cd /D C:\Nordic1\test_n160\central_uart_n9160\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: zephyr/drivers/bluetooth/libdrivers__bluetooth.a(h4.c.obj): in function `uart_irq_rx_disable':
    C:\Nordic1\test_n160\central_uart_n9160\build\zephyr\include\generated\syscalls\uart.h:278: undefined reference to `__device_dts_ord_123'
    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: zephyr/drivers/bluetooth/libdrivers__bluetooth.a(h4.c.obj): in function `z_impl_uart_irq_rx_enable':
    C:\Nordic1\v2.5.0\zephyr\include\zephyr\drivers\uart.h:960: undefined reference to `__device_dts_ord_123'
    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: zephyr/drivers/bluetooth/libdrivers__bluetooth.a(h4.c.obj): in function `uart_irq_tx_disable':
    C:\Nordic1\test_n160\central_uart_n9160\build\zephyr\include\generated\syscalls\uart.h:230: undefined reference to `__device_dts_ord_123'
    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: zephyr/drivers/bluetooth/libdrivers__bluetooth.a(h4.c.obj): in function `h4_send':
    C:\Nordic1\v2.5.0\zephyr\drivers\bluetooth\hci\h4.c:490: undefined reference to `__device_dts_ord_123'
    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: zephyr/drivers/bluetooth/libdrivers__bluetooth.a(h4.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_123'
    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: zephyr/drivers/bluetooth/libdrivers__bluetooth.a(h4.c.obj):C:\Nordic1\v2.5.0\zephyr\drivers\bluetooth\hci\h4.c:560: more undefined references to `__device_dts_ord_123' 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_n160\central_uart_n9160\build'

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

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

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

Related