I am a trying to learn about nrf5340-DK and its working with BLE, I want to connect my board with a smartphone(using nrf connect app), searched related issue on Nordic Semicondutor community support. In this example, I just want the device to show up in the nrf connect app and from there, I will build upon it but I am getting an error on my UART log prints can be tracked from the prints in code below.
*** Booting nRF Connect SDK v2.9.1-60d0d6c8d42d ****** Booting nRF Connect SDK v2.9.1-60d0d6c8d42d ***
*** Using Zephyr OS v3.7.99-ca954a6216c9 ****** Using Zephyr OS v3.7.99-ca954a6216c9 ***
Starting BLE Beacon example
Starting BLE Beacon example
bt_hci_driver: Endpoint binding failed with -11[00:00:01.664,000] <err> bt_hci_driver: Endpoint binding failed with -11
bt_hci_core: HCI driver open failed (-11)[00:00:01.678,200] <err> bt_hci_core: HCI driver open failed (-11)
BbtBluetooth init failed (err -11)Bluetooth init failed (err -11)
Here is the code I am trying.
#include <zephyr/kernel.h>
#include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/bluetooth/hci.h>
#include <zephyr/bluetooth/conn.h>
#include <zephyr/bluetooth/uuid.h>
#include <zephyr/bluetooth/gatt.h>
#define DEVICE_NAME "nRF5340-Demo"
#define DEVICE_NAME_LEN (sizeof(DEVICE_NAME) - 1)
/* Advertising data */
static const struct bt_data ad[] = {
BT_DATA_BYTES(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)),
BT_DATA(BT_DATA_NAME_COMPLETE, DEVICE_NAME, DEVICE_NAME_LEN),
};
/* Callback for Bluetooth initialization */
static void bt_ready(int err)
{
if (err) {
printk("Bluetooth init failed (err %d)\n", err);
return;
}
printk("Bluetooth initialized\n");
/* Start advertising */
err = bt_le_adv_start(BT_LE_ADV_NCONN, ad, ARRAY_SIZE(ad), NULL, 0);
if (err) {
printk("Advertising failed to start (err %d)\n", err);
return;
}
printk("Advertising successfully started\n");
}
int main(void)
{
int err;
printk("Starting BLE Beacon example\n");
/* Initialize the Bluetooth Subsystem */
err = bt_enable(bt_ready);
if (err) {
printk("Bluetooth init failed (err %d)\n", err);
return;
}
while (1) {
k_sleep(K_SECONDS(1));
}
}
prj.conf
CONFIG_BT=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_DEVICE_NAME="nRF5340-Demo"
CONFIG_LOG=y
CONFIG_LOG_MODE_IMMEDIATE=y
# CONFIG_BT_DEBUG_LOG=y
CONFIG_BT_DEBUG_MONITOR_UART=y
CONFIG_BT_EXT_ADV=y
Have you programmed the network core with anything? If so, what? Also have you configured sysbuild to include the network core image in the build?
I can't gather much info regarding your setup or toolchain from your post, but I'll provide some basic explanation behind my questions below.
From a high level, the Bluetooth stack consists of a Host and a Controller (the controller can be thought of as the lower level of the two, as it encompasses the physical and link layers).
Now the nRF5340 is a dual-core module (the cores are referred to as the application core and network core - check out the datasheet for more details). A relatively straightforward implementation of the Bluetooth stack is to implement the Controller on the network core and the Host on the application core and use a HCI (Host-Controller Interface) to communicate between the two. Nordic helps us out a lot by providing all these pieces through samples (here's the documentation for better, clearer details).
The error you're seeing indicates the host (which I'm assuming is running on your application core) is not receiving its expected response from the controller within the expected timeframe.
If the prj.conf
you provided is the extent of your entire project's configuration, then you're likely missing a few pieces. Additionally, versions of NCS newer than 2.7.0 (your logs indicate you're using v2.9.1) use sysbuild as their default build system, which does a lot of heavy lifting in managing multiple images within a single project (which is the case for BT samples on the nRF5340) but also comes with its own set of configurations, which would be set in a file called sysbuild.conf
.
I don't have much context on your particular situation or your level of experience, but just to throw it out there - if you're unfamiliar with NCS, I'd highly recommend taking Nordic's (FREE) DevAcademy courses. They're pretty short and give you a great starting point for using their toolchain and even cover the fundamentals of networking stacks such as Bluetooth.