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

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/*
* 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>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

prj.conf

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#
# 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
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

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

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
*** 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
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Log from the nrf connect APP

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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)
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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)
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

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:

    Fullscreen
    1
    2
    CONFIG_LOG_DEFAULT_LEVEL=4
    CONFIG_DEBUG_OPTIMIZATIONS=y
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • 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

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    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).
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Hi Einar, Have you test the uploaded zip file?

  • 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.

Reply
  • 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.

Children
  • 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

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    #
    # 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
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    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

  • Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    nRF Connect, 2021-03-17
    dfu_Nordic_Blinky (DC:CA:E1:CE:C3:8A)
    V 23:10:24.860 Connecting to DC:CA:E1:CE:C3:8A...
    D 23:10:24.860 gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE, preferred PHY = LE 1M)
    D 23:10:25.353 [Broadcast] Action received: android.bluetooth.device.action.ACL_CONNECTED
    D 23:10:25.416 [Callback] Connection state changed with status: 0 and new state: CONNECTED (2)
    I 23:10:25.416 Connected to DC:CA:E1:CE:C3:8A
    V 23:10:25.457 Discovering services...
    D 23:10:25.458 gatt.discoverServices()
    I 23:10:25.598 Connection parameters updated (interval: 7.5ms, latency: 0, timeout: 5000ms)
    D 23:10:25.957 [Callback] Services discovered with status: 0
    I 23:10:25.957 Services discovered
    V 23:10:25.988 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)
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    from android nrf connect

    last line show uploading firmware but no movement 

  • I got this kind of message in debug mode

    [00:00:00.536,285] [0m<inf> mcuboot: Starting bootloader[0m
    [00:00:00.542,572] [0m<inf> mcuboot: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3[0m
    [00:00:00.552,917] [0m<inf> mcuboot: Boot source: none[0m
    [00:00:00.558,624] [0m<inf> mcuboot: Swap type: none[0m
    [00:00:00.876,342] [0m<inf> mcuboot: Bootloader chainload address offset: 0xc000[0m
    [00:00:00.271,789] [0m<inf> mcuboot: Starting bootloader[0m
    [00:00:00.278,015] [0m<inf> mcuboot: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3[0m
    [00:00:00.288,391] [0m<inf> mcuboot: Boot source: none[0m
    [00:00:00.294,067] [0m<inf> mcuboot: Swap type: perm[0m
    [00:00:00.611,724] [1;33m<wrn> mcuboot: Not enough free space to run swap upgrade[0m
    [00:00:00.932,159] [0m<inf> mcuboot: Bootloader chainload address offset: 0xc000[0m