Problem with data sharing

Hello,

I have a project that contains the b0+mcuboot+app. My project works but now I would like to add "data sharing" in order to retrieve some information in my application about the mcuboot (currently used slot, version number).

I am using the nRF Connext SDK V2.7.0 and I am using the nrf52840DK.

Here is the config I added in my <Project>\Application\boards\<board>.overlay:

/ {
	sram@2003F000 {
		compatible = "zephyr,memory-region", "mmio-sram";
		reg = <0x2003F000 DT_SIZE_K(1)>;
		zephyr,memory-region = "RetainedMem";
		status = "okay";

		retainedmem {
			compatible = "zephyr,retained-ram";
			status = "okay";
			#address-cells = <1>;
			#size-cells = <1>;

			boot_info0: boot_info@0 {
				compatible = "zephyr,retention";
				status = "okay";
				reg = <0x0 0x100>;
			};

			retention1: retention@100 {
				compatible = "zephyr,retention";
				status = "okay";
				reg = <0x100 0x101>;
			};
		};
	};

	/*
	* In some default configurations within the nRF Connect SDK,
	* e.g. on nRF52840, the chosen zephyr,entropy node is &cryptocell.
	* This devicetree overlay ensures that default is overridden wherever it
	* is set, as this application uses the RNG node for entropy exclusively.
	*/
	chosen {
		//zephyr,entropy = &rng;
		zephyr,bootloader-info = &boot_info0;
		//zephyr,boot-mode = &retention1;
	};
};

&sram0 {
	reg = <0x20000000 DT_SIZE_K(255)>;
};

Here is what I put in my <Project>\Application\sysbuild\mcuboot\boards\<board>.overlay:

/* SPDX-License-Identifier: Apache-2.0 */
#include "../../../boards/<board>.overlay"

/ {
	chosen {
		zephyr,code-partition = &boot_partition;
	};
};

Here is what I put in my <Project>\Application\sysbuild\mcuboot\prj.conf:

#Adds a bootloader information sharing system which allows for retreiving data from the bootloader when data sharing is enabled:
CONFIG_RETAINED_MEM=y
CONFIG_RETENTION=y
CONFIG_BOOT_SHARE_DATA=y
CONFIG_BOOT_SHARE_DATA_BOOTINFO=y
CONFIG_BOOT_SHARE_BACKEND_RETENTION=y
CONFIG_FLASH=y
CONFIG_FLASH_MAP=y

Here is what I put in my <Project>\Application\prj.conf:

#Adds a bootloader information sharing system which allows for retreiving data from the bootloader when data sharing is enabled:
CONFIG_RETAINED_MEM=y
CONFIG_RETENTION=y
CONFIG_RETENTION_BOOTLOADER_INFO=y
CONFIG_RETENTION_BOOTLOADER_INFO_TYPE_MCUBOOT=y
CONFIG_SETTINGS=y
CONFIG_SETTINGS_RUNTIME=y
CONFIG_RETENTION_BOOTLOADER_INFO_OUTPUT_SETTINGS=y

I use a pm_static.yml file to define my partitions:

EMPTY_0:
  address: 0x19200
  end_address: 0x1a000
  placement:
    before:
    - s1_pad
  region: flash_primary
  size: 0xe00
EMPTY_1:
  address: 0x2a200
  end_address: 0x2b000
  placement:
    before:
    - mcuboot_pad
  region: flash_primary
  size: 0xe00
app:
  address: 0x2b200
  end_address: 0xEC000
  region: flash_primary
  size: 0xc0e00
app_image:
  address: 0x2b200
  end_address: 0xEC000
  orig_span: &id001
  - app
  region: flash_primary
  size: 0xC0E00
  span: *id001
b0:
  address: 0x0
  end_address: 0x8000
  placement:
    after:
    - start
  region: flash_primary
  size: 0x8000
b0_container:
  address: 0x0
  end_address: 0x9000
  orig_span: &id002
  - b0
  - provision
  region: flash_primary
  size: 0x9000
  span: *id002
mcuboot:
  address: 0x9200
  end_address: 0x19200
  placement:
    before:
    - mcuboot_primary
  region: flash_primary
  sharers: 0x1
  size: 0x10000
mcuboot_pad:
  address: 0x2b000
  end_address: 0x2b200
  placement:
    align:
      start: 0x1000
    before:
    - mcuboot_primary_app
  region: flash_primary
  sharers: 0x2
  size: 0x200
mcuboot_primary:
  address: 0x2b000
  end_address: 0xEC000
  orig_span: &id003
  - mcuboot_pad
  - app
  region: flash_primary
  sharers: 0x1
  size: 0xC1000
  span: *id003
mcuboot_primary_app:
  address: 0x2b200
  end_address: 0xEC000
  orig_span: &id004
  - app
  region: flash_primary
  size: 0xC0E00
  span: *id004
mcuboot_secondary:
  address: 0xEC000
  end_address: 0xfc000
  placement:
    after:
    - mcuboot_primary
    align:
      start: 0x1000
    align_next: 0x1000                  
  region: flash_primary
  share_size:
  - mcuboot_primary
  size: 0x10000
provision:
  address: 0x8000
  end_address: 0x9000
  placement:
    after:
    - b0
    align:
      start: 0x1000
  region: flash_primary
  size: 0x1000
s0:
  address: 0x9000
  end_address: 0x19200
  orig_span: &id005
  - s0_pad
  - mcuboot
  region: flash_primary
  size: 0x10200
  span: *id005
s0_image:
  address: 0x9200
  end_address: 0x19200
  orig_span: &id006
  - mcuboot
  region: flash_primary
  size: 0x10000
  span: *id006
s0_pad:
  address: 0x9000
  end_address: 0x9200
  placement:
    after:
    - b0_container
    align:
      start: 0x1000
  region: flash_primary
  share_size:
  - mcuboot_pad
  size: 0x200
s1:
  address: 0x1a000
  end_address: 0x2a200
  orig_span: &id007
  - s1_pad
  - s1_image
  region: flash_primary
  size: 0x10200
  span: *id007
s1_image:
  address: 0x1a200
  end_address: 0x2a200
  placement:
    after:
    - s1_pad
    - s0
  region: flash_primary
  share_size:
  - mcuboot
  size: 0x10000
s1_pad:
  address: 0x1a000
  end_address: 0x1a200
  placement:
    after:
    - s0
    align:
      start: 0x1000
  region: flash_primary
  share_size:
  - mcuboot_pad
  size: 0x200
settings_storage:
  address: 0xfc000
  end_address: 0x100000
  placement:
    align:
      start: 0x1000
    before:
    - end
  region: flash_primary
  size: 0x4000
sram_primary:
  address: 0x20000000
  end_address: 0x20040000
  region: sram_primary
  size: 0x40000

Is there anything else I need to indicate in this file to take into account "data sharing"?

The compilation of this project works but here are the logs I get when I run the code:

00> *** Booting MCUboot v2.1.0-dev-daf2946a0f07 ***
00> *** Using nRF Connect SDK v2.7.0-5cb85570ca43 ***
00> *** Using Zephyr OS v3.6.99-100befc70c74 ***
00> I: Starting bootloader
00> I: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
00> I: Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
00> I: Boot source: none
00> I: Image index: 0, Swap type: none
00> I: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
00> I: Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
00> I: Boot source: none
00> I: Image index: 1, Swap type: none
00> E: Failed to add data to shared memory area.
00> E: Unable to find bootable image

boot_add_data_to_shared_area(…) return rc=2 (SHARED_MEMORY_OVERFLOW)

Could you tell me what I forgot?

Thanks

Related