sysbuild & mcuboot custom pm_static.yml partition table matches default layout but will not build

Hi,

I am nrf52dk/nRF52832 (512kB flash) nordic peripheral_lbs sample as a test environment for establishing OTA updates. In my product firmware, I am facing a situation where I need to reduce the size of mcuboot partition to 0x9000 (36kB). I would like to reallocate the freed up space to the primary and secondary partitions. 

I have viewed many of the tickets on this forum for help - which have helped me reach the stage that I am so far. 
Adjusting the slots sizes with MCU Boot

MCUBoot, Zephyr, and static partition manager 

The following command gives me this output. 

west build -b nrf52dk/nrf52832 --sysbuild -d build . -t partition_manager




I have checked that the size of the peripheral_lbs firmware should fit inside the image partitions. However, when I try to build the full application with 

west build -b nrf52dk/nrf52832 --sysbuild -d build .

I get the following error


←[0mninja: error: '_sysbuild/mcuboot_primary_app_hex', needed by 'mcuboot_primary.hex', missing and no known rule to make it

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/Ryan/Downloads/peripheral-lbs-sysbuild-main/build_app/peripheral-lbs-sysbuild-main
-- Found partition manager static configuration : C:/Users/Ryan/Downloads/peripheral-lbs-sysbuild-main/pm_static.yml
Partition 'mcuboot' is not included in the dynamic resolving since it is statically defined.
Partition 'mcuboot_pad' is not included in the dynamic resolving since it is statically defined.
Partition 'mcuboot_primary' is not included in the dynamic resolving since it is statically defined.
Partition 'mcuboot_primary_app' 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.
Partition 'settings_storage' is not included in the dynamic resolving since it is statically defined.
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/Ryan/Downloads/peripheral-lbs-sysbuild-main/build_app/peripheral-lbs-sysbuild-main
-- Found partition manager static configuration : C:/Users/Ryan/Downloads/peripheral-lbs-sysbuild-main/pm_static.yml
Partition 'mcuboot' is not included in the dynamic resolving since it is statically defined.
Partition 'mcuboot_pad' is not included in the dynamic resolving since it is statically defined.
Partition 'mcuboot_primary' is not included in the dynamic resolving since it is statically defined.
Partition 'mcuboot_primary_app' 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.
Partition 'settings_storage' is not included in the dynamic resolving since it is statically defined.
-- Configuring done
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX



Here is the .yml file I used to define the partitioning 

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
app:
address: 0x9200
end_address: 0x43800
region: flash_primary
size: 0x3A600 # -200??
mcuboot:
address: 0x0
end_address: 0x9000
placement:
before:
- mcuboot_primary
region: flash_primary
size: 0x9000
mcuboot_pad:
address: 0x9000
end_address: 0x9200
placement:
before:
- mcuboot_primary_app
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Previously, I was getting some issues about too many or too little gaps in the partition table. However that seems to have resolved itself. If anyone could also explain what that means in relation to dynamic and static partitioning - that would be divine. Here is the error I got for context 

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/Ryan/Downloads/peripheral-lbs-sysbuild-main/build/peripheral-lbs-s
-- Found partition manager static configuration : C:/Users/Ryan/Downloads/peripheral-lbs-sysbuild-main/pm_static
Partition 'mcuboot' is not included in the dynamic resolving since it is statically defined.
Partition 'mcuboot_pad' is not included in the dynamic resolving since it is statically defined.
Partition 'mcuboot_primary' is not included in the dynamic resolving since it is statically defined.
Partition 'mcuboot_primary_app' 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.
Partition 'settings_storage' is not included in the dynamic resolving since it is statically defined.
Partition manager failed: Incorrect amount of gaps found in static configuration. There must be exactly one gap namic partitions (such as 'app'). Gaps found (0): The most common solution to this problem is to fill the smalle until there is only one gap left. Alternatively re-order the already defined static partitions so that only one
Failed to partition region flash_primary, size of region: 524288
Partition Configuration:
app:
size: 239104
mcuboot:
size: 36864
mcuboot_pad:
size: 512
mcuboot_primary:
size: 239616
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Parents
  • Hi,

    I think one of the best resources to start with is to go through this exercise with focus on the multi-image builds and partition manager section: https://academy.nordicsemi.com/courses/nrf-connect-sdk-intermediate/lessons/lesson-8-bootloaders-and-dfu-fota/

    I will revisit this case tomorrow and go over it once again and fill in some gaps that I see the lesson might miss and/or if you have posted any additional follow up questions by then

    Kind regards,
    Andreas

  • Hi Andreas, 

    Thanks for responding. I have actually done that lesson and finished that course. I just checked over it again to see if I missed anything regarding this. I would have thought that the following section would have been useful, but unfortunately has not been updated for the v2.7.0 SDK - so doesn’t really help for my debugging purposes 

    academy.nordicsemi.com/.../

    In my error messages,  can see that “Partition ‘mcuboot_primary_app’ is not included in the dynamic resolving since it is statically defined”. Surely this must have something to do with the message since “mcu_primary_app_hex is missing and no known rule to make it”? 

    Do you have any idea why my custom partitions are not being accepted as statically defined? 

    Thank you

  • Great! Thats good, then we have a common foundation for both of us w.r.t what we know. W.r.t the update: the author is working on updating the course, but it has taken longer time than expected to do so.

    Ryan S said:
    “Partition ‘mcuboot_primary_app’ is not included in the dynamic resolving since it is statically defined”.

    This is just a message w.r.t what the build system should create partitions for dynamically or statically. In this case, it will not create a dynamic partition since there exists such a partition in the pm_static.yml stating where it should have its start address and where it should have its end address. Same goes for the other partitions mentioned here. From this point, the dynamical partitioning system will take every other required partition such as companion components or custom storage partitions and fit them in per the spec you've specified in the static partitioning and the configuration of said partitions.

    Ryan S said:
    Do you have any idea why my custom partitions are not being accepted as statically defined? 

    Could you upload a minimal project (static partitioning, prj,conf and relevant other src code) and I'll have a closer look at it after the weekend?

    Kind regards,
    Andreas

  • I see. 

    I have updated the pm_static.yml to mirror the partitions.yml file (with changes to addresses) in build/partitions.yml obtained by building without pm_static.yml. This zip file attached is essentially a fork of https://github.com/nrfconnect/sdk-nrf/tree/main/samples/bluetooth/peripheral_lbs but with the added pm_static.yml and the following config updates: 

    prf.conf

    Fullscreen
    1
    2
    CONFIG_NCS_SAMPLE_MCUMGR_BT_OTA_DFU=y
    CONFIG_BOOTLOADER_MCUBOOT=y
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    sysbuild.conf

    Fullscreen
    1
    2
    SB_CONFIG_BOOTLOADER_MCUBOOT=y
    SB_CONFIG_PARTITION_MANAGER=y
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    There was a typo in my original post where I wrote partition_manager instead of partition_manager_report. Here is the correct build command: 

    west build -b nrf52dk/nrf52832 --sysbuild -d new_build_sysbuild . -t partition_manager_report

    You should be able to replicate the following:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    -- Configuring done
    -- Generating done
    -- Build files have been written to: C:/Users/Ryan/Downloads/peripheral-lbs-sysbuild-main/new_build_sysbuild/peripheral-lbs-sysbuild-main
    -- Found partition manager static configuration : C:/Users/Ryan/Downloads/peripheral-lbs-sysbuild-main/pm_static.yml
    Partition 'mcuboot' is not included in the dynamic resolving since it is statically defined.
    Partition 'mcuboot_pad' is not included in the dynamic resolving since it is statically defined.
    Partition 'mcuboot_primary' is not included in the dynamic resolving since it is statically defined.
    Partition 'mcuboot_primary_app' 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.
    Partition 'settings_storage' is not included in the dynamic resolving since it is statically defined.
    -- Configuring done
    -- Generating done
    -- Build files have been written to: C:/Users/Ryan/Downloads/peripheral-lbs-sysbuild-main/new_build_sysbuild
    ←[92m-- west build: running target partition_manager_report
    [1/1] cmd,exe /C "cd /D C:\Users\Ryan\Downloads\peripheral-lbs...eripheral-lbs-sysbuild-main/new_build_sysbuild/partitions.yml"
    flash_primary (0x80000 - 512kB):
    +-------------------------------------------------+
    | 0x0: mcuboot (0x9000 - 36kB) |
    +---0x9000: mcuboot_primary (0x3a800 - 234kB)-----+
    | 0x9000: mcuboot_pad (0x200 - 512B) |
    +---0x9200: mcuboot_primary_app (0x3a600 - 233kB)-+
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    This seems fine, but when I try to flash I get this error again:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    Building peripheral-lbs-sysbuild-main
    C:\Windows\system32\cmd,exe /d /s /c "west build --build-dir c:/Users/Ryan/Downloads/peripheral-lbs-sysbuild-main/new_build_sysbuild c:/Users/Ryan/Downloads/peripheral-lbs-sysbuild-main"
    ninja: error: '_sysbuild/mcuboot_primary_app_hex', needed by 'mcuboot_primary.hex', missing and no known rule to make it
    FATAL ERROR: command exited with status 1: 'C:\ncs\toolchains\ce3b5ff664\opt\bin\cmake.EXE' --build C:/Users/Ryan/Downloads/peripheral-lbs-sysbuild-main/new_build_sysbuild
    * The terminal process terminated with exit code: 1.
    * Terminal will be reused by tasks, press any key to close it.
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Thank you Andreas!

  •  I was seeing the same issue when trying to use a static partition layout which I had previously used with SDK v2.5 (I am now using v2.9).

    Here are some of the relevant entries from my pm_static.yml;

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    mcuboot_primary_app:
    address: 0x020200
    end_address: 0x0f0000
    size: 0x0cfe00
    region: flash_primary
    #span: [tfm_nonsecure, tfm]
    span: [app, tfm]
    inside: [mcuboot_primary]
    placement:
    after: [mcuboot_pad]
    tfm:
    address: 0x020200
    end_address: 0x030000
    size: 0x00fe00
    region: flash_primary
    inside: [tfm_secure]
    placement:
    after: mcuboot_pad
    tfm_nonsecure:
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    In my mcuboot_primary_app partition entry, if I list it as spanning [tfm_nonseucre, tfm]. I get the same ninja error. However, using [app, tfm] works even though tfm_nonsecure and app both share the same address space. 

    It seems that when defining a span partition, it does not like it if any of the span items are themselves span partitions.

    Your mcuboot_primary partition spans [mcuboot_pad, mcuboot_primary_app] but mcuboot_primary_app is also a span partition. Both your app and mcuboot_primary_app entries cover the same address range, but mcu_primary_app is a span and app is not. 

    Have you tried using the following for your mcuboot_primary entry:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    mcuboot_primary:
    address: 0x9000
    end_address: 0x43800
    orig_span: &id001
    - mcuboot_pad
    - app
    region: flash_primary
    sharers: 0x1
    size: 0x3A800
    span: *id001
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Reply
  •  I was seeing the same issue when trying to use a static partition layout which I had previously used with SDK v2.5 (I am now using v2.9).

    Here are some of the relevant entries from my pm_static.yml;

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    mcuboot_primary_app:
    address: 0x020200
    end_address: 0x0f0000
    size: 0x0cfe00
    region: flash_primary
    #span: [tfm_nonsecure, tfm]
    span: [app, tfm]
    inside: [mcuboot_primary]
    placement:
    after: [mcuboot_pad]
    tfm:
    address: 0x020200
    end_address: 0x030000
    size: 0x00fe00
    region: flash_primary
    inside: [tfm_secure]
    placement:
    after: mcuboot_pad
    tfm_nonsecure:
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    In my mcuboot_primary_app partition entry, if I list it as spanning [tfm_nonseucre, tfm]. I get the same ninja error. However, using [app, tfm] works even though tfm_nonsecure and app both share the same address space. 

    It seems that when defining a span partition, it does not like it if any of the span items are themselves span partitions.

    Your mcuboot_primary partition spans [mcuboot_pad, mcuboot_primary_app] but mcuboot_primary_app is also a span partition. Both your app and mcuboot_primary_app entries cover the same address range, but mcu_primary_app is a span and app is not. 

    Have you tried using the following for your mcuboot_primary entry:

    Fullscreen
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    mcuboot_primary:
    address: 0x9000
    end_address: 0x43800
    orig_span: &id001
    - mcuboot_pad
    - app
    region: flash_primary
    sharers: 0x1
    size: 0x3A800
    span: *id001
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Children