DFU on nrf52832

Hi, I am having problem making DFU work on nrf52832 using nrf connect sdk 2.6.0.  Below is my mcuboot.conf under child_image and prj.conf. Please guide me where I am wrong. Also when I set CONFIG_SINGLE_APPLICATION_SLOT, it builds fine but when I disables it, it doesn't build due to size issue.

&flash0 {

partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;

boot_partition: partition@0 {
label = "mcuboot";
reg = <0x00000000 0xC000>;
};
slot0_partition: partition@C000 {
label = "image-0";
reg = <0x0000C000 0x2C000>;
};
slot1_partition: partition@38000 {
label = "image-1";
reg = <0x00038000 0x2C000>;
};
storage_partition: partition@64000 {
label = "storage";
reg = <0x00064000 0x4000>;
};
};

};
# Logging
CONFIG_LOG=y
CONFIG_MCUBOOT_LOG_LEVEL_WRN=y
# CONFIG_PM_PARTITION_SIZE_MCUBOOT=0x15000
CONFIG_SINGLE_APPLICATION_SLOT=y

and prj.conf
#
# Copyright (C) 2024 Walk With Path Corp. All Rights Reserved.
# Project Configuration File
#
# This file contains configuration settings for Bluetooth, logging, peripherals,
# memory optimization, DFU support, and other key features for Zephyr-based applications.
#

# ==============================
# General Debugging and Logging
# ==============================

CONFIG_LOG=y # Enable logging framework
CONFIG_LOG_BACKEND_UART=y # Use UART backend for logs
CONFIG_LOG_PRINTK=y # Allow printk for logs
CONFIG_CBPRINTF_FP_SUPPORT=y # Enable floating-point support in logs

# Enable console for debug purposes
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y

CONFIG_DEBUG=y # Enable debugging
CONFIG_PRINTK=y # Enable printk debugging

CONFIG_SHELL=n # Enable Zephyr Shell for debugging
CONFIG_SHELL_LOG_BACKEND=y
CONFIG_SHELL_CMD_BUFF_SIZE=128

# Enable RTT (Real-Time Transfer) for logs (alternative to UART)
CONFIG_USE_SEGGER_RTT=y
CONFIG_LOG_BACKEND_RTT=y
CONFIG_RTT_CONSOLE=y
CONFIG_UART_CONSOLE=y # Disable UART console if RTT is enabled
CONFIG_SEGGER_RTT_BUFFER_SIZE_UP=512
CONFIG_SEGGER_RTT_MODE_BLOCK_IF_FIFO_FULL=y

CONFIG_LOG_BLOCK_IN_THREAD=y
CONFIG_LOG_BUFFER_SIZE=256
CONFIG_DEBUG=y # Enable debugging
CONFIG_DEBUG_INFO=y
CONFIG_DEBUG_THREAD_INFO=y

# CONFIG_NCS_BOOT_BANNER=y # Enable NCS boot banner
CONFIG_BOOT_BANNER=y
CONFIG_PRINTK=y

# Enable UART support
CONFIG_SERIAL=y

# ==============================
# Peripheral and Sensor Drivers
# ==============================

CONFIG_I2C=y # Enable I2C interface
CONFIG_SPI=y # Enable SPI interface
CONFIG_ADC=y # Enable ADC driver

CONFIG_SENSOR=y # Enable generic sensor support
CONFIG_TMP116=y # Enable TMP116 temperature sensor
CONFIG_BMI270=y # Enable BMI270 accelerometer
CONFIG_BMI270_TRIGGER_GLOBAL_THREAD=y

CONFIG_WATCHDOG=y # Enable watchdog timer
CONFIG_WDT_LOG_LEVEL_DBG=y
CONFIG_WDT_DISABLE_AT_BOOT=n

# Enable LED and regulator drivers
CONFIG_LED=y
CONFIG_REGULATOR=y

# Enable power management IC (NPMX)
# CONFIG_NPMX=y
# CONFIG_NPMX_DEVICE_NPM1300=y

# Enable Nordic Fuel Gauge and BMI270 (Accelerometer and Gyroscope)
CONFIG_NRF_FUEL_GAUGE=y

# Disable SPI NOR flash driver (if not used)
CONFIG_SPI_NOR=n

# ==============================
# Power and Memory Optimizations
# ==============================

# Power management configuration
CONFIG_PM_DEVICE=y
CONFIG_PM_DEVICE_RUNTIME=y

# ==============================
# Memory Optimizations
# ==============================

# Configure memory pool and stack sizes
CONFIG_MAIN_STACK_SIZE=2048
CONFIG_HEAP_MEM_POOL_SIZE=1024

# ==============================
# Flash Configuration
# ==============================

CONFIG_FLASH=y # Enable flash memory support
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH_MAP=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y

CONFIG_BT_SETTINGS=y # Enable Bluetooth settings
CONFIG_SETTINGS=y # Enable settings subsystem
CONFIG_NVS=y # Enable Non-Volatile Storage
CONFIG_NVS_LOG_LEVEL_DBG=y

# ==============================
# Bluetooth Settings
# ==============================

CONFIG_NCS_SAMPLES_DEFAULTS=y

# Enable Bluetooth and controller settings
CONFIG_BT=y
CONFIG_BT_HCI=y
CONFIG_BT_CTLR=y
CONFIG_BT_PERIPHERAL=y
CONFIG_BT_BROADCASTER=n
CONFIG_BT_SMP=y
CONFIG_BT_BONDABLE=y
CONFIG_BT_CTLR_ADV_EXT=n
CONFIG_BT_DEVICE_APPEARANCE=1345
CONFIG_BT_DEVICE_NAME_DYNAMIC=y
CONFIG_BT_GATT_CLIENT=y

# Bluetooth security and bonding settings
CONFIG_BT_KEYS_OVERWRITE_OLDEST=y
CONFIG_BT_SMP_ALLOW_UNAUTH_OVERWRITE=y
CONFIG_BT_ID_UNPAIR_MATCHING_BONDS=y
CONFIG_BT_PRIVACY=n
CONFIG_BT_TINYCRYPT_ECC=y
CONFIG_BT_CTLR_PHY_2M=y
CONFIG_BT_USER_PHY_UPDATE=y

# Bluetooth buffer and connection settings
CONFIG_BT_BUF_ACL_RX_SIZE=247
CONFIG_BT_ATT_PREPARE_COUNT=2
CONFIG_BT_BUF_ACL_TX_SIZE=256
CONFIG_BT_BUF_ACL_TX_COUNT=10
CONFIG_BT_L2CAP_TX_MTU=247
CONFIG_BT_L2CAP_TX_BUF_COUNT=10
CONFIG_BT_L2CAP_DYNAMIC_CHANNEL=y
CONFIG_BT_CTLR_DATA_LENGTH_MAX=247
CONFIG_BT_CTLR_RX_BUFFERS=2
CONFIG_BT_CONN_TX_MAX=10
CONFIG_BT_GAP_AUTO_UPDATE_CONN_PARAMS=n

CONFIG_BT_GATT_DM=y

# Allow only LESC pairing
# CONFIG_BT_SMP_SC_PAIR_ONLY=y

# Configure Bluetooth connection settings
CONFIG_BT_CTLR_TX_PWR_0=y
CONFIG_BT_MAX_CONN=1
CONFIG_BT_MAX_PAIRED=1

# Enable PHY updates
CONFIG_BT_USER_PHY_UPDATE=y
CONFIG_BT_USER_DATA_LEN_UPDATE=y

# Enable Bluetooth shell for debugging
CONFIG_BT_SHELL=n

# Enable BT NUS (Nordic UART Service) shell for testing
# CONFIG_SHELL_BT_NUS=y

# Enable Battery Service (BAS) for battery level reporting
CONFIG_BT_BAS=y

# ==============================
# Cryptography
# ==============================

CONFIG_TINYCRYPT=y # Enable TinyCrypt for secure operations
CONFIG_BT_TINYCRYPT_ECC=y

# ==============================
# Reboot and Misc Settings
# ==============================

CONFIG_REBOOT=y # Enable reboot functionality

# ==============================
# DFU Support and Bootloader
# ==============================

# Enable mcumgr.
CONFIG_MCUMGR=y

# Enable MCUboot and FOTA
CONFIG_BOOTLOADER_MCUBOOT=y
# CONFIG_MCUBOOT_SIGNATURE_KEY_FILE="bootloader/mcuboot/root-rsa-2048.pem"
CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU=y
CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU_SPEEDUP=y

# Enable image management
CONFIG_MCUMGR_TRANSPORT_BT=y
CONFIG_MCUMGR_TRANSPORT_BT_AUTHEN=n
CONFIG_MCUMGR_TRANSPORT_BT_CONN_PARAM_CONTROL=y

CONFIG_IMG_MANAGER=n
CONFIG_MCUBOOT_IMG_MANAGER=y
CONFIG_IMG_ERASE_PROGRESSIVELY=y

# Enable logging for mcumgr (DFU)
CONFIG_MCUMGR_LOG_LEVEL_DBG=y
CONFIG_MCUMGR_LOG_LEVEL_INF=y

# Enable logging for image management subsystem
CONFIG_IMG_MANAGER_LOG_LEVEL_DBG=y
CONFIG_IMG_MANAGER_LOG_LEVEL_INF=y

# # Enable mcumgr DFU in application
# # Enable MCUMGR

# # Enable MCUMGR management for both OS and Images
# CONFIG_MCUMGR_GRP_OS=y
# CONFIG_MCUMGR_GRP_IMG=y

# Support for taskstat command
CONFIG_MCUMGR_GRP_OS_TASKSTAT=y

# Enable statistics and statistic names.
CONFIG_STATS=y
CONFIG_STATS_NAMES=y

# Enable most core commands.
CONFIG_MCUMGR_GRP_IMG=y
CONFIG_MCUMGR_GRP_OS=y
CONFIG_MCUMGR_GRP_STAT=y


Parents
  • Hi,

    I recommend you to have a look at this lesson in the intermediate course about bootloaders and DFU https://academy.nordicsemi.com/courses/nrf-connect-sdk-intermediate/lessons/lesson-8-bootloaders-and-dfu-fota/ 

    In short what happens when you don't use CONFIG_SINGLE_APPLICATION_SLOT is that you're using a dual bank DFU, meaning that you cut your available application space in half since you have two application slots. On the first slot, you have your running application, while on the second slot you will temporary store the update image whenever you perform an update.

    This is explained in closer detail in the theory sections before the exercises.

    Let me know if this answers your questions.

    Kind regards,
    Andreas

  • Can I have CONFIG_SINGLE_APPLICATION_SLOT DFU over BLE? 

  • Hi

    Moh said:
    Any chance to have a live session? Thanks Moh

    Unfortunately we typically don't do live sessions and when we do they have to be arranged through your regional sales manager.

    Moh said:
    If I don't include at25xe321d in overlay, mcuboot builds fine and eventually the app

    Ok, this is good since we now have isolated that the issue is with configuring the external flash and presumably that everything else works as it should. Could you post the build log with errors for the unsuccessful build with the external flash (for the setup without using CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU)? I still see in the latest 1581.prj_release.conf that you're using this configuration

    Kind regards,
    Andreas

  • Hi Andreas,

    Please find the log attached. I have also attached the prj_release file. As you can see, I have commented out  CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU. I have also attached log from devicetree.generated.h for undefined __device_dts_ord_105

    /* Node's dependency ordinal: */
    #define DT_N_S_soc_S_i2c_40004000_ORD 105
    #define DT_N_S_soc_S_i2c_40004000_ORD_STR_SORTABLE 00105

    0005.prj_release.conf


    -- west build: building application
    [1/349] Preparing syscall dependency handling
    
    [9/349] Generating include/generated/version.h
    -- Zephyr version: 3.5.99 (/opt/nordic/ncs/v2.6.0/zephyr), build: v3.5.99-ncs1
    [1/271] Preparing syscall dependency handling
    
    [4/271] Generating include/generated/version.h
    -- Zephyr version: 3.5.99 (/opt/nordic/ncs/v2.6.0/zephyr), build: v3.5.99-ncs1
    [266/271] Linking C executable zephyr/zephyr_pre0.elf
    FAILED: zephyr/zephyr_pre0.elf zephyr/zephyr_pre0.map /Users/mohsin/path-feel-zephyr-fw/app/build_release/mcuboot/zephyr/zephyr_pre0.map 
    : && ccache /opt/nordic/ncs/toolchains/580e4ef81c/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc  -gdwarf-4 zephyr/CMakeFiles/zephyr_pre0.dir/misc/empty_file.c.obj -o zephyr/zephyr_pre0.elf  zephyr/CMakeFiles/offsets.dir/./arch/arm/core/offsets/offsets.c.obj  -fuse-ld=bfd  -T  zephyr/linker_zephyr_pre0.cmd  -Wl,-Map=/Users/mohsin/path-feel-zephyr-fw/app/build_release/mcuboot/zephyr/zephyr_pre0.map  -Wl,--whole-archive  app/libapp.a  zephyr/libzephyr.a  zephyr/arch/common/libarch__common.a  zephyr/arch/arch/arm/core/libarch__arm__core.a  zephyr/arch/arch/arm/core/cortex_m/libarch__arm__core__cortex_m.a  zephyr/arch/arch/arm/core/mpu/libarch__arm__core__mpu.a  zephyr/lib/libc/minimal/liblib__libc__minimal.a  zephyr/lib/libc/common/liblib__libc__common.a  zephyr/soc/soc/arm/nordic_nrf/libsoc__arm__nordic_nrf.a  zephyr/drivers/clock_control/libdrivers__clock_control.a  zephyr/drivers/console/libdrivers__console.a  zephyr/drivers/flash/libdrivers__flash.a  zephyr/drivers/gpio/libdrivers__gpio.a  zephyr/drivers/pinctrl/libdrivers__pinctrl.a  zephyr/drivers/serial/libdrivers__serial.a  zephyr/drivers/timer/libdrivers__timer.a  modules/nrf/lib/fprotect/lib..__nrf__lib__fprotect.a  modules/nrf/lib/fatal_error/lib..__nrf__lib__fatal_error.a  modules/mcuboot/boot/bootutil/zephyr/libmcuboot_util.a  modules/mbedtls/libmbedTLSBase.a  modules/mbedtls/libmbedTLSCrypto.a  modules/mbedtls/libmbedTLSX509.a  modules/mbedtls/libmodules__mbedtls.a  modules/hal_nordic/nrfx/libmodules__hal_nordic__nrfx.a  modules/segger/libmodules__segger.a  -Wl,--no-whole-archive  zephyr/kernel/libkernel.a  -L"/opt/nordic/ncs/toolchains/580e4ef81c/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/thumb/v7e-m/nofp"  -L/Users/mohsin/path-feel-zephyr-fw/app/build_release/mcuboot/zephyr  -lgcc  zephyr/arch/common/libisr_tables.a  modules/mbedtls/libmbedTLSBase.a  modules/mbedtls/libmbedTLSCrypto.a  modules/mbedtls/libmbedTLSX509.a  -mcpu=cortex-m4  -mthumb  -mabi=aapcs  -mfp16-format=ieee  -Wl,--gc-sections  -Wl,--build-id=none  -Wl,--sort-common=descending  -Wl,--sort-section=alignment  -Wl,-u,_OffsetAbsSyms  -Wl,-u,_ConfigAbsSyms  -nostdlib  -static  -Wl,-X  -Wl,-N  -Wl,--orphan-handling=warn  -Wl,-no-pie && cd /Users/mohsin/path-feel-zephyr-fw/app/build_release/mcuboot/zephyr && /opt/nordic/ncs/toolchains/580e4ef81c/Cellar/cmake/3.21.0/bin/cmake -E true
    /opt/nordic/ncs/toolchains/580e4ef81c/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: zephyr/drivers/flash/libdrivers__flash.a(spi_nor.c.obj): in function `k_sleep':
    /Users/mohsin/path-feel-zephyr-fw/app/build_release/mcuboot/zephyr/include/generated/syscalls/kernel.h:135: undefined reference to `z_impl_k_sleep'
    /opt/nordic/ncs/toolchains/580e4ef81c/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: /Users/mohsin/path-feel-zephyr-fw/app/build_release/mcuboot/zephyr/include/generated/syscalls/kernel.h:135: undefined reference to `z_impl_k_sleep'
    /opt/nordic/ncs/toolchains/580e4ef81c/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: zephyr/drivers/flash/libdrivers__flash.a(spi_nor.c.obj):(.rodata.spi_nor_config_0+0x0): undefined reference to `__device_dts_ord_105'
    collect2: error: ld returned 1 exit status
    ninja: build stopped: subcommand failed.

  • Moh said:
    Please find the log attached. I have also attached the prj_release file. As you can see, I have commented out 

    My bad, I didn't spot the #.

    Could you check with this sample (and your external flash) if you're able to get the external flash device running? https://docs.zephyrproject.org/latest/samples/drivers/spi_flash/README.html

    You might need to run https://docs.zephyrproject.org/latest/samples/drivers/jesd216/README.html if the parameters in &spi2 is wrong

    &spi2 {
        compatible = "nordic,nrf-spi";
        status = "okay";
        pinctrl-0 = <&spi2_default>;
        pinctrl-1 = <&spi2_sleep>;
        pinctrl-names = "default", "sleep";
        cs-gpios = <&gpio0 16 GPIO_ACTIVE_LOW>;
    
        at25xe321d: at25xe321d@0 {
            #address-cells = <1>;
            #size-cells = <1>;
    		partitions {
    			compatible = "fixed-partitions";
    			#address-cells = <1>;
    			#size-cells = <1>;
    
    			slot1_partition: partition@0 {
    				label = "image-1";
    				reg = <0x0000000 DT_SIZE_K(472)>;
    			};
    			/* to be used in firmware */
    			store_partition: partition@100000 {
    				label = "store";
    				reg = <0x00100000 0x00400000>;
    			};
    		};
    		compatible = "jedec,spi-nor";
            reg = <0>; // Chip select 0
            spi-max-frequency = <100000000>;
            jedec-id = [1F 47 0C];
            // size = <0x400000>;  // 4 MB
    		size = <DT_SIZE_M(4)>;
    		has-dpd;
    		t-enter-dpd = < 3000 >;
    		t-exit-dpd = < 1200000 >;
        };
    };

    Kind regards,
    Andreas

  • Hi Andreas, When I try to build the sample (without mcuboot) with above attached spi2 dts configurations, I got similar error

    /opt/nordic/ncs/toolchains/580e4ef81c/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: zephyr/libzephyr.a(flash_map_default.c.obj):(.rodata.default_flash_map+0x4c): undefined reference to `__device_dts_ord_122'
    /opt/nordic/ncs/toolchains/580e4ef81c/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd: zephyr/libzephyr.a(flash_map_default.c.obj):(.rodata.default_flash_map+0x5c): undefined reference to `__device_dts_ord_122'

    but when I build with without partitions defined, It builds and runs fine.

    &spi2 {
        compatible = "nordic,nrf-spi";
        status = "okay";
        pinctrl-0 = <&spi2_default>;
        pinctrl-1 = <&spi2_sleep>;
        pinctrl-names = "default", "sleep";
        cs-gpios = <&gpio0 16 GPIO_ACTIVE_LOW>;
    	at25xe321d: at25xe321d@0 {
            #address-cells = <1>;
            #size-cells = <1>;
    		compatible = "jedec,spi-nor";
            reg = <0>; // Chip select 0
            spi-max-frequency = <100000000>;
            jedec-id = [1F 47 0C];
            // size = <0x400000>;  // 4 MB
    		size = <DT_SIZE_M(4)>;
    		has-dpd;
    		t-enter-dpd = < 3000 >;
    		t-exit-dpd = < 1200000 >;
        };
    };

  • Do you also get the expected output from the sample, i.e are you able to run it?

    Kind regards,
    Andreas

Reply Children
Related