Partition Alignment

Hi,

I am using the nrf54l15 on a custom board in our current project and want to use it with DFU over BLE FOTA as well as TF-M.

I can compile the project just fine before adding DFU as described in your tutorial (tutorial) The only diffrence being that i started from the Blinky Example.

When i try to compile the project it gives me an alignment error:

!!!Partition alignment error!!!
The non-secure start address in pm_static.yml or generated partition.yml is: 0x64600
which is not aligned with the SPU/MPC HW requirements.
In nRF53/nRF91 series the flash region need to be aligned with the SPU region size.
In nRF54L15 the flash region need to be aligned with the MPC region size.
Refer to the documentation section 'TF-M partition alignment requirements'
for more information.

Here is my compiled partitons.yml (when i delete the sysbuild.conf-File thus not implementing the DFU i suppose?)

EMPTY_0:
  address: 0x164000
  end_address: 0x165000
  placement:
    after:
    - mcuboot_secondary
  region: flash_primary
  size: 0x1000
app:
  address: 0x64600
  end_address: 0xbc000
  region: flash_primary
  size: 0x57a00
mcuboot:
  address: 0x0
  end_address: 0xc000
  placement:
    align:
      end: 0x1000
    before:
    - mcuboot_primary
  region: flash_primary
  size: 0xc000
mcuboot_pad:
  address: 0x14000
  end_address: 0x14800
  placement:
    align:
      start: 0x1000
    before:
    - mcuboot_primary_app
  region: flash_primary
  size: 0x800
mcuboot_primary:
  address: 0x14000
  end_address: 0xbc000
  orig_span: &id001
  - app
  - tfm
  - mcuboot_pad
  region: flash_primary
  sharers: 0x1
  size: 0xa8000
  span: *id001
mcuboot_primary_app:
  address: 0x14800
  end_address: 0xbc000
  orig_span: &id002
  - app
  - tfm
  region: flash_primary
  size: 0xa7800
  span: *id002
mcuboot_secondary:
  address: 0xbc000
  end_address: 0x164000
  placement:
    after:
    - mcuboot_primary
    align:
      start: 0x1000
    align_next: 0x1000
  region: flash_primary
  share_size:
  - mcuboot_primary
  size: 0xa8000
mcuboot_sram:
  address: 0x20000000
  end_address: 0x20013000
  orig_span: &id003
  - tfm_sram
  region: sram_primary
  size: 0x13000
  span: *id003
otp:
  address: 0xffd500
  end_address: 0xffd9fc
  region: otp
  size: 0x4fc
sram_nonsecure:
  address: 0x20013000
  end_address: 0x2002f000
  orig_span: &id004
  - sram_primary
  region: sram_primary
  size: 0x1c000
  span: *id004
sram_primary:
  address: 0x20013000
  end_address: 0x2002f000
  region: sram_primary
  size: 0x1c000
sram_secure:
  address: 0x20000000
  end_address: 0x20013000
  orig_span: &id005
  - tfm_sram
  region: sram_primary
  size: 0x13000
  span: *id005
tfm:
  address: 0x14800
  end_address: 0x64600
  inside:
  - mcuboot_primary_app
  placement:
    before:
    - app
  region: flash_primary
  size: 0x4fe00
tfm_its:
  address: 0xc000
  end_address: 0xe000
  inside:
  - tfm_storage
  placement:
    before:
    - tfm_otp_nv_counters
  region: flash_primary
  size: 0x2000
tfm_nonsecure:
  address: 0x64600
  end_address: 0xbc000
  orig_span: &id006
  - app
  region: flash_primary
  size: 0x57a00
  span: *id006
tfm_otp_nv_counters:
  address: 0xe000
  end_address: 0x10000
  inside:
  - tfm_storage
  placement:
    before:
    - tfm_ps
  region: flash_primary
  size: 0x2000
tfm_ps:
  address: 0x10000
  end_address: 0x14000
  inside:
  - tfm_storage
  placement:
    after:
    - mcuboot
    - tfm_secure
  region: flash_primary
  size: 0x4000
tfm_secure:
  address: 0x14000
  end_address: 0x64600
  orig_span: &id007
  - mcuboot_pad
  - tfm
  region: flash_primary
  size: 0x50600
  span: *id007
tfm_sram:
  address: 0x20000000
  end_address: 0x20013000
  inside:
  - sram_secure
  placement:
    after:
    - start
  region: sram_primary
  size: 0x13000
tfm_storage:
  address: 0xc000
  end_address: 0x14000
  orig_span: &id008
  - tfm_ps
  - tfm_its
  - tfm_otp_nv_counters
  region: flash_primary
  size: 0x8000
  span: *id008

I understand that i need to define custom partitions taht are properly aligned to the CONFIG_NRF_TRUSTZONE_FLASH_REGION_SIZE wich defaults to 0x1000 (as it is in the KCONFIG file in the board definition).

Can you please point out to me what is wrong and how i define this correctly?

Maybe you also have resources on how to define a static partitioning-table for your diffrent board-targets as we are currently also in development for a project using the nrf52-Series wich will encounter similar problems i suppose.

  • Hello,

    The problem is that the app start address is not aligned to a 0x1000 byte boundary like you mentioned

    The non-secure start address in pm_static.yml or generated partition.yml is: 0x64600

    It would have worked if the start address was 0x64000 or 0x65000 here.

    But is the partitions.yml file created dynamically by the build, or did you create static partitions yourself? I would expect the build system to adhere to the alignment requirements.

    Best regards,

    Vidar

  • That is what i would expect too.

    In my case this is the generated partition.yml

    Shame on me it warned me to create one on my own as "having the bootloader without a static_pm.yml can casue problems"

  • That's not good. In most cases, you should be able to let the build system generate the partition for you. Then, when you're ready to lock down the memory layout before release, you can turn it into a static partitioning file by renaming it to pm_static.yml.

    To work around this for now, you can adjust the current partitions.yml to ensure it meets the alignment requirements. Then, rename it to pm_static.yml, place it in the project root, and perform a clean build.

  • Dou you have any resources on what the diffrent partitions are used for and how i define them?

    I have the feeling that some informations in there is duplicated wich is normal for a generated build but maybe i can omit them to make it easier to change the sizes if needed.

    For example the partiton:
    mcuboot_primary_app:
      address: 0x14800
      end_address: 0xbc000
      orig_span: &id002
      - app
      - tfm
      region: flash_primary
      size: 0xa7800
      span: *id002

    it has a size as well as start and end address. can i omit one of them?
    looking here im seeing a wildly different kind of partition.yml. What is the correct way of defining this?

    I dont really care for optimal sizing as the 1.5MB is more than enough.

    Also:
    If we update the software in the future is it possible to change the partition sizes?

Related