Controller hangs when I am trying to connect with Security feature

Hello,

I am adding security feature for BLE in nrf52810 custom board. I am using v2.9.1 toolchain and 2.9.1 sdk files

PFA BLE related file as well as .conf file as well.

I am not sure what is wrong that I am doing. Its going in hard fault.

Can you help me with that? Also let me know if you want any other info.

Thanks,

Chinmay

#include "ble_handle.h"

#include <zephyr/types.h>
#include <zephyr/kernel.h>
#include <zephyr/drivers/uart.h>
#include <zephyr/usb/usb_device.h>

#include <zephyr/device.h>
#include <zephyr/devicetree.h>
#include <soc.h>
#include <zephyr/bluetooth/bluetooth.h>
#include <zephyr/bluetooth/uuid.h>
#include <zephyr/bluetooth/gatt.h>
#include <zephyr/bluetooth/hci.h>

#include <zephyr/logging/log.h>
#include <uart_async_adapter.h>

#include <bluetooth/services/nus.h>
#include "../GPIO_handle/GPIO_handle.h"
#include "../uart_handle/uart_handle.h"
#include "storage_handle.h"
#include "at_cmd_handle.h"

#define LOG_MODULE_NAME BLE
LOG_MODULE_REGISTER(LOG_MODULE_NAME);

#define STACKSIZE 1024
#define PRIORITY 7

K_FIFO_DEFINE(fifo_uart_tx_data);
K_FIFO_DEFINE(fifo_uart_rx_data);

static struct bt_conn *current_conn;
static struct bt_conn *auth_conn;
static struct bt_conn *security_conn;
uint16_t conn_interval;

#ifdef CONFIG_BT_NUS_SECURITY_ENABLED
static void num_comp_reply(bool accept)
{
	if (accept) {
		bt_conn_auth_passkey_confirm(auth_conn);
		//LOG_INF("Numeric Match, conn %p", (void *)auth_conn);
	} else {
		bt_conn_auth_cancel(auth_conn);
		//LOG_INF("Numeric Reject, conn %p", (void *)auth_conn);
	}

	bt_conn_unref(auth_conn);
	auth_conn = NULL;
}

#endif /* CONFIG_BT_NUS_SECURITY_ENABLED */

static K_SEM_DEFINE(ble_init_ok, 0, 1);

static const struct bt_data sd[] = {
	BT_DATA_BYTES(BT_DATA_UUID128_ALL, BT_UUID_NUS_VAL),
};

static char ble_name[MAX_NAME_LEN] = DEFAULT_NAME;

static 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, ble_name, 0), // Length set later
};

void send_ble_data(struct uart_data_t * buf)
{
	if (bt_nus_send(NULL, buf->data, buf->len)) 
	{
		LOG_WRN("Failed to send data over BLE connection");
	}
}


static void bt_receive_cb(struct bt_conn *conn, const uint8_t *const data,
			  uint16_t len)
{
	int err;
	//LOG_INF("Received data from: %s", addr);

	// If in programming mode, treat BLE input as AT command inputx
    if (programming_mode) {
        char at_cmd_buf[50];  // Match size with uart_data_t
        uint16_t copy_len = MIN(len, sizeof(at_cmd_buf) - 1);
        memcpy(at_cmd_buf, data, copy_len);
        at_cmd_buf[copy_len] = '\0';  // Null-terminate string
		//LOG_INF("AT Command received: %s", at_cmd_buf);	
        parse_at_command(at_cmd_buf);
        return;
    }

	// If not in programming mode, send data to UART
	for (uint16_t pos = 0; pos != len;) {
		struct uart_data_t *tx = k_malloc(sizeof(*tx));

		if (!tx) {
			LOG_WRN("Not able to allocate UART send data buffer");
			return;
		}

		/* Keep the last byte of TX buffer for potential LF char. */
		size_t tx_data_size = sizeof(tx->data) - 1;

		if ((len - pos) > tx_data_size) {
			tx->len = tx_data_size;
		} else {
			tx->len = (len - pos);
		}

		memcpy(tx->data, &data[pos], tx->len);

		pos += tx->len;

		/* Append the LF character when the CR character triggered
		 * transmission from the peer.
		 */
		// if ((pos == len) && (data[len - 1] == '\r')) {
		// 	tx->data[tx->len] = '\n';
		// 	tx->len++;
		// }

        uart_data_send(tx);
	}
}

static struct bt_nus_cb nus_cb = {
	.received = bt_receive_cb,
};

#if defined(CONFIG_BT_NUS_SECURITY_ENABLED)
static void auth_passkey_display(struct bt_conn *conn, unsigned int passkey)
{
	char addr[BT_ADDR_LE_STR_LEN];

	bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));

	//printk("Passkey for %s: %06u\n", addr, passkey);
	uart_printk("Passkey for %s: %06u\n", addr, passkey);
	//LOG_INF("Passkey for %s: %06u", addr, passkey);
}

static void auth_passkey_confirm(struct bt_conn *conn, unsigned int passkey)
{
	char addr[BT_ADDR_LE_STR_LEN];

	auth_conn = bt_conn_ref(conn);

	bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));

	//LOG_INF("Passkey for %s: %06u", addr, passkey);

	uart_printk("Confirming passkey %06u for %s\n", passkey, addr);
	if (bt_conn_auth_passkey_confirm(auth_conn)) {
		uart_printk("Failed to confirm passkey for %s", addr);
	} else {
		//LOG_INF("Passkey confirmed for %s", addr);
	}
}


static void auth_cancel(struct bt_conn *conn)
{
	char addr[BT_ADDR_LE_STR_LEN];

	bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));

	//LOG_INF("Pairing cancelled: %s", addr);
}


static void pairing_complete(struct bt_conn *conn, bool bonded)
{
	char addr[BT_ADDR_LE_STR_LEN];

	bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));

	uart_printk("Pairing completed: %s, bonded: %d\n", addr, bonded);

	//LOG_INF("Pairing completed: %s, bonded: %d", addr, bonded);
}


static void pairing_failed(struct bt_conn *conn, enum bt_security_err reason)
{
	char addr[BT_ADDR_LE_STR_LEN];

	bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));

	uart_printk("Pairing failed: %s, reason: %d %s\n", addr, reason,
			bt_security_err_to_str(reason));

	//LOG_INF("Pairing failed conn: %s, reason %d %s", addr, reason,
		//bt_security_err_to_str(reason);
}

static void auth_passkey_entry(struct bt_conn *conn)
{

    if (bt_conn_auth_passkey_entry(conn, 123456))
	{
		uart_printk("Failed to enter passkey for %s\n", bt_addr_str(bt_conn_get_dst(conn)));
	}
	else
	{
		uart_printk("Passkey entered for %s\n", bt_addr_str(bt_conn_get_dst(conn)));
	}
}

static struct bt_conn_auth_cb conn_auth_callbacks = {
	.passkey_display = auth_passkey_display,
	.cancel = auth_cancel,
	//.passkey_entry   = auth_passkey_entry,
	//.passkey_confirm = auth_passkey_confirm,
	
};

static struct bt_conn_auth_info_cb conn_auth_info_callbacks = {
	.pairing_complete = pairing_complete,
	.pairing_failed = pairing_failed
};
#else
static struct bt_conn_auth_cb conn_auth_callbacks;
static struct bt_conn_auth_info_cb conn_auth_info_callbacks;
#endif

static void update_data_length(struct bt_conn *conn)
{
	int err;
	struct bt_conn_le_data_len_param my_data_len = {
		.tx_max_len = BT_GAP_DATA_LEN_MAX,
		.tx_max_time = BT_GAP_DATA_TIME_MAX,
	};
	err = bt_conn_le_data_len_update(current_conn, &my_data_len);
	if (err) {
		LOG_ERR("data_len_update failed (err %d)", err);
	}
}

static void exchange_func(struct bt_conn *conn, uint8_t att_err,
			  struct bt_gatt_exchange_params *params)
{
	LOG_INF("MTU exchange %s", att_err == 0 ? "successful" : "failed");
	if (!att_err) {
		uint16_t payload_mtu = bt_gatt_get_mtu(conn) - 3;   // 3 bytes used for Attribute headers.
		LOG_INF("New MTU: %d bytes", payload_mtu);
	}
}

static struct bt_gatt_exchange_params exchange_params;

static void update_mtu(struct bt_conn *conn)
{
	int err;
	exchange_params.func = exchange_func;

	err = bt_gatt_exchange_mtu(conn, &exchange_params);
	if (err) {
		LOG_ERR("bt_gatt_exchange_mtu failed (err %d)", err);
	}
}

static struct k_work_delayable security_work;

static void security_work_handler(struct k_work *work)
{
	if (security_conn) {
		uart_printk("Setting BLE security level...\n");
		int err = bt_conn_set_security(security_conn, BT_SECURITY_L2);
		if (err) {
			uart_printk("Failed to set security: %d\n", err);
		}

		bt_conn_unref(security_conn);
	}
}

static void connected(struct bt_conn *conn, uint8_t err)
{
	char addr[BT_ADDR_LE_STR_LEN];

	if (err) {
		LOG_ERR("Connection failed, err 0x%02x %s", err, bt_hci_err_to_str(err));
		return;
	}

	bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));
	//LOG_INF("Connected %s", addr);

	current_conn = bt_conn_ref(conn);

	struct bt_le_conn_param param = {
		.interval_min = 24,
		.interval_max = read_conn_interval(),
		.latency = 0,
		.timeout = 400,
	};

	bt_conn_le_param_update(conn, &param);
	update_data_length(current_conn);
	update_mtu(current_conn);

	if (IS_ENABLED(CONFIG_BT_NUS_SECURITY_ENABLED))
	{
		security_conn = bt_conn_ref(conn);
		k_work_schedule(&security_work, K_SECONDS(1));  // delay of 1 second
		// security_conn = bt_conn_ref(conn);

		// if (security_conn) {
		// 	uart_printk("Setting BLE security level...\n");
		// 	int err = bt_conn_set_security(security_conn, BT_SECURITY_L2);
		// 	if (err) {
		// 		uart_printk("Failed to set security: %d\n", err);
		// 	}
		// }
	}

	ConnectedOnBLE = true;
	HandleLEDBlink();
}

static void disconnected(struct bt_conn *conn, uint8_t reason)
{
	char addr[BT_ADDR_LE_STR_LEN];

	bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));

	//LOG_INF("Disconnected: %s, reason 0x%02x %s", addr, reason, bt_hci_err_to_str(reason));

	if (auth_conn) {
		bt_conn_unref(auth_conn);
		auth_conn = NULL;
	}

	if (current_conn) {
		bt_conn_unref(current_conn);
		current_conn = NULL;
	}

	if (security_conn) {
		bt_conn_unref(security_conn);
		security_conn = NULL;
	}
	{
		/* code */
	}
	

	ConnectedOnBLE = false;
	HandleLEDBlink();
}

#ifdef CONFIG_BT_NUS_SECURITY_ENABLED
static void security_changed(struct bt_conn *conn, bt_security_t level,
			     enum bt_security_err err)
{
	char addr[BT_ADDR_LE_STR_LEN];

	bt_addr_le_to_str(bt_conn_get_dst(conn), addr, sizeof(addr));

	uart_printk("Security changed: %s level %u err %d %s\n", addr, level, err,
			bt_security_err_to_str(err));

	if (!err) {
		//LOG_INF("Security changed: %s level %u", addr, level);
	} else {
		LOG_WRN("Security failed: %s level %u err %d %s", addr, level, err,
			bt_security_err_to_str(err));
	}
}
#endif

BT_CONN_CB_DEFINE(conn_callbacks) = {
	.connected    = connected,
	.disconnected = disconnected,
#ifdef CONFIG_BT_NUS_SECURITY_ENABLED
	.security_changed = security_changed,
#endif
};

void ble_write_thread(void)
{
	/* Don't go any further until BLE is initialized */
	k_sem_take(&ble_init_ok, K_FOREVER);
	// struct uart_data_t nus_data = {
	// 	.len = 0,
	// };

	for (;;) {
		/* Wait indefinitely for data to be sent over bluetooth */
		struct uart_data_t *buf = k_fifo_get(&fifo_uart_rx_data,
						     K_FOREVER);

		//int plen = MIN(sizeof(nus_data.data) - nus_data.len, buf->len);
		//int loc = 0;

		//while (plen > 0) {
			// memcpy(&nus_data.data[nus_data.len], &buf->data[loc], plen);
			// nus_data.len += plen;
			// loc += plen;

			// if (nus_data.len >= sizeof(nus_data.data) ||
			//    (nus_data.data[nus_data.len - 1] == '\n') ||
			//    (nus_data.data[nus_data.len - 1] == '\r')) 
			// {
			// 	if (bt_nus_send(NULL, nus_data.data, nus_data.len)) {
			// 		LOG_WRN("Failed to send data over BLE connection");
			// 	}
			// 	nus_data.len = 0;
			// // }

			// plen = MIN(sizeof(nus_data.data), buf->len - loc);
		//}



		if (bt_nus_send(NULL, buf->data, buf->len)) {
			 		LOG_WRN("Failed to send data over BLE connection");
			 	}

		k_free(buf);
	}
}

K_THREAD_DEFINE(ble_write_thread_id, STACKSIZE, ble_write_thread, NULL, NULL,
		NULL, PRIORITY, 0, 0); 

void ble_init()
{
    int err = 0;

    if (IS_ENABLED(CONFIG_BT_NUS_SECURITY_ENABLED)) {
		err = bt_conn_auth_cb_register(&conn_auth_callbacks);
		if (err) {
			uart_printk("Failed to register authorization callbacks.\n");
		}

		err = bt_conn_auth_info_cb_register(&conn_auth_info_callbacks);
		if (err) {
			uart_printk("Failed to register authorization info callbacks.\n");
		}
	}

	err = bt_enable(NULL);
	if (err) {
        LOG_ERR("Bluetooth init failed (err %d)", err);
	}
	if (IS_ENABLED(CONFIG_BT_NUS_SECURITY_ENABLED))
	{
		k_work_init_delayable(&security_work, security_work_handler);
		bt_passkey_set(123456);
	}
		
	
	if (err) {
		uart_printk("Failed to set passkey (err %d)\n", err);
	}

	//LOG_INF("Bluetooth initialized");

	k_sem_give(&ble_init_ok);

	if (IS_ENABLED(CONFIG_SETTINGS)) {
		settings_load();
	}

	err = bt_nus_init(&nus_cb);
	if (err) {
		LOG_ERR("Failed to initialize UART service (err: %d)", err);
	}

	int len = read_device_name(ble_name);  // Pull name from NVS
	if (len < 0) {
		uart_printk("Using default BLE name\n");
	}
	ad[1].data_len = strlen(ble_name); // Set correct length dynamically

	conn_interval = read_conn_interval();
	uart_printk("Using connection interval: %d ms\n", conn_interval);

	err = bt_le_adv_start(BT_LE_ADV_PARAM(
                              BT_LE_ADV_OPT_CONNECTABLE,
                              BT_GAP_ADV_FAST_INT_MIN_2,
                              BT_GAP_ADV_FAST_INT_MAX_2,
                              NULL),
                          ad, ARRAY_SIZE(ad),
                          sd, ARRAY_SIZE(sd));
	if (err) {
		uart_printk("Advertising failed to start (err %d)", err);
	}
}
4064.prj_minimal.conf

Parents
  • Hi,

    I do not see an obvious issue related to bonding here. Can you also upload the following?

    • generated .config file from <build_folder>/<application_name>/zephyr/
    • The full build log
    • UART/RTT log showing the hard fault you describe (please share the full log)
  • Hello Einar,

    PFA zephyr folder and build log

     0284.zephyr.zip

     *  Executing task: nRF Connect: Build [pristine]: NRF_BLETransparentModule_V2/build 
    
    Building NRF_BLETransparentModule_V2
    west build --build-dir /Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/build /Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2 --pristine --board ble_trans_board_nrf52810/nrf52810 --sysbuild -- -DNCS_TOOLCHAIN_VERSION=NONE -DCONF_FILE=prj_minimal.conf -DDTC_OVERLAY_FILE=ble_trans_board_nrf52810_nrf52810.overlay -DBOARD_ROOT=/Users/chinmaydixit/Projects/NRF
    
    -- west build: generating a build system
    Loading Zephyr module(s) (Zephyr base): sysbuild_default
    -- Found Python3: /opt/nordic/ncs/toolchains/b8efef2ad5/opt/[email protected]/bin/python3.12 (found suitable version "3.12.4", minimum required is "3.8") found components: Interpreter 
    -- Cache files will be written to: /Users/chinmaydixit/Library/Caches/zephyr
    -- Found west (found suitable version "1.2.0", minimum required is "0.14.0")
    -- Board: ble_trans_board_nrf52810, qualifiers: nrf52810
    Parsing /Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/Kconfig.sysbuild
    Loaded configuration '/Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/build/_sysbuild/empty.conf'
    Merged configuration '/Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/build/_sysbuild/empty.conf'
    Configuration saved to '/Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/build/zephyr/.config'
    Kconfig header saved to '/Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/build/_sysbuild/autoconf.h'
    -- 
       *************************************************
       * Running CMake for NRF_BLETransparentModule_V2 *
       *************************************************
    
    Loading Zephyr default modules (Zephyr base).
    -- Application: /Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2
    -- CMake version: 3.21.0
    -- Found Python3: /opt/nordic/ncs/toolchains/b8efef2ad5/bin/python (found suitable version "3.12.4", minimum required is "3.8") found components: Interpreter 
    -- Cache files will be written to: /Users/chinmaydixit/Library/Caches/zephyr
    -- Zephyr version: 3.7.99 (/opt/nordic/ncs/v2.9.1/zephyr)
    -- Found west (found suitable version "1.2.0", minimum required is "0.14.0")
    -- Board: ble_trans_board_nrf52810, qualifiers: nrf52810
    -- Found host-tools: zephyr 0.17.0 (/opt/nordic/ncs/toolchains/b8efef2ad5/opt/zephyr-sdk)
    -- Found toolchain: zephyr 0.17.0 (/opt/nordic/ncs/toolchains/b8efef2ad5/opt/zephyr-sdk)
    -- Found Dtc: /opt/nordic/ncs/toolchains/b8efef2ad5/bin/dtc (found suitable version "1.6.1", minimum required is "1.4.6") 
    -- Found BOARD.dts: /Users/chinmaydixit/Projects/NRF/boards/CGC/ble_trans_board_nrf52810/ble_trans_board_nrf52810.dts
    -- Found devicetree overlay: ble_trans_board_nrf52810_nrf52810.overlay
    -- Generated zephyr.dts: /Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/build/NRF_BLETransparentModule_V2/zephyr/zephyr.dts
    -- Generated devicetree_generated.h: /Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/build/NRF_BLETransparentModule_V2/zephyr/include/generated/zephyr/devicetree_generated.h
    -- Including generated dts.cmake file: /Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/build/NRF_BLETransparentModule_V2/zephyr/dts.cmake
    
    warning: HW_STACK_PROTECTION (defined at soc/nxp/s32/s32k1/Kconfig.defconfig:20, arch/Kconfig:283)
    was assigned the value 'y' but got the value 'n'. Check these unsatisfied dependencies:
    ((SOC_SERIES_S32K1 && SOC_FAMILY_NXP_S32) || ARCH_HAS_STACK_PROTECTION) (=n). See
    http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_HW_STACK_PROTECTION and/or look up
    HW_STACK_PROTECTION in the menuconfig/guiconfig interface. The Application Development Primer,
    Setting Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be
    helpful too.
    
    
    warning: LOG_BUFFER_SIZE (defined at
    /opt/nordic/ncs/v2.9.1/nrf/subsys/net/openthread/Kconfig.defconfig:51,
    subsys/logging/Kconfig.processing:122) was assigned the value '256' but got the value ''. Check
    these unsatisfied dependencies: (NET_L2_OPENTHREAD || (LOG_MODE_DEFERRED && !LOG_FRONTEND_ONLY &&
    !LOG_MODE_MINIMAL && LOG)) (=n). See
    http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_LOG_BUFFER_SIZE and/or look up
    LOG_BUFFER_SIZE in the menuconfig/guiconfig interface. The Application Development Primer, Setting
    Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be helpful
    too.
    
    
    warning: UART_CONSOLE (defined at drivers/console/Kconfig:42) was assigned the value 'y' but got the
    value 'n'. Check these unsatisfied dependencies: CONSOLE (=n). See
    http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_UART_CONSOLE and/or look up UART_CONSOLE in
    the menuconfig/guiconfig interface. The Application Development Primer, Setting Configuration
    Values, and Kconfig - Tips and Best Practices sections of the manual might be helpful too.
    
    
    warning: LOG_PRINTK (defined at subsys/logging/Kconfig.processing:8) was assigned the value 'y' but
    got the value 'n'. Check these unsatisfied dependencies: LOG (=n). See
    http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_LOG_PRINTK and/or look up LOG_PRINTK in the
    menuconfig/guiconfig interface. The Application Development Primer, Setting Configuration Values,
    and Kconfig - Tips and Best Practices sections of the manual might be helpful too.
    
    
    warning: LOG_BACKEND_UART (defined at subsys/logging/backends/Kconfig.uart:4) was assigned the value
    'y' but got the value 'n'. Check these unsatisfied dependencies: UART_CONSOLE (=n), LOG (=n). See
    http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_LOG_BACKEND_UART and/or look up
    LOG_BACKEND_UART in the menuconfig/guiconfig interface. The Application Development Primer, Setting
    Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be helpful
    too.
    
    Parsing /Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/Kconfig
    Loaded configuration '/Users/chinmaydixit/Projects/NRF/boards/CGC/ble_trans_board_nrf52810/ble_trans_board_nrf52810_defconfig'
    Merged configuration '/Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/prj_minimal.conf'
    Merged configuration '/Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/build/NRF_BLETransparentModule_V2/zephyr/.config.sysbuild'
    Configuration saved to '/Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/build/NRF_BLETransparentModule_V2/zephyr/.config'
    Kconfig header saved to '/Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/build/NRF_BLETransparentModule_V2/zephyr/include/generated/zephyr/autoconf.h'
    -- Found GnuLd: /opt/nordic/ncs/toolchains/b8efef2ad5/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi/bin/ld.bfd (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: /opt/nordic/ncs/toolchains/b8efef2ad5/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc
    CMake Warning at /opt/nordic/ncs/v2.9.1/zephyr/subsys/bluetooth/host/CMakeLists.txt:91 (message):
      CONFIG_BT_FIXED_PASSKEY is enabled
    
        A fixed passkey is easy to deduce during the pairing procedure, do not use in
        production.
    
    
    -- Setting build type to 'MinSizeRel' as none was specified.
    -- Using ccache: /opt/nordic/ncs/toolchains/b8efef2ad5/bin/ccache
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/build/NRF_BLETransparentModule_V2
    -- Found partition manager static configuration : /Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/pm_static.yml
    Partition 'nvs_storage' is not included in the dynamic resolving since it is statically defined.
    Partition 'settings_storage' is not included in the dynamic resolving since it is statically defined.
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/build
    -- west build: building application
    [1/216] Preparing syscall dependency handling
    
    [8/216] Generating include/generated/zephyr/version.h
    -- Zephyr version: 3.7.99 (/opt/nordic/ncs/v2.9.1/zephyr), build: v3.7.99-ncs2-1
    [39/216] Building C object CMakeFiles/app.dir/src/GPIO_handle/GPIO_handle.c.obj
    /Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/src/GPIO_handle/GPIO_handle.c: In function 'configure_gpio':
    /Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/src/GPIO_handle/GPIO_handle.c:131:1: warning: control reaches end of non-void function [-Wreturn-type]
      131 | }
          | ^
    [49/216] Building C object CMakeFiles/app.dir/src/ble_handle/ble_handle.c.obj
    /Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/src/ble_handle/ble_handle.c: In function 'bt_receive_cb':
    /Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/src/ble_handle/ble_handle.c:81:13: warning: unused variable 'err' [-Wunused-variable]
       81 |         int err;
          |             ^~~
    /Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/src/ble_handle/ble_handle.c: In function 'auth_passkey_entry':
    /Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/src/ble_handle/ble_handle.c:204:65: warning: implicit declaration of function 'bt_addr_str'; did you mean 'bt_addr_to_str'? [-Wimplicit-function-declaration]
      204 |                 uart_printk("Failed to enter passkey for %s\n", bt_addr_str(bt_conn_get_dst(conn)));
          |                                                                 ^~~~~~~~~~~
          |                                                                 bt_addr_to_str
    /Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/src/ble_handle/ble_handle.c: In function 'ble_init':
    /Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/src/ble_handle/ble_handle.c:466:17: warning: implicit declaration of function 'settings_load' [-Wimplicit-function-declaration]
      466 |                 settings_load();
          |                 ^~~~~~~~~~~~~
    /Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/src/ble_handle/ble_handle.c: At top level:
    /Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/src/ble_handle/ble_handle.c:199:13: warning: 'auth_passkey_entry' defined but not used [-Wunused-function]
      199 | static void auth_passkey_entry(struct bt_conn *conn)
          |             ^~~~~~~~~~~~~~~~~~
    /Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/src/ble_handle/ble_handle.c:145:13: warning: 'auth_passkey_confirm' defined but not used [-Wunused-function]
      145 | static void auth_passkey_confirm(struct bt_conn *conn, unsigned int passkey)
          |             ^~~~~~~~~~~~~~~~~~~~
    /Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/src/ble_handle/ble_handle.c:40:13: warning: 'num_comp_reply' defined but not used [-Wunused-function]
       40 | static void num_comp_reply(bool accept)
          |             ^~~~~~~~~~~~~~
    [216/216] Linking C executable zephyr/zephyr.elf
    Memory region         Used Size  Region Size  %age Used
               FLASH:      151060 B       176 KB     83.82%
                 RAM:       23064 B        24 KB     93.85%
            IDT_LIST:          0 GB        32 KB      0.00%
    Generating files from /Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/build/NRF_BLETransparentModule_V2/zephyr/zephyr.elf for board: ble_trans_board_nrf52810
    [10/10] Generating ../merged.hex
     *  Terminal will be reused by tasks, press any key to close it. 
    




    I am using nrf52810 and due to lack of RAM, I am unable to turn on logs. But I have attached the image and in that, I am getting reason 35.
    Can you help me with that?
    Thanks for your support.
    Chinmay

Reply
  • Hello Einar,

    PFA zephyr folder and build log

     0284.zephyr.zip

     *  Executing task: nRF Connect: Build [pristine]: NRF_BLETransparentModule_V2/build 
    
    Building NRF_BLETransparentModule_V2
    west build --build-dir /Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/build /Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2 --pristine --board ble_trans_board_nrf52810/nrf52810 --sysbuild -- -DNCS_TOOLCHAIN_VERSION=NONE -DCONF_FILE=prj_minimal.conf -DDTC_OVERLAY_FILE=ble_trans_board_nrf52810_nrf52810.overlay -DBOARD_ROOT=/Users/chinmaydixit/Projects/NRF
    
    -- west build: generating a build system
    Loading Zephyr module(s) (Zephyr base): sysbuild_default
    -- Found Python3: /opt/nordic/ncs/toolchains/b8efef2ad5/opt/[email protected]/bin/python3.12 (found suitable version "3.12.4", minimum required is "3.8") found components: Interpreter 
    -- Cache files will be written to: /Users/chinmaydixit/Library/Caches/zephyr
    -- Found west (found suitable version "1.2.0", minimum required is "0.14.0")
    -- Board: ble_trans_board_nrf52810, qualifiers: nrf52810
    Parsing /Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/Kconfig.sysbuild
    Loaded configuration '/Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/build/_sysbuild/empty.conf'
    Merged configuration '/Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/build/_sysbuild/empty.conf'
    Configuration saved to '/Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/build/zephyr/.config'
    Kconfig header saved to '/Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/build/_sysbuild/autoconf.h'
    -- 
       *************************************************
       * Running CMake for NRF_BLETransparentModule_V2 *
       *************************************************
    
    Loading Zephyr default modules (Zephyr base).
    -- Application: /Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2
    -- CMake version: 3.21.0
    -- Found Python3: /opt/nordic/ncs/toolchains/b8efef2ad5/bin/python (found suitable version "3.12.4", minimum required is "3.8") found components: Interpreter 
    -- Cache files will be written to: /Users/chinmaydixit/Library/Caches/zephyr
    -- Zephyr version: 3.7.99 (/opt/nordic/ncs/v2.9.1/zephyr)
    -- Found west (found suitable version "1.2.0", minimum required is "0.14.0")
    -- Board: ble_trans_board_nrf52810, qualifiers: nrf52810
    -- Found host-tools: zephyr 0.17.0 (/opt/nordic/ncs/toolchains/b8efef2ad5/opt/zephyr-sdk)
    -- Found toolchain: zephyr 0.17.0 (/opt/nordic/ncs/toolchains/b8efef2ad5/opt/zephyr-sdk)
    -- Found Dtc: /opt/nordic/ncs/toolchains/b8efef2ad5/bin/dtc (found suitable version "1.6.1", minimum required is "1.4.6") 
    -- Found BOARD.dts: /Users/chinmaydixit/Projects/NRF/boards/CGC/ble_trans_board_nrf52810/ble_trans_board_nrf52810.dts
    -- Found devicetree overlay: ble_trans_board_nrf52810_nrf52810.overlay
    -- Generated zephyr.dts: /Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/build/NRF_BLETransparentModule_V2/zephyr/zephyr.dts
    -- Generated devicetree_generated.h: /Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/build/NRF_BLETransparentModule_V2/zephyr/include/generated/zephyr/devicetree_generated.h
    -- Including generated dts.cmake file: /Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/build/NRF_BLETransparentModule_V2/zephyr/dts.cmake
    
    warning: HW_STACK_PROTECTION (defined at soc/nxp/s32/s32k1/Kconfig.defconfig:20, arch/Kconfig:283)
    was assigned the value 'y' but got the value 'n'. Check these unsatisfied dependencies:
    ((SOC_SERIES_S32K1 && SOC_FAMILY_NXP_S32) || ARCH_HAS_STACK_PROTECTION) (=n). See
    http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_HW_STACK_PROTECTION and/or look up
    HW_STACK_PROTECTION in the menuconfig/guiconfig interface. The Application Development Primer,
    Setting Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be
    helpful too.
    
    
    warning: LOG_BUFFER_SIZE (defined at
    /opt/nordic/ncs/v2.9.1/nrf/subsys/net/openthread/Kconfig.defconfig:51,
    subsys/logging/Kconfig.processing:122) was assigned the value '256' but got the value ''. Check
    these unsatisfied dependencies: (NET_L2_OPENTHREAD || (LOG_MODE_DEFERRED && !LOG_FRONTEND_ONLY &&
    !LOG_MODE_MINIMAL && LOG)) (=n). See
    http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_LOG_BUFFER_SIZE and/or look up
    LOG_BUFFER_SIZE in the menuconfig/guiconfig interface. The Application Development Primer, Setting
    Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be helpful
    too.
    
    
    warning: UART_CONSOLE (defined at drivers/console/Kconfig:42) was assigned the value 'y' but got the
    value 'n'. Check these unsatisfied dependencies: CONSOLE (=n). See
    http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_UART_CONSOLE and/or look up UART_CONSOLE in
    the menuconfig/guiconfig interface. The Application Development Primer, Setting Configuration
    Values, and Kconfig - Tips and Best Practices sections of the manual might be helpful too.
    
    
    warning: LOG_PRINTK (defined at subsys/logging/Kconfig.processing:8) was assigned the value 'y' but
    got the value 'n'. Check these unsatisfied dependencies: LOG (=n). See
    http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_LOG_PRINTK and/or look up LOG_PRINTK in the
    menuconfig/guiconfig interface. The Application Development Primer, Setting Configuration Values,
    and Kconfig - Tips and Best Practices sections of the manual might be helpful too.
    
    
    warning: LOG_BACKEND_UART (defined at subsys/logging/backends/Kconfig.uart:4) was assigned the value
    'y' but got the value 'n'. Check these unsatisfied dependencies: UART_CONSOLE (=n), LOG (=n). See
    http://docs.zephyrproject.org/latest/kconfig.html#CONFIG_LOG_BACKEND_UART and/or look up
    LOG_BACKEND_UART in the menuconfig/guiconfig interface. The Application Development Primer, Setting
    Configuration Values, and Kconfig - Tips and Best Practices sections of the manual might be helpful
    too.
    
    Parsing /Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/Kconfig
    Loaded configuration '/Users/chinmaydixit/Projects/NRF/boards/CGC/ble_trans_board_nrf52810/ble_trans_board_nrf52810_defconfig'
    Merged configuration '/Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/prj_minimal.conf'
    Merged configuration '/Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/build/NRF_BLETransparentModule_V2/zephyr/.config.sysbuild'
    Configuration saved to '/Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/build/NRF_BLETransparentModule_V2/zephyr/.config'
    Kconfig header saved to '/Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/build/NRF_BLETransparentModule_V2/zephyr/include/generated/zephyr/autoconf.h'
    -- Found GnuLd: /opt/nordic/ncs/toolchains/b8efef2ad5/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi/bin/ld.bfd (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: /opt/nordic/ncs/toolchains/b8efef2ad5/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc
    CMake Warning at /opt/nordic/ncs/v2.9.1/zephyr/subsys/bluetooth/host/CMakeLists.txt:91 (message):
      CONFIG_BT_FIXED_PASSKEY is enabled
    
        A fixed passkey is easy to deduce during the pairing procedure, do not use in
        production.
    
    
    -- Setting build type to 'MinSizeRel' as none was specified.
    -- Using ccache: /opt/nordic/ncs/toolchains/b8efef2ad5/bin/ccache
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/build/NRF_BLETransparentModule_V2
    -- Found partition manager static configuration : /Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/pm_static.yml
    Partition 'nvs_storage' is not included in the dynamic resolving since it is statically defined.
    Partition 'settings_storage' is not included in the dynamic resolving since it is statically defined.
    -- Configuring done
    -- Generating done
    -- Build files have been written to: /Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/build
    -- west build: building application
    [1/216] Preparing syscall dependency handling
    
    [8/216] Generating include/generated/zephyr/version.h
    -- Zephyr version: 3.7.99 (/opt/nordic/ncs/v2.9.1/zephyr), build: v3.7.99-ncs2-1
    [39/216] Building C object CMakeFiles/app.dir/src/GPIO_handle/GPIO_handle.c.obj
    /Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/src/GPIO_handle/GPIO_handle.c: In function 'configure_gpio':
    /Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/src/GPIO_handle/GPIO_handle.c:131:1: warning: control reaches end of non-void function [-Wreturn-type]
      131 | }
          | ^
    [49/216] Building C object CMakeFiles/app.dir/src/ble_handle/ble_handle.c.obj
    /Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/src/ble_handle/ble_handle.c: In function 'bt_receive_cb':
    /Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/src/ble_handle/ble_handle.c:81:13: warning: unused variable 'err' [-Wunused-variable]
       81 |         int err;
          |             ^~~
    /Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/src/ble_handle/ble_handle.c: In function 'auth_passkey_entry':
    /Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/src/ble_handle/ble_handle.c:204:65: warning: implicit declaration of function 'bt_addr_str'; did you mean 'bt_addr_to_str'? [-Wimplicit-function-declaration]
      204 |                 uart_printk("Failed to enter passkey for %s\n", bt_addr_str(bt_conn_get_dst(conn)));
          |                                                                 ^~~~~~~~~~~
          |                                                                 bt_addr_to_str
    /Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/src/ble_handle/ble_handle.c: In function 'ble_init':
    /Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/src/ble_handle/ble_handle.c:466:17: warning: implicit declaration of function 'settings_load' [-Wimplicit-function-declaration]
      466 |                 settings_load();
          |                 ^~~~~~~~~~~~~
    /Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/src/ble_handle/ble_handle.c: At top level:
    /Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/src/ble_handle/ble_handle.c:199:13: warning: 'auth_passkey_entry' defined but not used [-Wunused-function]
      199 | static void auth_passkey_entry(struct bt_conn *conn)
          |             ^~~~~~~~~~~~~~~~~~
    /Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/src/ble_handle/ble_handle.c:145:13: warning: 'auth_passkey_confirm' defined but not used [-Wunused-function]
      145 | static void auth_passkey_confirm(struct bt_conn *conn, unsigned int passkey)
          |             ^~~~~~~~~~~~~~~~~~~~
    /Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/src/ble_handle/ble_handle.c:40:13: warning: 'num_comp_reply' defined but not used [-Wunused-function]
       40 | static void num_comp_reply(bool accept)
          |             ^~~~~~~~~~~~~~
    [216/216] Linking C executable zephyr/zephyr.elf
    Memory region         Used Size  Region Size  %age Used
               FLASH:      151060 B       176 KB     83.82%
                 RAM:       23064 B        24 KB     93.85%
            IDT_LIST:          0 GB        32 KB      0.00%
    Generating files from /Users/chinmaydixit/Projects/NRF/Projects/NRF_BLETransparentModule_V2/build/NRF_BLETransparentModule_V2/zephyr/zephyr.elf for board: ble_trans_board_nrf52810
    [10/10] Generating ../merged.hex
     *  Terminal will be reused by tasks, press any key to close it. 
    




    I am using nrf52810 and due to lack of RAM, I am unable to turn on logs. But I have attached the image and in that, I am getting reason 35.
    Can you help me with that?
    Thanks for your support.
    Chinmay

Children
Related