BLE DFU with Zephyr OS

Hello,

I'm tring to get OAD DFU working on an nrf52840 using Zephyr OS. Relevant information:

  • Host OS: Ubuntu 22.04, kernel 6.5.0
  • Zephyr SDK Version: 0.16.3
  • MCUBoot Version: 2.0.0

The problem is when I build my project, which I modified from the peripheral_hr project, I get the following build errors:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
$ west build -p -b nrf52840dk_nrf52840 dfu-oad/ -d build-dfu-oad -- -DCONFIG_MCUBOOT_SIGNATURE_KEY_FILE=\"bootloader/mcuboot/root-rsa-2048.pem\" [56/173]-- west build: making build dir /home/thomasokeeffe/Documents/school/drexel/research/CTS_sensor/zephyrproject/build-dfu-oad pristine
-- west build: generating a build system
Loading Zephyr default modules (Zephyr base).
-- Application: /home/thomasokeeffe/Documents/school/drexel/research/CTS_sensor/zephyrproject/dfu-oad
-- CMake version: 3.27.4
-- Found Python3: /home/thomasokeeffe/Documents/school/drexel/research/CTS_sensor/zephyrproject/.venv/bin/python3 (found suitable version "3.10.12", minimum required is "3.8") found components: Interpreter
-- Cache files will be written to: /home/thomasokeeffe/.cache/zephyr
-- Zephyr version: 3.5.99 (/home/thomasokeeffe/Documents/school/drexel/research/CTS_sensor/zephyrproject/zephyr)
-- Found west (found suitable version "1.2.0", minimum required is "0.14.0")
-- Board: nrf52840dk_nrf52840
-- ZEPHYR_TOOLCHAIN_VARIANT not set, trying to locate Zephyr SDK
-- Found host-tools: zephyr 0.16.3 (/opt/zephyr-sdk-0.16.3)
-- Found toolchain: zephyr 0.16.3 (/opt/zephyr-sdk-0.16.3)
-- Found Dtc: /opt/zephyr-sdk-0.16.3/sysroots/x86_64-pokysdk-linux/usr/bin/dtc (found suitable version "1.6.0", minimum required is "1.4.6")
-- Found BOARD.dts: /home/thomasokeeffe/Documents/school/drexel/research/CTS_sensor/zephyrproject/zephyr/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840.dts
-- Generated zephyr.dts: /home/thomasokeeffe/Documents/school/drexel/research/CTS_sensor/zephyrproject/build-dfu-oad/zephyr/zephyr.dts
-- Generated devicetree_generated.h: /home/thomasokeeffe/Documents/school/drexel/research/CTS_sensor/zephyrproject/build-dfu-oad/zephyr/include/generated/devicetree_generated.h
-- Including generated dts.cmake file: /home/thomasokeeffe/Documents/school/drexel/research/CTS_sensor/zephyrproject/build-dfu-oad/zephyr/dts.cmake
Parsing /home/thomasokeeffe/Documents/school/drexel/research/CTS_sensor/zephyrproject/zephyr/Kconfig
Loaded configuration '/home/thomasokeeffe/Documents/school/drexel/research/CTS_sensor/zephyrproject/zephyr/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840_defconfig'
Merged configuration '/home/thomasokeeffe/Documents/school/drexel/research/CTS_sensor/zephyrproject/dfu-oad/prj.conf'
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

I am able to build and flash the USB DFU example project, and update the image via DFU, so I know my setup is functioning.

I have attached the relevant code and config files. I was attempting to follow this guide: https://getwavecake.com/blog/adding-ota-dfu-to-a-nordic-zephyr-project/. I ran into some problems with the KConfig options, but I think I found a solution to that here: DFU with nrf connect 2.4. However, with those changes I get the above build error. Please let me know what I can do to fix this.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/* main.c - Application main entry point */
/*
* Copyright (c) 2015-2016 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <zephyr/types.h>
#include <stddef.h>
#include <string.h>
#include <errno.h>
#include <zephyr/sys/printk.h>
#include <zephyr/sys/byteorder.h>
#include <zephyr/kernel.h>
#include <zephyr/logging/log.h>
#include <zephyr/usb/usb_device.h>
#include <zephyr/bluetooth/bluetooth.h>
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

4670.prj.conf

Parents
  • Hi,

    • Zephyr SDK Version: 0.16.3
    • MCUBoot Version: 2.0.0

    Our support is based on nRF Connect SDK (NCS), so I would suggest you use the latest NCS v.2.5.0. Check out this similar question with NCS v2.5.0. 

    Regards,
    Amanda H.

  • Hi, I installed NCS v2.5.0 and rebuilt the same project in the NCS environment. It appears to be the same error. Here is the full build output:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    $ west build -p -b nrf52840dk_nrf52840 dfu-oad/ -d build-dfu-oad -- -DCONFIG_MCUBOOT_SIGNATURE_KEY_FILE=\"bootloader/mcuboot/root-rsa-2048.pem\" [117/4130]
    -- west build: generating a build system
    Loading Zephyr default modules (Zephyr base).
    -- Application: /home/thomasokeeffe/Documents/school/drexel/research/CTS_sensor/ncs/dfu-oad
    -- CMake version: 3.27.5
    -- Found Python3: /home/thomasokeeffe/Documents/school/drexel/research/CTS_sensor/ncs/.venv/bin/python3 (found suitable version "3.10.12", minimum required is "3.8") found components: Interpreter
    -- Cache files will be written to: /home/thomasokeeffe/.cache/zephyr
    -- Zephyr version: 3.4.99 (/home/thomasokeeffe/Documents/school/drexel/research/CTS_sensor/ncs/zephyr)
    -- Found west (found suitable version "1.2.0", minimum required is "0.14.0")
    -- Board: nrf52840dk_nrf52840
    -- ZEPHYR_TOOLCHAIN_VARIANT not set, trying to locate Zephyr SDK
    -- Found host-tools: zephyr 0.16.3 (/opt/zephyr-sdk-0.16.3)
    -- Found toolchain: zephyr 0.16.3 (/opt/zephyr-sdk-0.16.3)
    -- Found Dtc: /opt/zephyr-sdk-0.16.3/sysroots/x86_64-pokysdk-linux/usr/bin/dtc (found suitable version "1.6.0", minimum required is "1.4.6")
    -- Found BOARD.dts: /home/thomasokeeffe/Documents/school/drexel/research/CTS_sensor/ncs/zephyr/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840.dts
    -- Generated zephyr.dts: /home/thomasokeeffe/Documents/school/drexel/research/CTS_sensor/ncs/build-dfu-oad/zephyr/zephyr.dts
    -- Generated devicetree_generated.h: /home/thomasokeeffe/Documents/school/drexel/research/CTS_sensor/ncs/build-dfu-oad/zephyr/include/generated/devicetree_generated.h
    -- Including generated dts.cmake file: /home/thomasokeeffe/Documents/school/drexel/research/CTS_sensor/ncs/build-dfu-oad/zephyr/dts.cmake
    Parsing /home/thomasokeeffe/Documents/school/drexel/research/CTS_sensor/ncs/zephyr/Kconfig
    Loaded configuration '/home/thomasokeeffe/Documents/school/drexel/research/CTS_sensor/ncs/zephyr/boards/arm/nrf52840dk_nrf52840/nrf52840dk_nrf52840_defconfig'
    Merged configuration '/home/thomasokeeffe/Documents/school/drexel/research/CTS_sensor/ncs/dfu-oad/prj.conf'
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Are you including the files as this similar post? If so, remove them. They are not required in v2.5.0.  

  • Yes I'm familiar with that post. I get the same error if I comment out lines 28 and 29.

  • Hi, 

    Make sure clean and build if you comment out lines 28 and 29. 

    You can refer to NCS v2.5.0 https://github.com/nrfconnect/sdk-zephyr/tree/v3.4.99-ncs1/samples/subsys/mgmt/mcumgr/smp_svr 

    -Amanda H.

  • Thank you for the updated code. I can now see the board advertising in the nRF Connect app on my android phone. However, when I click the DFU button and select the dfu application zip file that I generated from the blinky example, I see the following in the app log:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    nRF Connect, 2023-12-01
    Zephyr Heartrate Sensor (CF:CD:B0:4A:9E:BF)
    V 13:51:32.784 [McuMgr] Connecting...
    D 13:51:32.786 [McuMgr] gatt = device.connectGatt(autoConnect = false, TRANSPORT_LE, LE 1M)
    D 13:51:32.810 [McuMgr] [Callback] Connection state changed with status: 0 and new state: 2 (CONNECTED)
    I 13:51:32.812 [McuMgr] Connected to CF:CD:B0:4A:9E:BF
    D 13:51:32.814 [McuMgr] wait(300)
    I 13:51:32.815 [McuMgr] MTU changed to: 498
    V 13:51:33.117 [McuMgr] Discovering services...
    D 13:51:33.124 [McuMgr] gatt.discoverServices()
    I 13:51:33.137 [McuMgr] Services discovered
    V 13:51:33.142 [McuMgr] Primary service found
    D 13:51:33.147 [McuMgr] gatt.setCharacteristicNotification(da2e7828-fbce-4e01-ae9e-261174997c48, true)
    V 13:51:33.153 [McuMgr] Enabling notifications for da2e7828-fbce-4e01-ae9e-261174997c48
    D 13:51:33.158 [McuMgr] gatt.writeDescriptor(00002902-0000-1000-8000-00805f9b34fb, value=0x01-00)
    I 13:51:33.254 [McuMgr] Data written to descr. 00002902-0000-1000-8000-00805f9b34fb
    V 13:51:33.264 [McuMgr] Waiting for value change...
    V 13:51:33.268 [McuMgr] Writing characteristic da2e7828-fbce-4e01-ae9e-261174997c48 (WRITE COMMAND)
    D 13:51:33.270 [McuMgr] gatt.writeCharacteristic(da2e7828-fbce-4e01-ae9e-261174997c48, value=0x000000010000FF06A0, WRITE COMMAND)
    I 13:51:33.277 [McuMgr] Data written to da2e7828-fbce-4e01-ae9e-261174997c48
    I 13:51:33.348 [McuMgr] Notification received from da2e7828-fbce-4e01-ae9e-261174997c48, value: (0x) 01-00-00-06-00-00-FF-06-BF-62-72-63-08-FF
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

  • Hi, 

    Try this peripheral_hr_DFU.7z, and use the sample pm_static.yml to update the image. See Static partition requirement for DFU.

    “Beware that this code/configuration is not fully tested or qualified and should be considered provided “as-is”. Please test it with your application and let me know if you find any issues.”

    -Amanda H.

Reply Children
No Data