This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

NCS OTA DFU failed in nrf52832

Hi,

 I am trying to test and develop the DFU-OTA in nRF CONNECT SDK for nRF52832

I followed these link to develop  i am using NCS v1.4.2

1. I have copied the peripheral_lbs code to my workspace

2. Based on the link i have added few things and here i attached the related files

main.c

/*
 * Copyright (c) 2018 Nordic Semiconductor ASA
 *
 * SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
 */

#include <zephyr/types.h>
#include <stddef.h>
#include <string.h>
#include <errno.h>
#include <sys/printk.h>
#include <sys/byteorder.h>
#include <zephyr.h>
#include <drivers/gpio.h>
#include <soc.h>

#include <bluetooth/bluetooth.h>
#include <bluetooth/hci.h>
#include <bluetooth/conn.h>
#include <bluetooth/uuid.h>
#include <bluetooth/gatt.h>

#include <bluetooth/services/lbs.h>

#include <settings/settings.h>

#include <dk_buttons_and_leds.h>

// For FOTA
#include <tinycbor/cbor.h>
#include "cborattr/cborattr.h"
#include <mgmt/mgmt.h>
#include <mgmt/mcumgr/smp_bt.h>
#include <mgmt/mcumgr/buf.h>
#include <mgmt/mcumgr/smp.h>
#include "os_mgmt/os_mgmt.h"
#include "os_mgmt/os_mgmt_impl.h"
#include "os_mgmt/os_mgmt_config.h"
#include "img_mgmt/image.h"
#include "img_mgmt/img_mgmt.h"
#include "img_mgmt/img_mgmt_impl.h"
#include "img_mgmt/img_mgmt_config.h"

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


#define RUN_STATUS_LED          DK_LED1
#define CON_STATUS_LED          DK_LED2
#define RUN_LED_BLINK_INTERVAL  1000

#define USER_LED                DK_LED3

#define USER_BUTTON             DK_BTN1_MSK

static bool app_button_state;

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),
};

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

static void connected(struct bt_conn *conn, uint8_t err)
{
	if (err) {
		printk("Connection failed (err %u)\n", err);
		return;
	}

	printk("Connected\n");

	dk_set_led_on(CON_STATUS_LED);
}

static void disconnected(struct bt_conn *conn, uint8_t reason)
{
	printk("Disconnected (reason %u)\n", reason);

	dk_set_led_off(CON_STATUS_LED);
}

#ifdef CONFIG_BT_LBS_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));

	if (!err) {
		printk("Security changed: %s level %u\n", addr, level);
	} else {
		printk("Security failed: %s level %u err %d\n", addr, level,
			err);
	}
}
#endif

static struct bt_conn_cb conn_callbacks = {
	.connected        = connected,
	.disconnected     = disconnected,
#ifdef CONFIG_BT_LBS_SECURITY_ENABLED
	.security_changed = security_changed,
#endif
};

#if defined(CONFIG_BT_LBS_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);
}

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));

	printk("Pairing cancelled: %s\n", addr);
}

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

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

	bt_conn_auth_pairing_confirm(conn);

	printk("Pairing confirmed: %s\n", 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));

	printk("Pairing completed: %s, bonded: %d\n", 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));

	printk("Pairing failed conn: %s, reason %d\n", addr, reason);
}

static struct bt_conn_auth_cb conn_auth_callbacks = {
	.passkey_display = auth_passkey_display,
	.cancel = auth_cancel,
	.pairing_confirm = pairing_confirm,
	.pairing_complete = pairing_complete,
	.pairing_failed = pairing_failed
};
#else
static struct bt_conn_auth_cb conn_auth_callbacks;
#endif

static void app_led_cb(bool led_state)
{
	dk_set_led(USER_LED, led_state);
}

static bool app_button_cb(void)
{
	return app_button_state;
}

static struct bt_lbs_cb lbs_callbacs = {
	.led_cb    = app_led_cb,
	.button_cb = app_button_cb,
};

static void button_changed(uint32_t button_state, uint32_t has_changed)
{
	if (has_changed & USER_BUTTON) {
		bt_lbs_send_button_state(button_state);
		app_button_state = button_state ? true : false;
	}
}

static int init_button(void)
{
	int err;

	err = dk_buttons_init(button_changed);
	if (err) {
		printk("Cannot init buttons (err: %d)\n", err);
	}

	return err;
}

void main(void)
{
	int blink_status = 0;
	int err;

	printk("Starting Bluetooth Peripheral LBS example\n");
        printk("Application build time: %s %s \n", __DATE__, __TIME__);
	err = dk_leds_init();
	if (err) {
		printk("LEDs init failed (err %d)\n", err);
		return;
	}

	err = init_button();
	if (err) {
		printk("Button init failed (err %d)\n", err);
		return;
	}

	bt_conn_cb_register(&conn_callbacks);
	if (IS_ENABLED(CONFIG_BT_LBS_SECURITY_ENABLED)) {
		bt_conn_auth_cb_register(&conn_auth_callbacks);
	}

	err = bt_enable(NULL);
	if (err) {
		printk("Bluetooth init failed (err %d)\n", err);
		return;
	}

	printk("Bluetooth initialized\n");

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

	err = bt_lbs_init(&lbs_callbacs);
	if (err) {
		printk("Failed to init LBS (err:%d)\n", err);
		return;
	}

	err = bt_le_adv_start(BT_LE_ADV_CONN, ad, ARRAY_SIZE(ad),
			      sd, ARRAY_SIZE(sd));
	if (err) {
		printk("Advertising failed to start (err %d)\n", err);
		return;
	}

	printk("Advertising successfully started\n");
        // For FOTA
  os_mgmt_register_group();
  img_mgmt_register_group();
  smp_bt_register();

	for (;;) {
		dk_set_led(RUN_STATUS_LED, (++blink_status) % 2);
		k_sleep(K_MSEC(RUN_LED_BLINK_INTERVAL));
	}
}

prj.conf

#
# Copyright (c) 2018 Nordic Semiconductor
#
# SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
#
CONFIG_NCS_SAMPLES_DEFAULTS=y

CONFIG_BT=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_DEVICE_NAME="Nordic_Blinky"

# Enable the LBS service
CONFIG_BT_LBS=y
CONFIG_BT_LBS_POLL_BUTTON=y
CONFIG_DK_LIBRARY=y

# Added for FOTA
CONFIG_BOOTLOADER_MCUBOOT=y
CONFIG_MCUMGR=y
CONFIG_MCUMGR_CMD_OS_MGMT=y
CONFIG_MCUMGR_CMD_IMG_MGMT=y
CONFIG_MCUMGR_SMP_BT=y
CONFIG_IMG_ERASE_PROGRESSIVELY=y

CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048

also added full .zip file here

1447.dfu_app.zip

3. After successful compilation of the code uploaded to the Empty nRF52 DK (there is no bootloader separately added before )

4. Successfully showing the services in the nRF connect APP while entering into DFU

5. On the other-side i have just changed the device name to dfu_nrf_blinky

6. taken the build and app_update.bin is taken to mobile device

7. While initialize the DFU it asked for pairing and also paired with the device with valid key.

8. And on entering to start DFU it was disconnected like this and video is linked below with respective log

Log in the serial

*** Booting Zephyr OS build v2.4.0-ncs2  ***
[00:00:00.528,289] [0m<inf> mcuboot: Starting bootloader[0m
[00:00:00.534,576] [0m<inf> mcuboot: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3[0m
[00:00:00.545,043] [0m<inf> mcuboot: Boot source: none[0m
[00:00:00.550,781] [0m<inf> mcuboot: Swap type: none[0m
[00:00:00.844,512] [0m<inf> mcuboot: Bootloader chainload address offset: 0xc000[0m
[00:00:00.852,508] [0m<inf> mcuboot: Jumping to the first image slot[0m
*** Booting Zephyr OS build v2.4.0-ncs2  ***
Starting Bluetooth Peripheral LBS example
Application build time: Mar 15 2021 14:36:28 
I: 2 Sectors of 4096 bytes
I: alloc wra: 0, ff0
I: data wra: 0, 0
I: SoftDevice Controller build revision: 
I: cf 5c 0f 11 88 9c d7 02 |.\......
I: 15 27 c7 c3 ca 60 19 85 |.'...`..
I: b7 c4 50 e3             |..P.    
I: No ID address. App must call settings_load()
Bluetooth initialized
Advertising successfully started
Connected
Passkey for 7e:2a:18:a3:a2:3c (random): 757200
Security changed: 7e:2a:18:a3:a2:3c (random) level 4
Pairing completed: 7c:78:7e:78:66:b3 (public), bonded: 1
Disconnected (reason 19)
Connected
Security changed: 7c:78:7e:78:66:b3 (public) level 4
Disconnected (reason 19)
Connected
Security changed: 7c:78:7e:78:66:b3 (public) level 4
Disconnected (reason 19)
Connected
Security changed: 7c:78:7e:78:66:b3 (public) level 4

Log from the nrf connect APP

nRF Connect, 2021-03-15
Nordic_Blinky (FB:B4:FA:11:EB:63)
V	14:54:14.912	Connecting to FB:B4:FA:11:EB:63...
D	14:54:14.912	gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE, preferred PHY = LE 1M)
D	14:54:15.042	[Broadcast] Action received: android.bluetooth.device.action.ACL_CONNECTED
D	14:54:15.096	[Callback] Connection state changed with status: 0 and new state: CONNECTED (2)
I	14:54:15.097	Connected to FB:B4:FA:11:EB:63
D	14:54:15.099	wait(1600ms)
D	14:54:15.360	[Broadcast] Action received: android.bluetooth.device.action.BOND_STATE_CHANGED, bond state changed to: BOND_BONDING (11)
D	14:54:15.421	[Broadcast] Action received: android.bluetooth.device.action.BOND_STATE_CHANGED, bond state changed to: BOND_BONDED (12)
I	14:54:15.421	Device bonded
I	14:54:15.616	Connection parameters updated (interval: 7.5ms, latency: 0, timeout: 5000ms)
I	14:54:16.023	Connection parameters updated (interval: 45.0ms, latency: 0, timeout: 5000ms)
V	14:54:16.700	Discovering services...
D	14:54:16.700	gatt.discoverServices()
D	14:54:16.713	[Callback] Services discovered with status: 0
I	14:54:16.714	Services discovered
V	14:54:16.737	Generic Attribute (0x1801)
- Service Changed [I] (0x2A05)
   Client Characteristic Configuration (0x2902)
- Client Supported Features [R W] (0x2B29)
- Database Hash [R] (0x2B2A)
Generic Access (0x1800)
- Device Name [R] (0x2A00)
- Appearance [R] (0x2A01)
- Peripheral Preferred Connection Parameters [R] (0x2A04)
Nordic LED Button Service (00001523-1212-efde-1523-785feabcd123)
- Button [N R] (00001524-1212-efde-1523-785feabcd123)
   Client Characteristic Configuration (0x2902)
- LED [W] (00001525-1212-efde-1523-785feabcd123)
SMP Service (8d53dc1d-1db7-4cd3-868b-8a527460aa84)
- SMP Characteristic [N WNR] (da2e7828-fbce-4e01-ae9e-261174997c48)
   Client Characteristic Configuration (0x2902)
D	14:54:16.738	gatt.setCharacteristicNotification(00002a05-0000-1000-8000-00805f9b34fb, true)
D	14:54:16.740	gatt.setCharacteristicNotification(00001524-1212-efde-1523-785feabcd123, true)
I	14:54:20.973	Connection parameters updated (interval: 45.0ms, latency: 0, timeout: 420ms)
V	14:54:22.707	[McuMgr] Connecting...
D	14:54:22.720	[McuMgr] gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE, LE 1M)
D	14:54:22.751	[McuMgr] [Callback] Connection state changed with status: 0 and new state: 2 (CONNECTED)
I	14:54:22.767	[McuMgr] Connected to FB:B4:FA:11:EB:63
D	14:54:22.786	[McuMgr] wait(1600)
V	14:54:24.400	[McuMgr] Discovering services...
D	14:54:24.418	[McuMgr] gatt.discoverServices()
I	14:54:24.472	[McuMgr] Services discovered
V	14:54:24.483	[McuMgr] Primary service found
I	14:54:24.500	[McuMgr] Service Changed characteristic found on a bonded device
D	14:54:24.513	[McuMgr] gatt.setCharacteristicNotification(00002a05-0000-1000-8000-00805f9b34fb, true)
V	14:54:24.550	[McuMgr] Enabling indications for 00002a05-0000-1000-8000-00805f9b34fb
D	14:54:24.561	[McuMgr] gatt.writeDescriptor(00002902-0000-1000-8000-00805f9b34fb, value=0x02-00)
I	14:54:24.662	[McuMgr] Data written to descr. 00002902-0000-1000-8000-00805f9b34fb, value: (0x) 02-00
I	14:54:24.672	[McuMgr] Service Changed notifications enabled
V	14:54:24.695	[McuMgr] Requesting new MTU...
D	14:54:24.705	[McuMgr] gatt.requestMtu(515)
I	14:54:24.797	[McuMgr] MTU changed to: 65
D	14:54:24.807	[McuMgr] gatt.setCharacteristicNotification(da2e7828-fbce-4e01-ae9e-261174997c48, true)
V	14:54:24.831	[McuMgr] Enabling notifications for da2e7828-fbce-4e01-ae9e-261174997c48
D	14:54:24.852	[McuMgr] gatt.writeDescriptor(00002902-0000-1000-8000-00805f9b34fb, value=0x01-00)
I	14:54:24.979	[McuMgr] Data written to descr. 00002902-0000-1000-8000-00805f9b34fb, value: (0x) 01-00
I	14:54:24.992	[McuMgr] Notifications enabled
V	14:54:25.034	[McuMgr] Writing characteristic da2e7828-fbce-4e01-ae9e-261174997c48 (WRITE COMMAND)
D	14:54:25.047	[McuMgr] gatt.writeCharacteristic(da2e7828-fbce-4e01-ae9e-261174997c48)
I	14:54:25.066	[McuMgr] Data written to da2e7828-fbce-4e01-ae9e-261174997c48, value: (0x) 00-00-00-02-00-01-00-00-BF-FF
A	14:54:25.106	[McuMgr] "Operation: READ
Flags: 0
Length: 2
Group Id: 1 (IMAGE)
Sequence Num: 0
Command Id: 0 (STATE)
Message: {}" sent
I	14:54:25.124	[McuMgr] Notification received from da2e7828-fbce-4e01-ae9e-261174997c48, value: (0x) 01-00-00-86-00-01-00-00-BF-66-69-6D-61-67-65-73-9F-BF-64-73-6C-6F-74-00-67-76-65-72-73-69-6F-6E-65-30-2E-30-2E-30-64-68-61-73-68-58-20-AC-9F-71-AD-D4-4D-30-DB-72-07-FB-55-47-69-4B-33-95
I	14:54:25.161	[McuMgr] Notification received from da2e7828-fbce-4e01-ae9e-261174997c48, value: (0x) 8E-0A-87-5A-57-1A-5A-E0-48-51-DB-E1-28-88-C5-68-62-6F-6F-74-61-62-6C-65-F5-67-70-65-6E-64-69-6E-67-F4-69-63-6F-6E-66-69-72-6D-65-64-F5-66-61-63-74-69-76-65-F5-69-70-65-72-6D-61-6E-65-6E
I	14:54:25.174	[McuMgr] Notification received from da2e7828-fbce-4e01-ae9e-261174997c48, value: (0x) 74-F4-FF-FF-6B-73-70-6C-69-74-53-74-61-74-75-73-00-FF
A	14:54:25.209	[McuMgr] "{"images":[{"slot":0,"version":"0.0.0","hash":"rJ9xrdRNMNtyB/tVR2lLM5WOCodaVxpa4EhR2+EoiMU=","bootable":true,"pending":false,"confirmed":true,"active":true,"permanent":false}],"splitStatus":0}" received
V	14:54:25.227	[McuMgr] Uploading firmware...
I	14:54:46.130	Notification received from 00001524-1212-efde-1523-785feabcd123, value: (0x) 01
A	14:54:46.130	"Button pressed" received
I	14:54:46.488	Notification received from 00001524-1212-efde-1523-785feabcd123, value: (0x) 00
A	14:54:46.488	"Button released" received
I	14:54:47.030	Notification received from 00001524-1212-efde-1523-785feabcd123, value: (0x) 01
A	14:54:47.030	"Button pressed" received
I	14:54:47.431	Notification received from 00001524-1212-efde-1523-785feabcd123, value: (0x) 00
A	14:54:47.431	"Button released" received
V	14:54:55.459	[McuMgr] Connecting...
D	14:54:55.711	[McuMgr] gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE, LE 1M)
D	14:54:55.828	[McuMgr] [Callback] Connection state changed with status: 0 and new state: 2 (CONNECTED)
I	14:54:55.853	[McuMgr] Connected to FB:B4:FA:11:EB:63
D	14:54:55.887	[McuMgr] wait(1600)
I	14:54:55.906	[McuMgr] MTU changed to: 65
V	14:54:57.503	[McuMgr] Discovering services...
D	14:54:57.522	[McuMgr] gatt.discoverServices()
I	14:54:57.542	[McuMgr] Services discovered
V	14:54:57.558	[McuMgr] Primary service found
I	14:54:57.589	[McuMgr] Service Changed characteristic found on a bonded device
D	14:54:57.602	[McuMgr] gatt.setCharacteristicNotification(00002a05-0000-1000-8000-00805f9b34fb, true)
V	14:54:57.643	[McuMgr] Enabling indications for 00002a05-0000-1000-8000-00805f9b34fb
D	14:54:57.659	[McuMgr] gatt.writeDescriptor(00002902-0000-1000-8000-00805f9b34fb, value=0x02-00)
I	14:54:57.739	[McuMgr] Data written to descr. 00002902-0000-1000-8000-00805f9b34fb, value: (0x) 02-00
I	14:54:57.748	[McuMgr] Service Changed notifications enabled
V	14:54:57.779	[McuMgr] Requesting new MTU...
D	14:54:57.796	[McuMgr] gatt.requestMtu(515)
I	14:54:57.873	[McuMgr] MTU changed to: 65
D	14:54:57.884	[McuMgr] gatt.setCharacteristicNotification(da2e7828-fbce-4e01-ae9e-261174997c48, true)
V	14:54:57.913	[McuMgr] Enabling notifications for da2e7828-fbce-4e01-ae9e-261174997c48
D	14:54:57.923	[McuMgr] gatt.writeDescriptor(00002902-0000-1000-8000-00805f9b34fb, value=0x01-00)
I	14:54:58.053	[McuMgr] Data written to descr. 00002902-0000-1000-8000-00805f9b34fb, value: (0x) 01-00
I	14:54:58.063	[McuMgr] Notifications enabled
V	14:54:58.092	[McuMgr] Writing characteristic da2e7828-fbce-4e01-ae9e-261174997c48 (WRITE COMMAND)
D	14:54:58.103	[McuMgr] gatt.writeCharacteristic(da2e7828-fbce-4e01-ae9e-261174997c48)
I	14:54:58.118	[McuMgr] Data written to da2e7828-fbce-4e01-ae9e-261174997c48, value: (0x) 00-00-00-02-00-01-00-00-BF-FF
A	14:54:58.132	[McuMgr] "Operation: READ
Flags: 0
Length: 2
Group Id: 1 (IMAGE)
Sequence Num: 0
Command Id: 0 (STATE)
Message: {}" sent
I	14:54:58.206	[McuMgr] Notification received from da2e7828-fbce-4e01-ae9e-261174997c48, value: (0x) 01-00-00-86-00-01-00-00-BF-66-69-6D-61-67-65-73-9F-BF-64-73-6C-6F-74-00-67-76-65-72-73-69-6F-6E-65-30-2E-30-2E-30-64-68-61-73-68-58-20-AC-9F-71-AD-D4-4D-30-DB-72-07-FB-55-47-69-4B-33-95
I	14:54:58.252	[McuMgr] Notification received from da2e7828-fbce-4e01-ae9e-261174997c48, value: (0x) 8E-0A-87-5A-57-1A-5A-E0-48-51-DB-E1-28-88-C5-68-62-6F-6F-74-61-62-6C-65-F5-67-70-65-6E-64-69-6E-67-F4-69-63-6F-6E-66-69-72-6D-65-64-F5-66-61-63-74-69-76-65-F5-69-70-65-72-6D-61-6E-65-6E
I	14:54:58.267	[McuMgr] Notification received from da2e7828-fbce-4e01-ae9e-261174997c48, value: (0x) 74-F4-FF-FF-6B-73-70-6C-69-74-53-74-61-74-75-73-00-FF
A	14:54:58.316	[McuMgr] "{"images":[{"slot":0,"version":"0.0.0","hash":"rJ9xrdRNMNtyB/tVR2lLM5WOCodaVxpa4EhR2+EoiMU=","bootable":true,"pending":false,"confirmed":true,"active":true,"permanent":false}],"splitStatus":0}" received
V	14:54:58.335	[McuMgr] Uploading firmware...
V	14:55:15.765	Disconnecting...
D	14:55:15.765	gatt.disconnect()
D	14:55:15.809	[Callback] Connection state changed with status: 0 and new state: DISCONNECTED (0)
I	14:55:15.809	Disconnected
D	14:55:16.833	[Broadcast] Action received: android.bluetooth.device.action.ACL_DISCONNECTED

nRF Connect, 2021-03-15
Nordic_Blinky (FB:B4:FA:11:EB:63)
V	15:07:18.490	[McuMgr] Connecting...
D	15:07:18.500	[McuMgr] gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE, LE 1M)
D	15:07:18.520	[McuMgr] [Callback] Connection state changed with status: 0 and new state: 2 (CONNECTED)
I	15:07:18.534	[McuMgr] Connected to FB:B4:FA:11:EB:63
D	15:07:18.548	[McuMgr] wait(1600)
V	15:07:20.167	[McuMgr] Discovering services...
D	15:07:20.176	[McuMgr] gatt.discoverServices()
I	15:07:20.198	[McuMgr] Services discovered
V	15:07:20.229	[McuMgr] Primary service found
I	15:07:20.257	[McuMgr] Service Changed characteristic found on a bonded device
D	15:07:20.268	[McuMgr] gatt.setCharacteristicNotification(00002a05-0000-1000-8000-00805f9b34fb, true)
V	15:07:20.290	[McuMgr] Enabling indications for 00002a05-0000-1000-8000-00805f9b34fb
D	15:07:20.299	[McuMgr] gatt.writeDescriptor(00002902-0000-1000-8000-00805f9b34fb, value=0x02-00)
I	15:07:20.379	[McuMgr] Data written to descr. 00002902-0000-1000-8000-00805f9b34fb, value: (0x) 02-00
I	15:07:20.390	[McuMgr] Service Changed notifications enabled
V	15:07:20.417	[McuMgr] Requesting new MTU...
D	15:07:20.427	[McuMgr] gatt.requestMtu(515)
I	15:07:20.514	[McuMgr] MTU changed to: 65
D	15:07:20.525	[McuMgr] gatt.setCharacteristicNotification(da2e7828-fbce-4e01-ae9e-261174997c48, true)
V	15:07:20.561	[McuMgr] Enabling notifications for da2e7828-fbce-4e01-ae9e-261174997c48
D	15:07:20.577	[McuMgr] gatt.writeDescriptor(00002902-0000-1000-8000-00805f9b34fb, value=0x01-00)
I	15:07:20.741	[McuMgr] Data written to descr. 00002902-0000-1000-8000-00805f9b34fb, value: (0x) 01-00
I	15:07:20.760	[McuMgr] Notifications enabled
V	15:07:20.816	[McuMgr] Writing characteristic da2e7828-fbce-4e01-ae9e-261174997c48 (WRITE COMMAND)
D	15:07:20.832	[McuMgr] gatt.writeCharacteristic(da2e7828-fbce-4e01-ae9e-261174997c48)
I	15:07:20.853	[McuMgr] Data written to da2e7828-fbce-4e01-ae9e-261174997c48, value: (0x) 00-00-00-02-00-01-00-00-BF-FF
A	15:07:20.874	[McuMgr] "Operation: READ
Flags: 0
Length: 2
Group Id: 1 (IMAGE)
Sequence Num: 0
Command Id: 0 (STATE)
Message: {}" sent
I	15:07:20.923	[McuMgr] Notification received from da2e7828-fbce-4e01-ae9e-261174997c48, value: (0x) 01-00-00-86-00-01-00-00-BF-66-69-6D-61-67-65-73-9F-BF-64-73-6C-6F-74-00-67-76-65-72-73-69-6F-6E-65-30-2E-30-2E-30-64-68-61-73-68-58-20-AC-9F-71-AD-D4-4D-30-DB-72-07-FB-55-47-69-4B-33-95
I	15:07:20.938	[McuMgr] Notification received from da2e7828-fbce-4e01-ae9e-261174997c48, value: (0x) 8E-0A-87-5A-57-1A-5A-E0-48-51-DB-E1-28-88-C5-68-62-6F-6F-74-61-62-6C-65-F5-67-70-65-6E-64-69-6E-67-F4-69-63-6F-6E-66-69-72-6D-65-64-F5-66-61-63-74-69-76-65-F5-69-70-65-72-6D-61-6E-65-6E
I	15:07:20.978	[McuMgr] Notification received from da2e7828-fbce-4e01-ae9e-261174997c48, value: (0x) 74-F4-FF-FF-6B-73-70-6C-69-74-53-74-61-74-75-73-00-FF
A	15:07:21.028	[McuMgr] "{"images":[{"slot":0,"version":"0.0.0","hash":"rJ9xrdRNMNtyB/tVR2lLM5WOCodaVxpa4EhR2+EoiMU=","bootable":true,"pending":false,"confirmed":true,"active":true,"permanent":false}],"splitStatus":0}" received
V	15:07:21.044	[McuMgr] Uploading firmware...

Parents
  • Hi,

    I do not see any indication on what goes wrong. Can you try with another DFU master (other phone and/or other app)? Still same behavior? Perhaps you could get more debug information from the nRF log by adding this in you rprj.conf:

    CONFIG_LOG_DEFAULT_LEVEL=4
    CONFIG_DEBUG_OPTIMIZATIONS=y

  • This line is adding when i use iphone

    W: Ignoring data for unknown CID 0x003a

    Before uploading the first application code

    where we need to upload bootloader code as like nRF5 SDK?

  • After erase the chip i rebuild the code and upload . this time i connected with iphone

    while DFU process It shows Pairing option and i got new error log

    File Name: -889926514022512140app_update.bin
    Size: 202 KB
    Firmware Upgrade Started.
    State changed from none to validate
    Central Manager  ready
    Connecting...
    Peripheral connected
    Discovering services...
    Services discovered: 8D53DC1D-1DB7-4CD3-868B-8A527460AA84
    Discovering characteristics...
    Characteristics discovered: DA2E7828-FBCE-4E01-AE9E-261174997C48
    Enabling notifications...
    Notifications enabled
    Device ready
    -> 0x0000000100010000a0
    <- 0x0100008600010000bf66696d616765739fbf64736c6f74006776657273696f6e65302e302e30646861736858205c705692d95353292af8d9a180b8e5bc2a7a853d8260307ba6710cfc25e56ead68626f6f7461626c65f56770656e64696e67f469636f6e6669726d6564f566616374697665f5697065726d616e656e74f4ffff6b73706c697453746174757300ff
    State changed from validate to upload
    Length of data to send exceeds MTU
    -> 0x0200030000010001a4636c656e1a000314746464617461533db8f396000000000002000024110300000000636f6666006373686143a3835d
    <- 0x0300000600010001bf62726303ff
    DFU failed: Remote error: In Value (3).

Reply
  • After erase the chip i rebuild the code and upload . this time i connected with iphone

    while DFU process It shows Pairing option and i got new error log

    File Name: -889926514022512140app_update.bin
    Size: 202 KB
    Firmware Upgrade Started.
    State changed from none to validate
    Central Manager  ready
    Connecting...
    Peripheral connected
    Discovering services...
    Services discovered: 8D53DC1D-1DB7-4CD3-868B-8A527460AA84
    Discovering characteristics...
    Characteristics discovered: DA2E7828-FBCE-4E01-AE9E-261174997C48
    Enabling notifications...
    Notifications enabled
    Device ready
    -> 0x0000000100010000a0
    <- 0x0100008600010000bf66696d616765739fbf64736c6f74006776657273696f6e65302e302e30646861736858205c705692d95353292af8d9a180b8e5bc2a7a853d8260307ba6710cfc25e56ead68626f6f7461626c65f56770656e64696e67f469636f6e6669726d6564f566616374697665f5697065726d616e656e74f4ffff6b73706c697453746174757300ff
    State changed from validate to upload
    Length of data to send exceeds MTU
    -> 0x0200030000010001a4636c656e1a000314746464617461533db8f396000000000002000024110300000000636f6666006373686143a3835d
    <- 0x0300000600010001bf62726303ff
    DFU failed: Remote error: In Value (3).

Children
  • Hi,

    I have not tested but I see you have not set CONFIG_MCUMGR_SMP_BT_AUTHEN=n and get "DFU failed: Encryption is insufficient.".  Can you change that and test again? Also please upload log from nRF if it still does not work, not only log from the DFU master.

  • Hi Einar,

      Can you please reconfirm the below contents

    added these lines in prj.conf

    # Added for FOTA
    CONFIG_BOOTLOADER_MCUBOOT=y
    CONFIG_MCUMGR=y
    CONFIG_MCUMGR_CMD_OS_MGMT=y
    CONFIG_MCUMGR_CMD_IMG_MGMT=y
    CONFIG_MCUMGR_SMP_BT=y
    CONFIG_MCUMGR_SMP_BT_AUTHEN=n
    CONFIG_IMG_ERASE_PROGRESSIVELY=y

    prj.conf

    #
    # Copyright (c) 2018 Nordic Semiconductor
    #
    # SPDX-License-Identifier: LicenseRef-BSD-5-Clause-Nordic
    #
    CONFIG_NCS_SAMPLES_DEFAULTS=y
    
    CONFIG_BT=y
    CONFIG_BT_PERIPHERAL=y
    CONFIG_BT_DEVICE_NAME="Nordic_Blinky"
    
    
    # Enable the LBS service
    CONFIG_BT_LBS=y
    CONFIG_BT_LBS_POLL_BUTTON=y
    CONFIG_DK_LIBRARY=y
    
    # Added for FOTA
    CONFIG_BOOTLOADER_MCUBOOT=y
    CONFIG_MCUMGR=y
    CONFIG_MCUMGR_CMD_OS_MGMT=y
    CONFIG_MCUMGR_CMD_IMG_MGMT=y
    CONFIG_MCUMGR_SMP_BT=y
    CONFIG_MCUMGR_SMP_BT_AUTHEN=n
    CONFIG_IMG_ERASE_PROGRESSIVELY=y
    
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2048
    

    eventhough same error occurs

    I will recreate the project and send you the debug log

    Is any i need to change or add in the

    prj.conf

    CMakeLists

    Kconfig

    sample.yaml

    1. What this bootloader example does in the nrf -> samples->bootloader

    Are we need to upload this bootloader code before the application layer?

  • Hi Einar, Is there any exisiting example or you have develpoed any example code for this FOTA for nRF52832? please share those details so that i can recheck with each steps.

  • Hi,

    You can refer to the SMP server sample. Note that some of the zephyr documentation does not apply, as the NCS build system will handle image signing etc. automatically for you. This will also build both the application and mcuboot in one go. You need to flash both or the merged hex.

    Then to test DFU update, make sure to rebuild to get a new timestamp so that the app gets a new hash. Then pick the app_update.bin file, which is the signed upgrade image and use that to perform DFU. It should work out of the box.

    Your prj.cof look sensible. Essentialy you neeed most of the config from zephyr\samples\subsys\mgmt\mcumgr\smp_svr\prj.conf and overlay-bt.conf or overlay-bt-tiny.conf.

    Einar

Related