Problems that occur when changing the beacon program to host_only

I am a beginner in BLE and I want to use one nrf52840 as host and one nrf52832 as controller to learn HCI UART. In nrf52832 I flash the hci_uart program in the zephyr routine, and in nrf52840 I want to change the beacon program to host_only, but the compilation error occurs. I added the 

CONFIG_BT_HCI=y
CONFIG_BT_CTLR=n
CONFIG_BT_H4=y

code to the prj-coex.conf file, and VScode provides the following error output:

[108/174] Building C object zephyr/drivers/bluetooth/CMakeFiles/drivers__bluetooth.dir/hci/h4.c.obj
FAILED: zephyr/drivers/bluetooth/CMakeFiles/drivers__bluetooth.dir/hci/h4.c.obj
C:\ncs\toolchains\cf2149caf2\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-gcc.exe -DKERNEL -DNRF52840_XXAA -DPICOLIBC_LONG_LONG_PRINTF_SCANF -D_FORTIFY_SOURCE=1 -D_POSIX_C_SOURCE=200809 -D__LINUX_ERRNO_EXTENSIONS__ -D__PROGRAM_START -D__ZEPHYR_SUPERVISOR__ -D__ZEPHYR__=1 -IC:/ncs/v2.6.0/zephyr/subsys/bluetooth -IC:/ncs/v2.6.0/zephyr/include -IC:/myapps/beacon/build/zephyr/include/generated -IC:/ncs/v2.6.0/zephyr/soc/arm/nordic_nrf/nrf52 -IC:/ncs/v2.6.0/zephyr/soc/common/nordic_nrf/. -IC:/ncs/v2.6.0/zephyr/soc/arm/nordic_nrf/common/. -IC:/ncs/v2.6.0/nrf/include -IC:/ncs/v2.6.0/nrf/tests/include -IC:/ncs/v2.6.0/modules/hal/cmsis/CMSIS/Core/Include -IC:/ncs/v2.6.0/zephyr/modules/cmsis/. -IC:/ncs/v2.6.0/modules/hal/nordic/nrfx -IC:/ncs/v2.6.0/modules/hal/nordic/nrfx/drivers/include -IC:/ncs/v2.6.0/modules/hal/nordic/nrfx/mdk -IC:/ncs/v2.6.0/zephyr/modules/hal_nordic/nrfx/. -IC:/ncs/v2.6.0/modules/debug/segger/SEGGER -IC:/ncs/v2.6.0/modules/debug/segger/Config -IC:/ncs/v2.6.0/modules/crypto/tinycrypt/lib/include -IC:/ncs/v2.6.0/nrfxlib/softdevice_controller/include -isystem C:/ncs/v2.6.0/zephyr/lib/libc/common/include -isystem C:/ncs/v2.6.0/nrfxlib/crypto/nrf_cc310_platform/include -Wshadow -fno-strict-aliasing -Os -imacros C:/myapps/beacon/build/zephyr/include/generated/autoconf.h -fno-printf-return-value -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m4 -mthumb -mabi=aapcs -mfp16-format=ieee -mtp=soft --sysroot=C:/ncs/toolchains/cf2149caf2/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi -imacros C:/ncs/v2.6.0/zephyr/include/zephyr/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -Werror=implicit-int -fno-pic -fno-pie -fno-asynchronous-unwind-tables -ftls-model=local-exec -fno-reorder-functions --param=min-pagesize=0 -fno-defer-pop -fmacro-prefix-map=C:/myapps/beacon=CMAKE_SOURCE_DIR -fmacro-prefix-map=C:/ncs/v2.6.0/zephyr=ZEPHYR_BASE -fmacro-prefix-map=C:/ncs/v2.6.0=WEST_TOPDIR -ffunction-sections -fdata-sections --specs=picolibc.specs -std=c99 -MD -MT zephyr/drivers/bluetooth/CMakeFiles/drivers__bluetooth.dir/hci/h4.c.obj -MF zephyr\drivers\bluetooth\CMakeFiles\drivers__bluetooth.dir\hci\h4.c.obj.d -o zephyr/drivers/bluetooth/CMakeFiles/drivers__bluetooth.dir/hci/h4.c.obj -c C:/ncs/v2.6.0/zephyr/drivers/bluetooth/hci/h4.c
In file included from C:/ncs/v2.6.0/zephyr/include/zephyr/toolchain/gcc.h:98,
from C:/ncs/v2.6.0/zephyr/include/zephyr/toolchain.h:50,
from C:/ncs/v2.6.0/zephyr/include/zephyr/kernel_includes.h:23,
from C:/ncs/v2.6.0/zephyr/include/zephyr/kernel.h:17,
from C:/ncs/v2.6.0/zephyr/drivers/bluetooth/hci/h4.c:12:
C:/ncs/v2.6.0/zephyr/include/zephyr/device.h:89:41: error: '__device_dts_ord_114' undeclared here (not in a function); did you mean '__device_dts_ord_14'?
89 | #define DEVICE_NAME_GET(dev_id) _CONCAT(__device_, dev_id)
| ^~~~~~~~~
C:/ncs/v2.6.0/zephyr/include/zephyr/toolchain/common.h:137:26: note: in definition of macro '_DO_CONCAT'
137 | #define _DO_CONCAT(x, y) x ## y
| ^
C:/ncs/v2.6.0/zephyr/include/zephyr/device.h:89:33: note: in expansion of macro '_CONCAT'
89 | #define DEVICE_NAME_GET(dev_id) _CONCAT(__device_, dev_id)
| ^~~~~~~
C:/ncs/v2.6.0/zephyr/include/zephyr/device.h:216:37: note: in expansion of macro 'DEVICE_NAME_GET'
216 | #define DEVICE_DT_NAME_GET(node_id) DEVICE_NAME_GET(Z_DEVICE_DT_DEV_ID(node_id))
| ^~~~~~~~~~~~~~~
C:/ncs/v2.6.0/zephyr/include/zephyr/device.h:233:34: note: in expansion of macro 'DEVICE_DT_NAME_GET'
233 | #define DEVICE_DT_GET(node_id) (&DEVICE_DT_NAME_GET(node_id))
| ^~~~~~~~~~~~~~~~~~
C:/ncs/v2.6.0/zephyr/drivers/bluetooth/hci/h4.c:74:44: note: in expansion of macro 'DEVICE_DT_GET'
74 | static const struct device *const h4_dev = DEVICE_DT_GET(DT_CHOSEN(zephyr_bt_uart));
| ^~~~~~~~~~~~~
[117/174] Building C object zephyr/drivers/serial/CMakeFiles/drivers__serial.dir/uart_nrfx_uarte.c.obj
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: 'C:\ncs\toolchains\cf2149caf2\opt\bin\cmake.EXE' --build 'c:\myapps\beacon\build'

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

  • Hi, 
    How did you configure the device tree ? 
    Could you try adding this overlay: 

    &uart0 {
    	current-speed = <1000000>;
    	hw-flow-control;
    };
    / {
       chosen {
            zephyr,bt-uart = &uart0;
       };
    };


    To add an overlay you create a boards folder then add the overlay file there (for example nrf52840dk_nrf52840.overlay)

  • Yes, I have finished the configuration of the device tree, when bt-uart is configured to uart0, there is no problem compiling, when this configuration option is uart1, there is an error compiling. Here is my overlay file: 

    /{
        coex_gpio: coex {
            compatible = "gpio-radio-coex";
            grant-gpios = <&gpio1 0 (GPIO_PULL_DOWN | GPIO_ACTIVE_LOW)>;
            grant-delay-us = <150>;
        };
    };
    
    &radio {
        coex = <&coex_gpio>;
    };
    
    
    / {
       chosen {
            zephyr,console = &uart0;
            zephyr,shell-uart = &uart0;
            zephyr,bt-uart = &uart1;
       };
    };

    By the way, when bt-uart is set to uart0, the nrf52832 and nrf52840 uart0 are connected, but the beacon program is not running correctly. Since uart0 is connected to the interface MCU, is it necessary to change the hardware when using uart0 as the HCI interface?
  • Hi, 
    If you want to use uart1, you would need to turn it on by setting the status to okay. Something like this: 

    &uart1 {
        compatible = "nordic,nrf-uarte";
        status = "okay";
        current-speed = <115200>;
        pinctrl-0 = <&uart1_default>;
        pinctrl-1 = <&uart1_sleep>;
        pinctrl-names = "default", "sleep";
    };
    / {
        chosen {
             zephyr,bt-uart = &uart1;
        };
     };
  • Thank you for your response.

     I have configured bt-uart as uart0. Due to previous issues mentioned, I am using BlueZ to verify the connection between the controller and the host. Testing shows that the controller runs well and BlueZ communicates well with the controller. I am using the nRF52840 as the controller, but according to the datasheet, the pins for uart0 are P0.06 and P0.08. When I tried to capture data on uart0 during communication, I found that there was no signal on P0.06 and P0.08. Why is this happening? How can I see the data being transmitted over the HCI interface?

  • Hi, 
    They should have the signals on P0.06 and P0.08. Did you connect to the P0.06 and P0.08 on the header ?
    I would suggest to try testing with some simple UART sample that output on UART0. You can try to modify the dts file to output on other pins for testing. 

Related