MCUBOOT DFU Over Bluetooth Fails During Firmware Download – Need Help

"I'm trying to perform DFU using MCUBOOT over Bluetooth. The device enters DFU mode and connects successfully, but when I start the firmware download, I get an error:


Starting Bluetooth Peripheral LBS example
I: SoftDevice Controller build revision:
I: d6 da c7 ae 08 db 72 6f |......ro
I: 2a a3 26 49 2a 4d a8 b3 |*.&I*M..
I: 98 0e 07 7f |....
I: HW Platform: Nordic Semiconductor (0x0002)
I: HW Variant: nRF52x (0x0002)
I: Firmware: Standard Bluetooth controller (0x00) Version 214.51162 Build 1926957230
I: Identity: F6:41:05:EF:F1:85 (random)
I: HCI: version 5.4 (0x0d) revision 0x11fb, manufacturer 0x0059
I: LMP: version 5.4 (0x0d) subver 0x11fb
Bluetooth initialized
Advertising successfully started
E: invalid address: 0x001edff0:16
I: Secondary image of image pair (0.) is unreachable. Treat it as empty
I: Image index: 0, Swap type: none
E: invalid address: 0x001edff0:16
I: Secondary image of image pair (0.) is unreachable. Treat it as empty
I: Image index: 0, Swap type: none
E: invalid address: 0x001edff0:16
I: Secondary image of image pair (0.) is unreachable. Treat it as empty
I: Image index: 0, Swap type: none
E: Incorrect parameter
E: Irrecoverable error: flash write failed: 10


Below is my pm_static.yml file:


mcuboot:
  address: 0x0
  size: 0xc000
  region: flash_primary

mcuboot_pad:
  address: 0xc000
  size: 0x200
  region: flash_primary

mcuboot_primary:
  address: 0xc000
  size: 0xf1000
  region: flash_primary

app:
  address: 0xc200
  size: 0xe4e00
  region: flash_primary

mcuboot_secondary:
  address: 0xfd000
  size: 0xf1000
  region: flash_primary

second_storage:
  address: 0x1ee000
  size: 0x4000
  region: flash_primary
  placement:
    align:
      start: 0x1000
    before:
    - zboss_nvram

zboss_nvram:
  address: 0x1f2000
  size: 0x8000
  region: flash_primary
  placement:
    after:
    - second_storage
    align:
      start: 0x1000

zboss_product_config:
  address: 0x1fa000
  size: 0x1000
  region: flash_primary
  placement:
    after:
    - zboss_nvram

settings_storage:
  address: 0x1fb000
  size: 0x2000
  region: flash_primary
  placement:
    align:
      start: 0x1000
    before:
    - end

sram_primary:
  address: 0x20000000
  end_address: 0x20040000
  region: sram_primary
  size: 0x40000

Below is my mcuboot.conf file:

CONFIG_CLOCK_CONTROL_NRF_K32SRC_RC=y
CONFIG_CLOCK_CONTROL_NRF_K32SRC_500PPM=y
CONFIG_BOOT_MAX_IMG_SECTORS=256


I am using nRF Connect SDK v2.7.0 and Toolchain v2.7.0

Parents
  • Hi Dalvadi,

    it seems to me that your pm_static.yml is configured wrong.
    The nRF52840 has 1MB flash so the max address usable is 0xFFFFF.
    According to your pm_static your secondary partition starts at 0xFD000 and goes till 0x1EE000 which already exceeds the 1MB flash.

    May I ask how you got this pm_static?

    Kind regards
    Johannes

  • Hi Johannes,

    Thank you for your suggestion. You are correct that the secondary partition exceeds the 1MB flash limit of the nRF52840. I am using additional storage for data logging, and I also need to support DFU updates.

    Can you provide a correct pm_static.yml configuration that includes some storage space and supports DFU updates while staying within the 1MB flash limit of the nRF52840?

    Best regards,
    Dalvadi

Reply
  • Hi Johannes,

    Thank you for your suggestion. You are correct that the secondary partition exceeds the 1MB flash limit of the nRF52840. I am using additional storage for data logging, and I also need to support DFU updates.

    Can you provide a correct pm_static.yml configuration that includes some storage space and supports DFU updates while staying within the 1MB flash limit of the nRF52840?

    Best regards,
    Dalvadi

Children
  • Hi Dalvadi,

    in your case I think it should look something like this:

    mcuboot:
      address: 0x0
      size: 0xc000
      region: flash_primary
    
    mcuboot_pad:
      address: 0xc000
      size: 0x200
      region: flash_primary
    
    mcuboot_primary:
      address: 0xc000
      size: 0x72000
      region: flash_primary
    
    app:
      address: 0xc200
      size: 0x71E00
      region: flash_primary
    
    mcuboot_secondary:
      address: 0x7e000
      size: 0x73000
      region: flash_primary
    
    second_storage:
      address: 0xf1000
      size: 0x4000
      region: flash_primary
      placement:
        align:
          start: 0x1000
        before:
        - zboss_nvram
    
    zboss_nvram:
      address: 0xf5000
      size: 0x8000
      region: flash_primary
      placement:
        after:
        - second_storage
        align:
          start: 0x1000
    
    zboss_product_config:
      address: 0xfd000
      size: 0x1000
      region: flash_primary
      placement:
        after:
        - zboss_nvram
    
    settings_storage:
      address: 0xfe000
      size: 0x2000
      region: flash_primary
      placement:
        align:
          start: 0x1000
        before:
        - end
    
    sram_primary:
      address: 0x20000000
      end_address: 0x20040000
      region: sram_primary
      size: 0x40000

    Kind regards,
    Johannes

  • Hi Johannes,

    I try using this but not work for me getting this error.

    -- Found partition manager static configuration: /Users/nistantritech/Documents/Project/firmware_project/hazelnut_zigbee-master/ESPZIG_Single_Project/pm_static.yml
    Partition 'zboss_nvram' is not included in the dynamic resolving since it is statically defined.
    Partition 'zboss_product_config' 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.
    Partition manager failed: Incorrect amount of gaps found in static configuration. There must be exactly one gap in the static configuration to support placing the dynamic partitions (such as 'app'). Gaps found (0): The most common solution to this problem is to fill the smallest of these gaps with statically defined partition(s) until there is only one gap left. Alternatively re-order the already defined static partitions so that only one gap remains.
    Failed to partition region flash_primary, size of region: 1048576
    Partition Configuration:
    app:
      size: 466432
    mcuboot:
      size: 49152
    mcuboot_pad:
      size: 512
    mcuboot_primary:
      size: 466944
    mcuboot_secondary:
      size: 471040
    second_storage:
      placement:
        align:
          start: 4096
        before:
        - zboss_nvram
      size: 16384
    settings_storage:
      placement:
        align:
          start: 4096
        before:
        - end
      size: 8192
    zboss_nvram:
      placement:
        after:
        - second_storage
        align:
          start: 4096
      size: 32768
    zboss_product_config:
      placement:
        after:
        - zboss_nvram
      size: 4096
    
    CMake Error at /opt/nordic/ncs/v2.7.0/nrf/cmake/partition_manager.cmake:354 (message):
      Partition Manager failed, aborting.  Command:
      /opt/nordic/ncs/toolchains/f8037e9b83/opt/[email protected]/bin/python3.9;/opt/nordic/ncs/v2.7.0/nrf/scripts/partition_manager.py;--input-files;/Users/nistantritech/Documents/Project/firmware_project/hazelnut_zigbee-master/ESPZIG_Single_Project/build_1/zephyr/include/generated/pm.yml;/Users/nistantritech/Documents/Project/firmware_project/hazelnut_zigbee-master/ESPZIG_Single_Project/build_1/modules/nrf/subsys/partition_manager/pm.yml.settings;/Users/nistantritech/Documents/Project/firmware_project/hazelnut_zigbee-master/ESPZIG_Single_Project/build_1/modules/nrf/subsys/partition_manager/pm.yml.zboss;--regions;sram_primary;flash_primary;--output-partitions;/Users/nistantritech/Documents/Project/firmware_project/hazelnut_zigbee-master/ESPZIG_Single_Project/build_1/partitions.yml;--output-regions;/Users/nistantritech/Documents/Project/firmware_project/hazelnut_zigbee-master/ESPZIG_Single_Project/build_1/regions.yml;--static-config;/Users/nistantritech/Documents/Project/firmware_project/hazelnut_zigbee-master/ESPZIG_Single_Project/pm_static.yml;--sram_primary-size;0x40000;--sram_primary-base-address;0x20000000;--sram_primary-placement-strategy;complex;--sram_primary-dynamic-partition;sram_primary;--flash_primary-size;0x100000;--flash_primary-base-address;0x0;--flash_primary-placement-strategy;complex;--flash_primary-device;flash_controller;--flash_primary-default-driver-kconfig;CONFIG_SOC_FLASH_NRF
    Call Stack (most recent call first):
      /opt/nordic/ncs/v2.7.0/zephyr/cmake/modules/kernel.cmake:253 (include)
      /opt/nordic/ncs/v2.7.0/zephyr/cmake/modules/zephyr_default.cmake:141 (include)
      /opt/nordic/ncs/v2.7.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:66 (include)
      /opt/nordic/ncs/v2.7.0/zephyr/share/zephyr-package/cmake/ZephyrConfig.cmake:92 (include_boilerplate)
      CMakeLists.txt:9 (find_package)
    
    
    -- Configuring incomplete, errors occurred!
    See also "/Users/nistantritech/Documents/Project/firmware_project/hazelnut_zigbee-master/ESPZIG_Single_Project/build_1/CMakeFiles/CMakeOutput.log".
    See also "/Users/nistantritech/Documents/Project/firmware_project/hazelnut_zigbee-master/ESPZIG_Single_Project/build_1/CMakeFiles/CMakeError.log".
    FATAL ERROR: command exited with status 1: /opt/nordic/ncs/toolchains/f8037e9b83/bin/cmake -DWEST_PYTHON=/opt/nordic/ncs/toolchains/f8037e9b83/opt/[email protected]/bin/python3.9 -B/Users/nistantritech/Documents/Project/firmware_project/hazelnut_zigbee-master/ESPZIG_Single_Project/build_1 -GNinja -DBOARD=nrf21540dk/nrf52840 -DNCS_TOOLCHAIN_VERSION=NONE -DCONF_FILE=prj.conf -DDTC_OVERLAY_FILE=nrf21540dk_nrf52840.overlay -DBOARD_ROOT=/Users/nistantritech/Documents/Project/firmware_project/hazelnut_zigbee-master/ESPZIG_Single_Project -S/Users/nistantritech/Documents/Project/firmware_project/hazelnut_zigbee-master/ESPZIG_Single_Project
    
     *  The terminal process terminated with exit code: 1. 
     *  Terminal will be reused by tasks, press any key to close it. 

    Best regards,
    Dalvadi

  • Hi Dalvadi,

    ok, so far I haven't seen this error.

    Could you try this partition config instead?

    app:
      address: 0xc200
      end_address: 0x7e000
      region: flash_primary
      size: 0x71e00
    mcuboot:
      address: 0x0
      end_address: 0xc000
      placement:
        align:
          end: 0x1000
        before:
        - mcuboot_primary
      region: flash_primary
      size: 0xc000
    mcuboot_pad:
      address: 0xc000
      end_address: 0xc200
      placement:
        align:
          start: 0x1000
        before:
        - mcuboot_primary_app
      region: flash_primary
      size: 0x200
    mcuboot_primary:
      address: 0xc000
      end_address: 0x7e000
      orig_span: &id001
      - mcuboot_pad
      - app
      region: flash_primary
      sharers: 0x1
      size: 0x72000
      span: *id001
    mcuboot_primary:
      address: 0xc200
      end_address: 0x7e000
      orig_span: &id002
      - app
      region: flash_primary
      size: 0x71e00
      span: *id002
    mcuboot_secondary:
      address: 0x7e000
      end_address: 0xf1000
      placement:
        after:
        - mcuboot_primary
        align:
          start: 0x1000
      region: flash_primary
      size: 0x73000
    second_storage:
      address: 0xf1000
      end_address: 0xf5000
      placement:
        align:
          start: 0x1000
        after:
        - mcuboot_secondary
      region: flash_primary
      size: 0x4000
    zboss_nvram:
      address: 0xf5000
      end_address: 0xfd000
      placement:
        after:
        - second_storage
        align:
          start: 0x1000
      region: flash_primary
      size: 0x8000
    zboss_product_config:
      address: 0xfd000
      end_address: 0xfe000
      placement:
        after:
        - zboss_nvram
        align:
          start: 0x1000
      region: flash_primary
      size: 0x1000
    settings_storage:
      address: 0xfe000
      end_address: 0x100000
      placement:
        align:
          start: 0x1000
        before:
        - end
      region: flash_primary
      size: 0x2000
    sram_primary:
      address: 0x20000000
      end_address: 0x20040000
      region: sram_primary
      size: 0x40000

    Alternatively you could remove pm_static.yml, rebuild your project and take a look at build/partitions.yml. This is the automatically generated partition config. You can than copy this file, rename it and use it as a new pm_static.yml and make changes according to your needs

    Kind regards,
    Johannes

Related