Incorrect flash usage report

Hi,

I'm having an issue with flash usage reporting when building app. I'm using MCUBoot, so 2 images are generated.

First of all, my definition of partitions in an overlay file is the following (Original board is arduino nicla sense me).

I'm defining just slot0_partition as I will only update fw in serial recovery mode.

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

		boot_partition: partition@0 {
			label = "mcuboot";
			reg = <0x0 0xc000>;
		};
		slot0_partition: partition@c000 {
			label = "image-0";
			reg = <0xc000 0x6e000>;
		};
		storage_partition: partition@7a000 {
			label = "storage";
			reg = <0x7a000 0x6000>;
		};
	};
};

When I build the code, I receive these 2 memory usage reports:

Memory region         Used Size  Region Size  %age Used
           FLASH:       35288 B        48 KB     71.79%
            SRAM:       24800 B        64 KB     37.84%
        IDT_LIST:          0 GB         2 KB      0.00%

First one has sense and I suppose it corresponds to MCUboot, as 48KB is exactly 0xc000.

Memory region         Used Size  Region Size  %age Used
           FLASH:      186104 B     232960 B     79.89%
            SRAM:       63497 B        64 KB     96.89%
        IDT_LIST:          0 GB         2 KB      0.00%

However, in the second one I can not understand the source of 232960 B region size. Shouldn't be 440KB (0x6e000)??

I also tried splitting into slot0 and slot1 but 232960 B region size keeps unmodified.

Thanks and best regards,

Pedro.

Parents
  • Hi Pedro, 

    When you enable MCUBoot, Partition Manager will also be used and the overlay dts partition will not be used. Instead, you will find a file called partitions.yml  in the build folder which is the actual partition used. 
    You will have something like this: 

    app:
      address: 0xc200
      end_address: 0x46000
      region: flash_primary
      size: 0x39e00
    mcuboot:
      address: 0x0
      end_address: 0xc000
      placement:
        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: 0x46000
      orig_span: &id001
      - mcuboot_pad
      - app
      region: flash_primary
      sharers: 0x1
      size: 0x3a000
      span: *id001
    mcuboot_primary_app:
      address: 0xc200
      end_address: 0x46000
      orig_span: &id002
      - app
      region: flash_primary
      size: 0x39e00
      span: *id002
    mcuboot_secondary:
      address: 0x46000
      end_address: 0x80000
      placement:
        after:
        - mcuboot_primary
        align:
          start: 0x1000
        align_next: 0x1000
      region: flash_primary
      share_size:
      - mcuboot_primary
      size: 0x3a000
    sram_primary:
      address: 0x20000000
      end_address: 0x20010000
      region: sram_primary
      size: 0x10000
    

    You can see the mcuboot_primary_app size will be 0x39e00 or 0x38E00 . 

    By default the MCUBoot will configure the main flash into two partitions : primary and secondary. This is to support dual bank DFU update. 
    I'm not sure if there is a way to disable this, but one work around is to copy the file partitions.yml and call it pm_static.yml. Put it to the root folder of the project and then modify the mcuboot_primary and mcuboot_secondary to make the size of mcuboot_primary  cover the whole flash and mcuboot_secondary  has zero size. 

  • Hi Hung,

    Thank you for your answer. I've deleted partitions definition in overlay dts and used pm_static.yml instead and it works.

    I have a question about different sections of this file, because for me it seems to be redundant information.

    What are the differences between app, mcuboot_primary and mcuboot_primary_app sections? I changed addresses and size in the 3, but I also noticed changing just mcuboot_primary also works (Seems to be ignoring app and mcuboot_primary_app). 

    Why there is mcuboot_secondary but no mcuboot_secondary_app?

    Regards,

    Pedro.

  • Hi Pedro, 

    As far as I know, MCUBoot expects two partititions, mcuboot_primary and mcuboot_secondary. 

    mcuboot_primary contains the mcuboot_primary_app (where the application located) and the mcuboot_pad (where the padding is) 

    The app partition could be a redundancy here because it would be identical to the mcuboot_primary_app. 

     There is no point of having mcuboot_secondary_app because the app is not executed at the secondary lot. And padding not needed. It's simply the place where the new image is copied to. 

Reply Children
No Data
Related