compile error with mcuboot and external qspi flash

Hello I have an nRF52840 board with a 2 MB external flash
I'm using SDK 2.6.2
I'd like to configure the mcuboot_secondary partition to be on the external flash

Here is my pm_static.yml

# Internal flash partitions
mcuboot:
  address: 0x00000000
  size: 0x0000C000  # 48 KB

settings_storage:
  address: 0x000F8000
  size: 0x00007800  # 30 KB

app_config:
  address: 0x000FF800
  size: 0x00000800  # 2 KB

# External flash region
external_flash:
  address: 0x00000000
  size: 0x00200000  # 2 MB
  end_address: 0x00200000
  region: external_flash

# External flash partitions
mcuboot_secondary:
  address: 0x00000000
  size: 0x00100000  # 1 MB
  region: external_flash
  device: QSPI_FLASH
  end_address: 0x00100000

scratch_partition:
  address: 0x00100000
  size: 0x00010000  # 64 KB
  region: external_flash
  device: QSPI_FLASH
  end_address: 0x00110000

qspi_app_storage:
  address: 0x00110000
  size: 0x000F0000  # 960 KB
  region: external_flash
  device: QSPI_FLASH
  end_address: 0x00200000

DTS file:

chosen {
        .....
       
       pm_ext_flash = &qspi_flash0;
};
&qspi {
    status = "okay";
    pinctrl-0 = <&qspi_default>;
    pinctrl-1 = <&qspi_sleep>;
    pinctrl-names = "default", "sleep";

    qspi_flash0: qspi_flash@0 {
        compatible = "nordic,qspi-nor";
        status = "okay";
        label = "QSPI_FLASH";
        reg = <0>;
        sck-frequency = <16000000>;              
        writeoc = "pp4o";                         /* enable quad page program */
        readoc = "read4io";                       /* enable quad fast read */
        jedec-id = [c8 40 15];
        size = <0x00200000>;                      /* 2 MiB */
        has-dpd;
        t-enter-dpd = <20000>;                    /* match datasheet typical */
        t-exit-dpd = <20000>;
        quad-enable-requirements = "S2B1v1";      /* required for quad mode */
       
        partitions {
            status = "okay";
            compatible = "fixed-partitions";
            #address-cells = <1>;
            #size-cells = <1>;

            mcuboot_secondary: partition@0 {
                label = "mcuboot_secondary";
                reg = <0x000000 0x100000>;  /* 1MB */
            };

            scratch_partition: partition@100000 {
                label = "scratch";
                reg = <0x100000 0x10000>;  /* 64KB */
            };

            qspi_storage: partition@110000 {
                label = "qspi_storage";
                reg = <0x110000 0xF0000>;  /* 960KB */
            };
        };
    };
};
BUT I'm still getting compile error:

C:/ncs/v2.6.2/bootloader/mcuboot/boot/zephyr/include/sysflash/pm_sysflash.h: In function '__flash_area_ids_for_slot':
C:/ncs/v2.6.2/bootloader/mcuboot/boot/zephyr/include/sysflash/pm_sysflash.h:47:60: error: 'PM_MCUBOOT_SECONDARY_ID' undeclared (first use in this function); did you mean 'PM_MCUBOOT_PRIMARY_ID'?
47 | #define FLASH_AREA_IMAGE_0_SLOTS PM_MCUBOOT_PRIMARY_ID, PM_MCUBOOT_SECONDARY_ID
| ^~~~~~~~~~~~~~~~~~~~~~~
SDK is 2.6.2
When I examine the partitions.yml in and pm_config there is no mention of the mcuboot secondary. Looks like my pm_static.yml is ignored even though I see this message in the build log
Found partition manager static configuration:..../pm_static.yml
Partition 'mcuboot' 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 'mcuboot_secondary' is not included in the dynamic resolving since it is statically defined.
Any ideas?
Thank you
Andy
Parents
  • Hi, 

    Remove the partitions in the DTS and pm_static.yml to let the partition manager allocate the partition.

    Take a look at this course Exercise 3 – DFU with external flash for setting mcuboot_secondary on the external flash.

    Regards,
    Amanda H.

  • I'm using SDK 2.6.2

    I must have the "app_config" partition  at a certain address. How do I do that without pm_static.yml?

    Thanks

  • Just let the pm_static.yml only have that part.

  • Leaving just the app_config partition in the pm_static.yml
    fixed the link error I saw before, but now I'm getting this error
    c:/ncs/toolchains/cf2149caf2/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: zephyr\zephyr_pre0.elf section `rodata' will not fit in region `FLASH'
    c:/ncs/toolchains/cf2149caf2/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: region `FLASH' overflowed by 2790 bytes

    When I build without MCUBOOT here is what the memory  usage looks like

    Memory region Used Size Region Size %age Used
    FLASH: 516680 B 1 MB 49.27%
    RAM: 195217 B 256 KB 74.47%
    IDT_LIST: 0 GB 32 KB 0.00%

    My goal is to use the external flash for the mcuboot_secondary so I can grow my app

    I can adapt my scripts  to use a different address for app_config partition but I need to have it .

    Where do you suggest I place it ?

    Here is the partitions.yml generated by the build

    EMPTY_0:
      address: 0x7c00
      end_address: 0x8000
      placement:
        before:
        - mcuboot_pad
      region: flash_primary
      size: 0x400
    EMPTY_1:
      address: 0xff000
      end_address: 0xff800
      placement:
        after:
        - settings_storage
      region: flash_primary
      size: 0x800
    app:
      address: 0x8200
      end_address: 0xfd000
      region: flash_primary
      size: 0xf4e00
    app_config:
      address: 0xff800
      end_address: 0x100000
      region: flash_primary
      size: 0x800
    external_flash:
      address: 0xf5000
      end_address: 0x40000
      region: external_flash
      size: -0xb5000
    mcuboot:
      address: 0x0
      end_address: 0x7c00
      placement:
        before:
        - mcuboot_primary
      region: flash_primary
      size: 0x7c00
    mcuboot_pad:
      address: 0x8000
      end_address: 0x8200
      placement:
        align:
          start: 0x1000
        before:
        - mcuboot_primary_app
      region: flash_primary
      size: 0x200
    mcuboot_primary:
      address: 0x8000
      end_address: 0xfd000
      orig_span: &id001
      - app
      - mcuboot_pad
      region: flash_primary
      size: 0xf5000
      span: *id001
    mcuboot_primary_app:
      address: 0x8200
      end_address: 0xfd000
      orig_span: &id002
      - app
      region: flash_primary
      size: 0xf4e00
      span: *id002
    mcuboot_secondary:
      address: 0x0
      device: DT_CHOSEN(nordic_pm_ext_flash)
      end_address: 0xf5000
      placement:
        align:
          start: 0x4
      region: external_flash
      share_size:
      - mcuboot_primary
      size: 0xf5000
    settings_storage:
      address: 0xfd000
      end_address: 0xff000
      placement:
        align:
          start: 0x1000
        before:
        - end
      region: flash_primary
      size: 0x2000
    sram_primary:
      address: 0x20000000
      end_address: 0x20040000
      region: sram_primary
      size: 0x40000
Reply
  • Leaving just the app_config partition in the pm_static.yml
    fixed the link error I saw before, but now I'm getting this error
    c:/ncs/toolchains/cf2149caf2/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: zephyr\zephyr_pre0.elf section `rodata' will not fit in region `FLASH'
    c:/ncs/toolchains/cf2149caf2/opt/zephyr-sdk/arm-zephyr-eabi/bin/../lib/gcc/arm-zephyr-eabi/12.2.0/../../../../arm-zephyr-eabi/bin/ld.bfd.exe: region `FLASH' overflowed by 2790 bytes

    When I build without MCUBOOT here is what the memory  usage looks like

    Memory region Used Size Region Size %age Used
    FLASH: 516680 B 1 MB 49.27%
    RAM: 195217 B 256 KB 74.47%
    IDT_LIST: 0 GB 32 KB 0.00%

    My goal is to use the external flash for the mcuboot_secondary so I can grow my app

    I can adapt my scripts  to use a different address for app_config partition but I need to have it .

    Where do you suggest I place it ?

    Here is the partitions.yml generated by the build

    EMPTY_0:
      address: 0x7c00
      end_address: 0x8000
      placement:
        before:
        - mcuboot_pad
      region: flash_primary
      size: 0x400
    EMPTY_1:
      address: 0xff000
      end_address: 0xff800
      placement:
        after:
        - settings_storage
      region: flash_primary
      size: 0x800
    app:
      address: 0x8200
      end_address: 0xfd000
      region: flash_primary
      size: 0xf4e00
    app_config:
      address: 0xff800
      end_address: 0x100000
      region: flash_primary
      size: 0x800
    external_flash:
      address: 0xf5000
      end_address: 0x40000
      region: external_flash
      size: -0xb5000
    mcuboot:
      address: 0x0
      end_address: 0x7c00
      placement:
        before:
        - mcuboot_primary
      region: flash_primary
      size: 0x7c00
    mcuboot_pad:
      address: 0x8000
      end_address: 0x8200
      placement:
        align:
          start: 0x1000
        before:
        - mcuboot_primary_app
      region: flash_primary
      size: 0x200
    mcuboot_primary:
      address: 0x8000
      end_address: 0xfd000
      orig_span: &id001
      - app
      - mcuboot_pad
      region: flash_primary
      size: 0xf5000
      span: *id001
    mcuboot_primary_app:
      address: 0x8200
      end_address: 0xfd000
      orig_span: &id002
      - app
      region: flash_primary
      size: 0xf4e00
      span: *id002
    mcuboot_secondary:
      address: 0x0
      device: DT_CHOSEN(nordic_pm_ext_flash)
      end_address: 0xf5000
      placement:
        align:
          start: 0x4
      region: external_flash
      share_size:
      - mcuboot_primary
      size: 0xf5000
    settings_storage:
      address: 0xfd000
      end_address: 0xff000
      placement:
        align:
          start: 0x1000
        before:
        - end
      region: flash_primary
      size: 0x2000
    sram_primary:
      address: 0x20000000
      end_address: 0x20040000
      region: sram_primary
      size: 0x40000
Children
  • Update

    With this pm_static.yml the build succeeds
    Thank you

    # ===== Internal flash (1 MiB) =====
    mcuboot:
      address: 0x00000
      size:    0x9000        # 36 KiB, bigger than the default so MCUboot fits
      region:  flash_primary

    mcuboot_pad:
      address: 0x9000        # immediately after mcuboot
      size:    0x200
      region:  flash_primary
      placement:
        align:
          start: 0x1000
        before:
        - app                 # keep the pad right before the app

    # Leave the gap from 0x9200 up to settings_storage for the app (dynamic)

    settings_storage:
      address: 0xF6000
      size:    0x9800        # fills exactly up to 0xFF800 to avoid a second gap
      region:  flash_primary
      placement:
        align:
          start: 0x1000
        before:
        - app_config

    app_config:
      address: 0xFF800      
      size:    0x800         # 1 KiB

    # ===== External flash =====
    mcuboot_secondary:
      address: 0x0000
      size:    0xEE000
      region:  external_flash
      device:  DT_CHOSEN(nordic_pm_ext_flash)

    qspi_storage:
      address: 0xEE000
      size:    0x52000
      region:  external_flash

    # ===== SRAM =====
    sram_primary:
      address: 0x20000000
      size:    0x40000
      region:  sram_primary
Related