Sysbuild, Partition manager and mcuboot from external flash problems

I am trying to use mcuboot with external flash on the NRF52840DK with NCS2.7.0 and a simple hello world application to reproduce the problems I have with my real-world application on a custom board. There is a problem when using the partition manager and pm_static.yml. Interestingly it works when I define the partitions in a board overlay.

So first the version that does not work, using partition mananger:

I'm using sysbuild, config SB_CONFIG_BOOTLOADER_MCUBOOT=y and SB_CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y

sysbuild/mcuboot.conf is

CONFIG_MULTITHREADING=y
CONFIG_BOOT_MAX_IMG_SECTORS=256
CONFIG_NORDIC_QSPI_NOR=y
CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
CONFIG_FLASH=y

and i have boards/nrf52840dk_nrf52840.overlay with

/ {
chosen {
nordic,pm-ext-flash = &mx25r64;
};
};

pm_static.yml is

mcuboot_secondary:
  address: 0x0
  device: mx25r64
  end_address: 0xf4000
  placement:
    align:
      start: 0x4
  region: external_flash
  share_size:
  - mcuboot_primary
  size: 0xf4000

Images build fine and I see region size is 998912B but mcuboot gives the following error message:

*** Booting MCUboot v2.1.0-dev-daf2946a0f07 ***
*** Using nRF Connect SDK v2.7.0-5cb85570ca43 ***
*** Using Zephyr OS v3.6.99-100befc70c74 ***
I: Starting bootloader
E: Failed to open flash area ID 1 (image 0 slot 1): -19, cannot continue

But when I define the partitons in overlay files it works:

Following https://github.com/hlord2000/mcuboot_sysbuild_external_flash sysbuild is still used but SB_CONFIG_PARTITION_MANAGER=n

And boards/nrf52840dk_nrf52840.overlay is:

/delete-node/ &boot_partition;
/delete-node/ &slot0_partition;
/delete-node/ &slot1_partition;

&flash0 {
    partitions {
        boot_partition: partition@0 {
            label = "mcuboot";
            reg = <0x000000000 0x00010000>;
        };
        slot0_partition: partition@10000 {
            label = "image-0";
            reg = <0x000010000 0x0000e8000>;
        };
    };
};

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

        slot1_partition: partition@0 {
            label = "image-1";
            reg = <0x000000000 0x0000e8000>;
        };
    };
};

and mcuboot.overlay is

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

/delete-node/ &boot_partition;
/delete-node/ &slot0_partition;
/delete-node/ &slot1_partition;

&flash0 {
    partitions {
        boot_partition: partition@0 {
            label = "mcuboot";
            reg = <0x000000000 0x00010000>;
        };
        slot0_partition: partition@10000 {
            label = "image-0";
            reg = <0x000010000 0x0000e8000>;
        };
    };
};

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

        slot1_partition: partition@0 {
            label = "image-1";
            reg = <0x000000000 0x0000e8000>;
        };
    };
};

In this case mcuboot boots just fine:

*** Booting MCUboot v2.1.0-dev-daf2946a0f07 ***
*** Using nRF Connect SDK v2.7.0-5cb85570ca43 ***
*** Using Zephyr OS v3.6.99-100befc70c74 ***
I: Starting bootloader
I: Primary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
I: Secondary image: magic=unset, swap_type=0x1, copy_done=0x3, image_ok=0x3
I: Boot source: none
I: Image index: 0, Swap type: none
I: Bootloader chainload address offset: 0x10000
*** Booting nRF Connect SDK v2.7.0-5cb85570ca43 ***
*** Using Zephyr OS v3.6.99-100befc70c74 ***
Hello World! nrf52840dk/nrf52840

From the documentation it sounded like using partition mananger is the way to go. Am I doing something wrong?

Parents Reply Children
Related