bt_hci_driver: Endpoint binding failed with -11

I'm developing software for the nRF5340 based on the NCS 3.2.4 "hello world" example.
Adding bt_enable() returns error code -11.
Please tell me how to implement bt_enable() so that it completes correctly.
The source code is as follows:

prj.conf

CONFIG_LOG=y
CONFIG_USE_SEGGER_RTT=y

CONFIG_BT=y
CONFIG_BT_DEVICE_NAME="Thingy91X"
CONFIG_BT_CENTRAL=y

CONFIG_BT_SCAN=y
CONFIG_BT_SCAN_FILTER_ENABLE=y
CONFIG_BT_SCAN_UUID_CNT=1


main.c
#include <stdio.h>
#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
#include <zephyr/bluetooth/bluetooth.h>
#include <bluetooth/scan.h>

#define DEVICE_NAME	CONFIG_BT_DEVICE_NAME
#define DEVICE_NAME_LEN (sizeof(DEVICE_NAME) - 1)

#define TARGET_DEVICE_NAME "nRF54L15"
#define TARGET_DEVICE_NAME_LEN (sizeof(TARGET_DEVICE_NAME) - 1)

static void scan_filter_match(struct bt_scan_device_info *device_info,
			      struct bt_scan_filter_match *filter_match, bool connectable)
{
	char addr[BT_ADDR_LE_STR_LEN];

	bt_addr_le_to_str(device_info->recv_info->addr, addr, sizeof(addr));

	printk("Filters matched. Address: %s connectable: %d\n", addr, connectable);
}

static void scan_filter_no_match(struct bt_scan_device_info *device_info, bool connectable)
{
#if 0
	char addr[BT_ADDR_LE_STR_LEN];

	bt_addr_le_to_str(device_info->recv_info->addr, addr, sizeof(addr));
#endif
}

static void scan_connecting_error(struct bt_scan_device_info *device_info)
{
	printk("Connecting failed\n");
}

BT_SCAN_CB_INIT(scan_cb, scan_filter_match, scan_filter_no_match, scan_connecting_error, NULL);

static int scan_init(void)
{
	int err;
	struct bt_le_scan_param scan_param = {
		.type = BT_LE_SCAN_TYPE_PASSIVE,
		.options = BT_LE_SCAN_OPT_FILTER_DUPLICATE,
		.interval = 0x0010,
		.window = 0x0010,
	};

	struct bt_scan_init_param scan_init_param = {
		.connect_if_match = true, .scan_param = &scan_param, .conn_param = NULL
	};

	bt_scan_init(&scan_init);
	bt_scan_cb_register(&scan_cb);

	err = bt_scan_filter_add(BT_SCAN_FILTER_TYPE_NAME, TARGET_DEVICE_NAME);
	if (err) {
		printk("bt_scan_filter_add() = %d\n", err);
		return err;
	}

	err = bt_scan_filter_enable(BT_SCAN_UUID_FILTER, false);
	if (err) {
		printk("bt_scan_filter_enable() = %d\n", err);
		return err;
	}

	return 0;
}

static int scan_start(void)
{
	int err;

	err = bt_scan_start(BT_SCAN_TYPE_SCAN_PASSIVE);
	if (err) {
		printk("bt_scan_start() = %d\n", err);
		return err;
	}

	return 0;
}

int main(void)
{
	int err;

#if 1
	err = bt_enable(NULL);
	if (err) {
		printk("bt_enable() = %d\n", err);
		return 0;
	}

	err = scan_init();
	if (err) {
		printk("scan_init() = %d\n", err);
		return 0;
	}

	err = scan_start();
	if (err) {
		printk("scan_start() = %d\n", err);
		return 0;
	}
#endif

	for(;;) {
		static uint32_t c = 0;
		printk("Hello World! (%d) %s\n", c, CONFIG_BOARD_TARGET);
		c++;
		k_msleep(1000);
	}

	return 0;
}


The following message is displayed in J-Link RTT Viewer V8.92:
00> *** Booting nRF Connect SDK v3.2.4-4c3fc0d44534 ***
00> *** Using Zephyr OS v4.2.99-9673eec75908 ***
00> [00:00:02.251,190] <err> bt_hci_driver: Endpoint binding failed with -11
00> [00:00:02.251,190] <err> bt_hci_core: HCI driver open failed (-11)
00> bt_enable() = -11


Disabling Bluetooth processing (changing `#if` on line 88 to 0) allows it to work correctly.
00> *** Booting nRF Connect SDK v3.2.4-4c3fc0d44534 ***
00> *** Using Zephyr OS v4.2.99-9673eec75908 ***
00> Hello World! (0) nrf5340dk/nrf5340/cpuapp
00> Hello World! (1) nrf5340dk/nrf5340/cpuapp
00> Hello World! (2) nrf5340dk/nrf5340/cpuapp
00> Hello World! (3) nrf5340dk/nrf5340/cpuapp


The procedure for writing is as follows:
C:\ncs\applications\hello_world_v3-2-4_rev2\build>nrfutil device recover --core Network
v Recovered 960033963
nrfutil device recover
v Recovered 960033963
nrfutil device erase --core Network
v Erased 960033963
nrfutil device erase
v Erased 960033963
nrfutil device program --firmware merged.hex
[00:00:01] ###### 100% [3/3 960033963] Programmed
nrfutil device reset
v Reset was applied to 960033963


Is build/merged.hex an image where Application and Network are combined?

Parents Reply Children
  • And you are only having this problem with this particular project? Have you tested with any of the SDK samples? Do you have any build logs? 

  • I've attached the build log.
    I also tried other sample projects (peripheral_lbs and central_bas), but they also returned -11 when I called bt_enable().
    I prepared a new PC and reinstalled everything from scratch, but the situation hasn't changed. I have two Thingy91X units, and both have the same problem.

     *  Executing task: nRF Connect: Build [pristine]: hello_world_v3-3-0/build 
    
    Building hello_world_v3-3-0
    west build --build-dir c:/Works/nRF/hello_world_v3-3-0/build c:/Works/nRF/hello_world_v3-3-0 --pristine --board nrf5340dk/nrf5340/cpuapp/ns -- -DDEBUG_THREAD_INFO=On -DCONFIG_DEBUG_THREAD_INFO=y -Dhello_world_v3-3-0_DEBUG_THREAD_INFO=On
    
    -- west build: generating a build system
    Loading Zephyr module(s) (Zephyr base): sysbuild_default
    -- Found Python3: C:/ncs/toolchains/936afb6332/opt/bin/python.exe (found suitable version "3.12.4", minimum required is "3.10") found components: Interpreter
    -- Cache files will be written to: C:/ncs/v3.3.0/zephyr/.cache
    -- Found west (found suitable version "1.5.0", minimum required is "0.14.0")
    -- Board: nrf5340dk, qualifiers: nrf5340/cpuapp/ns
    
    warning: Deprecated symbol PARTITION_MANAGER is enabled.
    
    Parsing C:/ncs/v3.3.0/zephyr/share/sysbuild/Kconfig
    Loaded configuration 'C:/Works/nRF/hello_world_v3-3-0/build/_sysbuild/empty.conf'
    Merged configuration 'C:/Works/nRF/hello_world_v3-3-0/build/_sysbuild/empty.conf'
    Configuration saved to 'C:/Works/nRF/hello_world_v3-3-0/build/zephyr/.config'
    Kconfig header saved to 'C:/Works/nRF/hello_world_v3-3-0/build/_sysbuild/autoconf.h'
    -- 
       ****************************************
       * Running CMake for hello_world_v3-3-0 *
       ****************************************
    Loading Zephyr default modules (Zephyr base).
    -- Application: C:/Works/nRF/hello_world_v3-3-0
    -- CMake version: 4.2.1
    -- Found Python3: C:/ncs/toolchains/936afb6332/opt/bin/python.exe (found suitable version "3.12.4", minimum required is "3.10") found components: Interpreter
    -- Cache files will be written to: C:/ncs/v3.3.0/zephyr/.cache
    -- Zephyr version: 4.3.99 (C:/ncs/v3.3.0/zephyr)
    -- Found west (found suitable version "1.5.0", minimum required is "0.14.0")
    -- Board: nrf5340dk, qualifiers: nrf5340/cpuapp/ns
    -- Found host-tools: zephyr 0.17.0 (C:/ncs/toolchains/936afb6332/opt/zephyr-sdk)
    -- Found toolchain: zephyr 0.17.0 (C:/ncs/toolchains/936afb6332/opt/zephyr-sdk)
    -- Found Dtc: C:/ncs/toolchains/936afb6332/opt/bin/dtc.exe (found suitable version "1.4.7", minimum required is "1.4.6")
    -- Found BOARD.dts: C:/ncs/v3.3.0/zephyr/boards/nordic/nrf5340dk/nrf5340dk_nrf5340_cpuapp_ns.dts
    -- Found devicetree overlay: C:/Works/nRF/hello_world_v3-3-0/app.overlay
    -- Generated zephyr.dts: C:/Works/nRF/hello_world_v3-3-0/build/hello_world_v3-3-0/zephyr/zephyr.dts
    -- Generated pickled edt: C:/Works/nRF/hello_world_v3-3-0/build/hello_world_v3-3-0/zephyr/edt.pickle
    -- Generated devicetree_generated.h: C:/Works/nRF/hello_world_v3-3-0/build/hello_world_v3-3-0/zephyr/include/generated/zephyr/devicetree_generated.h
    
    warning: Deprecated symbol PARTITION_MANAGER_ENABLED is enabled.
    
    
    warning: Experimental symbol TFM_EXPERIMENTAL is enabled.
    
    Parsing C:/ncs/v3.3.0/zephyr/Kconfig
    Loaded configuration 'C:/ncs/v3.3.0/zephyr/boards/nordic/nrf5340dk/nrf5340dk_nrf5340_cpuapp_ns_defconfig'
    Merged configuration 'C:/Works/nRF/hello_world_v3-3-0/prj.conf'
    Merged configuration 'C:/Works/nRF/hello_world_v3-3-0/build/hello_world_v3-3-0/zephyr/misc/generated/extra_kconfig_options.conf'
    Merged configuration 'C:/Works/nRF/hello_world_v3-3-0/build/hello_world_v3-3-0/zephyr/.config.sysbuild'
    Configuration saved to 'C:/Works/nRF/hello_world_v3-3-0/build/hello_world_v3-3-0/zephyr/.config'
    Kconfig header saved to 'C:/Works/nRF/hello_world_v3-3-0/build/hello_world_v3-3-0/zephyr/include/generated/zephyr/autoconf.h'
    -- Found GnuLd: c:/ncs/toolchains/936afb6332/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi/bin/ld.bfd.exe (found version "2.38")
    -- The C compiler identification is GNU 12.2.0
    -- The CXX compiler identification is GNU 12.2.0
    -- The ASM compiler identification is GNU
    -- Found assembler: C:/ncs/toolchains/936afb6332/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe
    -- libmetal version: 1.9.0 (C:/Works/nRF/hello_world_v3-3-0)
    -- Build type:  
    -- Host:    Windows/AMD64
    -- Target:  Generic/arm
    -- Machine: arm
    -- Vendor: none
    -- Looking for include file stdatomic.h
    -- Looking for include file stdatomic.h - found
    -- open-amp version: 1.8.0 (C:/ncs/v3.3.0/modules/lib/open-amp/open-amp)
    -- Looking for include file fcntl.h
    -- Host:    Windows/AMD64
    -- Target:  Generic/arm
    -- Machine: arm
    -- C_FLAGS :  -Wall -Wextra
    -- Looking for include file fcntl.h - found
    -- Found gen_kobject_list: C:/ncs/v3.3.0/zephyr/scripts/build/gen_kobject_list.py
    -- Configuring done (44.0s)
    -- Generating done (3.0s)
    -- Build files have been written to: C:/Works/nRF/hello_world_v3-3-0/build/hello_world_v3-3-0
    Dropping partition 'nonsecure_storage' since it is empty.
    CMake Warning at C:/ncs/v3.3.0/nrf/sysbuild/CMakeLists.txt:1150 (message):
    
    
          -----------------------------------------------------------------------------------
          --- WARNING: SB_CONFIG_PARTITION_MANAGER is enabled, partition manager has been ---
          --- deprecated and boards should be updated to use DTS-based partitioning, see  ---
          --- the migration guide for more details on this.                               ---
          -----------------------------------------------------------------------------------
          
    Call Stack (most recent call first):
      cmake/modules/sysbuild_extensions.cmake:808 (nrf_POST_CMAKE)
      cmake/modules/sysbuild_extensions.cmake:808 (cmake_language)
      cmake/modules/sysbuild_images.cmake:46 (sysbuild_module_call)
      cmake/modules/sysbuild_default.cmake:21 (include)
      C:/ncs/v3.3.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:75 (include)
      C:/ncs/v3.3.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
      C:/ncs/v3.3.0/zephyr/share/sysbuild-package/cmake/SysbuildConfig.cmake:8 (include)
      template/CMakeLists.txt:10 (find_package)
    
    
    -- Configuring done (66.5s)
    -- Generating done (0.2s)
    -- Build files have been written to: C:/Works/nRF/hello_world_v3-3-0/build
    -- west build: building application
    [4/327] Generating include/generated/zephyr/version.h
    -- Zephyr version: 4.3.99 (C:/ncs/v3.3.0/zephyr), build: ncs-v3.3.0
    [10/327] Generating ../../tfm/CMakeCache.txt
    -- Found Git: C:/ncs/toolchains/936afb6332/mingw64/bin/git.exe (found version "2.52.0.windows.1")
    -- The C compiler identification is GNU 12.2.0
    -- The CXX compiler identification is GNU 12.2.0
    -- The ASM compiler identification is GNU
    -- Found assembler: C:/ncs/toolchains/936afb6332/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc.exe
    -- Found Python3: C:/ncs/toolchains/936afb6332/opt/bin/python.exe (found version "3.12.4") found components: Interpreter
    -- Found Python3: C:/ncs/toolchains/936afb6332/opt/bin/python.exe (found suitable version "3.12.4", minimum required is "3.10") found components: Interpreter
    -- Cache files will be written to: C:/ncs/v3.3.0/zephyr/.cache
    CMake Warning (dev) at C:/ncs/v3.3.0/nrf/modules/trusted-firmware-m/tfm_boards/nrf5340_cpuapp/CMakeLists.txt:21 (install):
      Policy CMP0177 is not set: install() DESTINATION paths are normalized.  Run
      "cmake --help-policy CMP0177" for policy details.  Use the cmake_policy
      command to set the policy and suppress this warning.
    This warning is for project developers.  Use -Wno-dev to suppress it.
    
    -- Configuring done (8.6s)
    -- Generating done (0.9s)
    -- Build files have been written to: C:/Works/nRF/hello_world_v3-3-0/build/hello_world_v3-3-0/tfm
    [217/223] Linking C executable bin\tfm_s.axf
    Memory region         Used Size  Region Size  %age Used
               FLASH:       81340 B       256 KB     31.03%
                 RAM:       48280 B       192 KB     24.56%
    [17/327] Performing install step for 'tfm'
    -- Install configuration: "MinSizeRel"
    ----- Installing platform NS -----
    [327/327] Linking C executable zephyr\zephyr.elf
    Memory region         Used Size  Region Size  %age Used
               FLASH:       73976 B       720 KB     10.03%
                 RAM:       25172 B       256 KB      9.60%
            IDT_LIST:          0 GB        32 KB      0.00%
    Generating files from C:/Works/nRF/hello_world_v3-3-0/build/hello_world_v3-3-0/zephyr/zephyr.elf for board: nrf5340dk/nrf5340/cpuapp/ns
    [10/10] Generating ../merged.hex
     *  Terminal will be reused by tasks, press any key to close it.

  • I did not realise you were using the Thingy91x board. This board is not tested and validated with these bluetooth samples and may need someconfiguration changes to work. As a test, please build the peripheral_lbs sample for the nrf5340dk/nrf5340/cpuapp target instead, which is supported, then use nRF connect on iOS or Android to confirm that it becomes discoverable over Bluetooth.

    https://docs.nordicsemi.com/bundle/ncs-latest/page/nrf/samples/bluetooth/peripheral_lbs/README.html

    The only Bluetooth sample tested with the Thingy91x board configuration is the connectivity_bridge application you were using in the other ticket.

Related