!!!Partition alignment error!!!

Dear Nordic Engineers

I used gd25lq32e to replace mx25r6435 and it is a 32Mbit Flash, when I add it to the Devicetree of Lwmwm(NCS 2.6.1), the build will report the following log:

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
!!!Partition alignment error!!!
The non-secure start address in pm_static.yml or generated partition.yml is: 0x1be00
which is not aligned with the SPU HW requirements.
Refer to the documentation section 'TF-M partition alignment requirements'
for more information.
'
18 | #pragma message \
| ^~~~~~~
E:/NCS/v2.6.1/nrf/modules/trusted-firmware-m/tfm_boards/common/assert.c:27:2: error: #error "TF-M non-secure start address is not aligned to SPU HW requirements"
27 | #error "TF-M non-secure start address is not aligned to SPU HW requirements"
| ^~~~~
ninja: build stopped: subcommand failed.
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

I tried to set CONFIG_PM_PARTITION_SIZE_TFM=0x8000, but it didn't work.

This is my partitions.yml, please give me some good suggestions.

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
EMPTY_0:
· address: 0xf2000
· end_address: 0xf8000
· placement:
· · after:
· · - settings_storage
· region: flash_primary
· size: 0x6000
EMPTY_tfm_ps:
· address: 0xfc000
· end_address: 0x100000
· region: flash_primary
· size: 0x4000
app:
· address: 0x1be00
· end_address: 0xe8000
· region: flash_primary
· size: 0xcc200
external_flash:
· address: 0x4d4200
· end_address: 0x400000
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Best regards,

Hannibal

Parents
  • Hi Hannibal,

    There are quite a few items here you will need to fix in your .dts and overlay.

    The first item is your external flash, which has a negative size in the generated partition layout. How did you set it up in your board files?

    Kind regards,
    Andreas

  • Hi Andreas

    1. I changed 2 overlay files of lwm2m/boards path and added the configure of gd25lq32e to them, as the following files.

    7607.nrf9160dk_nrf9160_ns_0_14_0.overlay1830.nrf9160dk_nrf9160_ns.overlay

    2. I changed an overlay file of lwm2m\child_image\mcuboot\boards path as same as the last step, this is the file. 

    nrf9160dk_nrf9160_0_14_0.overlay

    And then this is the zephyr.dts file from the build/zephyr path.  

    0488.zephyr.dts

    Is there any problem with this configuration?

    Best regards,

    Hannibal

  • At first lookthrough the files look ok.

    Them moving on to the second item, the CONFIG_PM_PARTITION_SIZE_TFM:

    You need to change the size of the TF-M partition so that it follows the requirement that the secure and non-secure partition addresses are aligned with the TrustZone flash region size This can be done by changing CONFIG_PM_PARTITION_SIZE_TFM.

    From a discussion with my colleague, the following example should explain how you can achieve this: For example if the default value in the sample you've based your application on is set to 0x20000 in the sample, such that the TF-M partition is from 0x0 to 0x20000, with tfm_secure starting at 0x0 and tfm_nonsecure starting at 0x20000 so that they are both aligned to 0x4000:

    However, when you add MCUboot to your project, partition manager will add an MCUboot partition from 0x0 to 0xc000, causing TF-M to start at 0xc000 instead. This will shift tfm_secure in such a way that the start of tfm_nonsecure will no longer be aligned with 0x4000, so you need to change the size of TF-M to ensure that both tfm_secure and tfm_nonsecure are still aligned.

    Kind regards,
    Andreas

  • Hi Andreas

    I tried to set CONFIG_PM_PARTITION_SIZE_TFM=0x8000 and 0x10000, but it didn't improve.

    This is the build log while I set CONFIG_PM_PARTITION_SIZE_TFM=0x10000

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    !!!Partition alignment error!!!
    The non-secure start address in pm_static.yml or generated partition.yml is: 0x24000
    which is not aligned with the SPU HW requirements.
    Refer to the documentation section 'TF-M partition alignment requirements'
    for more information.
    '
    18 | #pragma message \
    | ^~~~~~~
    E:/NCS/v2.6.1/nrf/modules/trusted-firmware-m/tfm_boards/common/assert.c:27:2: error: #error "TF-M non-secure start address is not aligned to SPU HW requirements"
    27 | #error "TF-M non-secure start address is not aligned to SPU HW requirements"
    | ^~~~~
    ninja: build stopped: subcommand failed.
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    This is the partitions.yml file.

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    EMPTY_0:
    address: 0xf2000
    end_address: 0xf8000
    placement:
    after:
    - settings_storage
    region: flash_primary
    size: 0x6000
    EMPTY_tfm_ps:
    address: 0xfc000
    end_address: 0x100000
    region: flash_primary
    size: 0x4000
    app:
    address: 0x24000
    end_address: 0xe8000
    region: flash_primary
    size: 0xc4000
    external_flash:
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    So, do you have other good suggestions?

    Best regards,

    Hannibal

  • Hi,

    In your build log it is clearly written where you need to look next:

    "The non-secure start address in pm_static.yml or generated partition.yml is: 0x24000
    which is not aligned with the SPU HW requirements.
    Refer to the documentation section 'TF-M partition alignment requirements'
    for more information."

    Please have a look at the TF-M documentation it refers to: https://docs.nordicsemi.com/bundle/ncs-2.6.1/page/nrf/security/tfm.html 

    Kind regards,
    Andreas

  • Hi Andreas

    I tried to set 

    CONFIG_NRF_SPU_FLASH_REGION_SIZE=0x8000 and set pm_static.yml as same as you gave me the description of the document:
    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    tfm_secure:
    address: 0x14000
    size: 0x8000
    span:
    - mcuboot_pad
    - tfm
    mcuboot_pad:
    address: 0x14000
    size: 0x0
    tfm:
    address: 0x14000
    size: 0x8000
    tfm_nonsecure:
    address: 0x1C000
    span:
    - app
    size: 0x8000
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    But, it still didn't have any improvement.  The build still failed because of  [!!!Partition alignment error!!!].
    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    !!!Partition alignment error!!!
    The non-secure start address in pm_static.yml or generated partition.yml is: 0x1c000
    which is not aligned with the SPU HW requirements.
    Refer to the documentation section 'TF-M partition alignment requirements'
    for more information.
    '
    18 | #pragma message \
    | ^~~~~~~
    E:/NCS/v2.6.1/nrf/modules/trusted-firmware-m/tfm_boards/common/assert.c:27:2: error: #error "TF-M non-secure start address is not aligned to SPU HW requirements"
    27 | #error "TF-M non-secure start address is not aligned to SPU HW requirements"
    | ^~~~~
    ninja: build stopped: subcommand failed.
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
     
    I'm about to go crazy over this issue, can you help me try it out? I use the above .conf and overlay to port to the lwmwm_client (NCS V2.6.0) and it will recur this problem.
    Best regards,
    Hannibal
Reply
  • Hi Andreas

    I tried to set 

    CONFIG_NRF_SPU_FLASH_REGION_SIZE=0x8000 and set pm_static.yml as same as you gave me the description of the document:
    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    tfm_secure:
    address: 0x14000
    size: 0x8000
    span:
    - mcuboot_pad
    - tfm
    mcuboot_pad:
    address: 0x14000
    size: 0x0
    tfm:
    address: 0x14000
    size: 0x8000
    tfm_nonsecure:
    address: 0x1C000
    span:
    - app
    size: 0x8000
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
    But, it still didn't have any improvement.  The build still failed because of  [!!!Partition alignment error!!!].
    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    !!!Partition alignment error!!!
    The non-secure start address in pm_static.yml or generated partition.yml is: 0x1c000
    which is not aligned with the SPU HW requirements.
    Refer to the documentation section 'TF-M partition alignment requirements'
    for more information.
    '
    18 | #pragma message \
    | ^~~~~~~
    E:/NCS/v2.6.1/nrf/modules/trusted-firmware-m/tfm_boards/common/assert.c:27:2: error: #error "TF-M non-secure start address is not aligned to SPU HW requirements"
    27 | #error "TF-M non-secure start address is not aligned to SPU HW requirements"
    | ^~~~~
    ninja: build stopped: subcommand failed.
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
     
    I'm about to go crazy over this issue, can you help me try it out? I use the above .conf and overlay to port to the lwmwm_client (NCS V2.6.0) and it will recur this problem.
    Best regards,
    Hannibal
Children
No Data