Unable to do FOTA using Bluetooth and external flash memory

I would like to do a FOTA using bluetooth and external flash memory on nrf52840 board. I am also using sdk 2.9.1
The issue i am currently facing is I get the below when i run my program                                                                                                                                                                                               

*** Booting MCUboot v2.1.0-dev-12e5ee106034 ***
*** Using nRF Connect SDK v2.9.1-60d0d6c8d42d ***
*** Using Zephyr OS v3.7.99-ca954a6216c9 ***
I: Starting bootloader
W: Cannot upgrade: not a compatible amount of sectors
D: slot0 sectors: 242, slot1 sectors: 256, usable slot0 sectors: 240
I: Bootloader chainload address offset: 0xc000

I have already looked at this link  OTA device firmware update with external flash memory  but i still get the same error even after implementing the recommendations in my mcuboot.conf file.

Below is my pm_static.yml file where I have created a partition for mcuboot_secondary slot of size 1MB

storage1_partition:
  address:     0x00000000      # 0 KB
  size:        0x00004000      # 16 KB
  end_address: 0x00004000
  region:      external_flash
  device:      DT_CHOSEN(nordic_pm_ext_flash)
  placement:
    before: [tfm_storage, end]

storage2_partition:
  address:     0x00004000      # 16 KB
  size:        0x00004000      # 16 KB
  end_address: 0x00008000
  region:      external_flash
  device:      DT_CHOSEN(nordic_pm_ext_flash)
  placement:
    before: [tfm_storage, end]

storage3_partition:
  address:     0x00008000      # 32 KB
  size:        0x00004000      # 16 KB
  end_address: 0x0000C000
  region:      external_flash
  device:      DT_CHOSEN(nordic_pm_ext_flash)
  placement:
    before: [tfm_storage, end]

littlefs_partition:
  address:     0x0000C000      # 48 KB
  size:        0x00080000      # 512 KB
  end_address: 0x0008C000
  region:      external_flash
  device:      DT_CHOSEN(nordic_pm_ext_flash)
  placement:
    before: [tfm_storage, end]

mcuboot_secondary:
  address:     0x0008C000      # 560 KB
  size:        0x00100000      # 1 MB
  end_address: 0x0018C000
  region:      external_flash
  device:      DT_CHOSEN(nordic_pm_ext_flash)
  placement:
    before: [tfm_storage, end]

resources_partition:
  address:     0x0018C000      # 1.5 MB + 32 KB = 1.56 MB
  size:        0x00400000      # 4 MB
  end_address: 0x0058C000
  region:      external_flash
  device:      DT_CHOSEN(nordic_pm_ext_flash)
  placement:
    before: [tfm_storage, end]


below is my mcuboot.conf file where I set 

CONFIG_BOOT_MAX_IMG_SECTORS to 256


CONFIG_MCUBOOT_LOG_LEVEL_DBG=y
#CONFIG_BOOT_UPGRADE_ONLY=y
CONFIG_MCUBOOT_DOWNGRADE_PREVENTION=y

# Enable QSPI and secondary external slot
CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y
CONFIG_NORDIC_QSPI_NOR=y
CONFIG_FLASH=y
CONFIG_MULTITHREADING=y
CONFIG_BOOT_MAX_IMG_SECTORS=256

Below is my mcuboot.overlay file where I have enabled external flash memory
/ {
    chosen {
        nordic,pm-ext-flash = &mx25r64;
    };
};

below is my sysbuild.conf file
SB_CONFIG_BOOTLOADER_MCUBOOT=y
SB_CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y
SB_CONFIG_PM_OVERRIDE_EXTERNAL_DRIVER_CHECK=y 

below is my nrf52840_partition.dtsi
&flash0 {
	partitions {
		compatible = "fixed-partitions";
		#address-cells = <1>;
		#size-cells = <1>;

		boot_partition: partition@0 {
			label = "mcuboot";
			reg = <0x00000000 0x0000C000>;
		};
		slot0_partition: partition@c000 {
			label = "image-0";
			reg = <0x0000C000 0x00077000>;
		};
		slot1_partition: partition@83000 {
			label = "image-1";
			reg = <0x00083000 0x00075000>;
		};

		/*
		 * The flash starting at 0x000f8000 and ending at
		 * 0x000fffff is reserved for use by the application.
		 */

		/*
		 * Storage partition will be used by FCB/LittleFS/NVS
		 * if enabled.
		 */
		storage_partition: partition@f8000 {
			label = "storage";
			reg = <0x000f8000 0x00008000>;
		};
	};
};


what could be the issue causing the error? And what do i need to configure that i have not configured
Parents
  • Hello,

    Please refer to the Academy course on DFU with external flash and make sure you have configured both the application and MCUboot correctly. You can find the same application example here.

    Kind regards,
    Abhijith

  • Hello,
    I had already gone through the DFU example with external flash and it runs well. However in my implementation I have partitions in my external flash memory and am using partition manager.
    I created a partition named mcuboot_secondary of 1MB as shown in my pm_static.yml file and also included the partition in my overlay file as shown below.

    &mx25r64 {
        partitions {
            compatible = "fixed-partitions";
            #address-cells = <1>;
            #size-cells = <1>;
    
            storage1_partition: partition@0 {
                label = "storage1";
                reg = <0x00000000 0x00004000>;  /* 16KB */
                //reg = <0x00000000 DT_SIZE_K(16)>;  /* 16 kb */
            };
            storage2_partition: partition@4000 {
                label = "storage2";
                reg = <0x00004000 0x00004000>;  /* 16KB */
            };
            storage3_partition: partition@8000 {
                label = "storage3";
                reg = <0x00008000 0x00004000>;  /* 16KB */
            };
            littlefs_partition: partition@C000 {
                label = "littlefs";
                reg = <0x0000C000 0x00080000>;  /* 512 KiB */
            };
            mcuboot_secondary: partition@8C000 {
                label = "ota";
                reg = <0x0008C000 0x00100000>; /* 1MB */
            };
            resources_partition: partition@18C000 {
                label = "resources";
                reg = <0x0018C000 0x00400000>;  /* 4 MB */
            };
        };
    };


    This error "W: Cannot upgrade: not a compatible amount of sectors" is as a result of the partitions I have created and most probably the value of CONFIG_BOOT_MAX_IMG_SECTORS which I set to 256.

    Is there a setting I need to put in my mcuboot.conf in regards to the partition manager? Or how do I resolve this issue?

Reply
  • Hello,
    I had already gone through the DFU example with external flash and it runs well. However in my implementation I have partitions in my external flash memory and am using partition manager.
    I created a partition named mcuboot_secondary of 1MB as shown in my pm_static.yml file and also included the partition in my overlay file as shown below.

    &mx25r64 {
        partitions {
            compatible = "fixed-partitions";
            #address-cells = <1>;
            #size-cells = <1>;
    
            storage1_partition: partition@0 {
                label = "storage1";
                reg = <0x00000000 0x00004000>;  /* 16KB */
                //reg = <0x00000000 DT_SIZE_K(16)>;  /* 16 kb */
            };
            storage2_partition: partition@4000 {
                label = "storage2";
                reg = <0x00004000 0x00004000>;  /* 16KB */
            };
            storage3_partition: partition@8000 {
                label = "storage3";
                reg = <0x00008000 0x00004000>;  /* 16KB */
            };
            littlefs_partition: partition@C000 {
                label = "littlefs";
                reg = <0x0000C000 0x00080000>;  /* 512 KiB */
            };
            mcuboot_secondary: partition@8C000 {
                label = "ota";
                reg = <0x0008C000 0x00100000>; /* 1MB */
            };
            resources_partition: partition@18C000 {
                label = "resources";
                reg = <0x0018C000 0x00400000>;  /* 4 MB */
            };
        };
    };


    This error "W: Cannot upgrade: not a compatible amount of sectors" is as a result of the partitions I have created and most probably the value of CONFIG_BOOT_MAX_IMG_SECTORS which I set to 256.

    Is there a setting I need to put in my mcuboot.conf in regards to the partition manager? Or how do I resolve this issue?

Children
No Data
Related