error: 'PM_mcuboot_secondary_ID' undeclared on ncs v2.5.2

I added CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y to prj.conf file. And adding the following content to pm_static_dfu.yml file. But west build failed.

mcuboot:
    address: 0x0
    size: 0x8000
    region: flash_primary
mcuboot_pad:
    address: 0x8000
    size: 0x200
app:
    address: 0x8200
    size: 0xf2e00
mcuboot_primary:
    orig_span: &id001
        - mcuboot_pad
        - app
    span: *id001
    address: 0x8000
    size: 0xf3000
    region: flash_primary
mcuboot_primary_app:
    orig_span: &id002
        - app
    span: *id002
    address: 0x8200
    size: 0xf2e00
factory_data:
    address: 0xfb000
    size: 0x1000
    region: flash_primary
settings_storage:
    address: 0xfc000
    size: 0x4000
    region: flash_primary
mcuboot_primary_1:
    address: 0x0
    size: 0x40000
    device: flash_ctrl
    region: ram_flash
mcuboot_secondary:
    address: 0x0
    size: 0xf3000
    device: MX25R64
    region: external_flash
mcuboot_secondary_1:
    address: 0xf3000
    size: 0x40000
    device: MX25R64
    region: external_flash
external_flash:
    address: 0x133000
    size: 0x6CD000
    device: MX25R64
    region: external_flash
pcd_sram:
    address: 0x20000000
    size: 0x2000
    region: sram_primary

The following are west build messages.

C:\ncs\v2.5.2\nrf\samples\caf_pm_static_enable>rm -rf build

C:\ncs\v2.5.2\nrf\samples\caf_pm_static_enable>west build -b nrf5340dk_nrf5340_cpuapp
-- west build: generating a build system
-- PM_STATIC_YML_FILE: C:/ncs/v2.5.2/nrf/samples/caf_pm_static_enable/configuration/nrf5340dk_nrf5340_cpuapp/pm_static_dfu.yml
...
In file included from C:/ncs/v2.5.2/zephyr/include/zephyr/storage/flash_map.h:275,
                 from C:/ncs/v2.5.2/zephyr/subsys/mgmt/mcumgr/grp/img_mgmt/src/zephyr_img_mgmt.c:10:
C:/ncs/v2.5.2/zephyr/subsys/mgmt/mcumgr/grp/img_mgmt/src/zephyr_img_mgmt.c: In function 'img_mgmt_flash_area_id':
C:/ncs/v2.5.2/nrf/include/flash_map_pm.h:43:22: error: 'PM_mcuboot_secondary_ID' undeclared (first use in this function); did you mean 'PM_mcuboot_primary_ID'?
   43 | #define PM_ID(label) PM_##label##_ID
      |                      ^~~
C:/ncs/v2.5.2/nrf/include/flash_map_pm.h:48:35: note: in expansion of macro 'PM_ID'
   48 | #define FIXED_PARTITION_ID(label) PM_ID(label)
      |                                   ^~~~~
C:/ncs/v2.5.2/zephyr/subsys/mgmt/mcumgr/grp/img_mgmt/src/zephyr_img_mgmt.c:139:25: note: in expansion of macro 'FIXED_PARTITION_ID'
  139 |                 fa_id = FIXED_PARTITION_ID(SLOT1_PARTITION);
      |                         ^~~~~~~~~~~~~~~~~~
C:/ncs/v2.5.2/nrf/include/flash_map_pm.h:43:22: note: each undeclared identifier is reported only once for each function it appears in
   43 | #define PM_ID(label) PM_##label##_ID
      |                      ^~~
C:/ncs/v2.5.2/nrf/include/flash_map_pm.h:48:35: note: in expansion of macro 'PM_ID'
   48 | #define FIXED_PARTITION_ID(label) PM_ID(label)
      |                                   ^~~~~
C:/ncs/v2.5.2/zephyr/subsys/mgmt/mcumgr/grp/img_mgmt/src/zephyr_img_mgmt.c:139:25: note: in expansion of macro 'FIXED_PARTITION_ID'
  139 |                 fa_id = FIXED_PARTITION_ID(SLOT1_PARTITION);
      |                         ^~~~~~~~~~~~~~~~~~
[206/326] Building C object zephyr/subsys/mgmt/mcumgr/grp/img_mgmt/CMakeFiles/subsys__mgmt__mcumgr__grp__img_mgmt.dir/src/img_mgmt.c.obj
FAILED: zephyr/subsys/mgmt/mcumgr/grp/img_mgmt/CMakeFiles/subsys__mgmt__mcumgr__grp__img_mgmt.dir/src/img_mgmt.c.obj
C:\ncs\toolchains\c57af46cb7\opt\zephyr-sdk\arm-zephyr-eabi\bin\arm-zephyr-eabi-gcc.exe -DKERNEL -DNRF5340_XXAA_APPLICATION -DNRF_SKIP_FICR_NS_COPY_TO_RAM -DUSE_PARTITION_MANAGER=1 -D_ANSI_SOURCE -D_FORTIFY_SOURCE=1 -D__LINUX_ERRNO_EXTENSIONS__ -D__PROGRAM_START -D__ZEPHYR__=1 -IC:/ncs/v2.5.2/zephyr/subsys/mgmt/mcumgr/grp/img_mgmt/include -IC:/ncs/v2.5.2/zephyr/include -Izephyr/include/generated -IC:/ncs/v2.5.2/zephyr/soc/arm/nordic_nrf/nrf53 -IC:/ncs/v2.5.2/zephyr/lib/libc/newlib/include -IC:/ncs/v2.5.2/zephyr/soc/arm/nordic_nrf/common/. -IC:/ncs/v2.5.2/zephyr/subsys/mgmt/mcumgr/util/include -IC:/ncs/v2.5.2/bootloader/mcuboot/boot/bootutil/include -IC:/ncs/v2.5.2/zephyr/subsys/mgmt/mcumgr/transport/include -IC:/ncs/v2.5.2/bootloader/mcuboot/boot/zephyr/include -IC:/ncs/v2.5.2/zephyr/subsys/bluetooth -IC:/ncs/v2.5.2/nrf/include -IC:/ncs/v2.5.2/nrf/subsys/app_event_manager/. -IC:/ncs/v2.5.2/nrf/subsys/app_event_manager_profiler_tracer/. -IC:/ncs/v2.5.2/nrf/tests/include -IC:/ncs/v2.5.2/modules/hal/cmsis/CMSIS/Core/Include -IC:/ncs/v2.5.2/zephyr/modules/cmsis/. -IC:/ncs/v2.5.2/modules/hal/nordic/nrfx -IC:/ncs/v2.5.2/modules/hal/nordic/nrfx/drivers/include -IC:/ncs/v2.5.2/modules/hal/nordic/nrfx/mdk -IC:/ncs/v2.5.2/zephyr/modules/hal_nordic/nrfx/. -Imodules/libmetal/libmetal/lib/include -IC:/ncs/v2.5.2/modules/lib/open-amp/open-amp/lib/include -IC:/ncs/v2.5.2/modules/debug/segger/SEGGER -IC:/ncs/v2.5.2/modules/debug/segger/Config -IC:/ncs/v2.5.2/modules/crypto/tinycrypt/lib/include -IC:/ncs/v2.5.2/modules/lib/zcbor/include -IC:/ncs/v2.5.2/nrf/samples/caf_pm_static_enable/configuration/nrf5340dk_nrf5340_cpuapp -IC:/ncs/v2.5.2/nrfxlib/softdevice_controller/include -IC:/ncs/v2.5.2/bootloader/mcuboot/boot/bootutil/zephyr/.. -IC:/ncs/v2.5.2/bootloader/mcuboot/boot/bootutil/zephyr/../include -IC:/ncs/v2.5.2/bootloader/mcuboot/boot/bootutil/zephyr/../../zephyr/include -isystem C:/ncs/v2.5.2/nrfxlib/crypto/nrf_cc312_platform/include -Wshadow -fno-strict-aliasing -Os -imacros C:/ncs/v2.5.2/nrf/samples/caf_pm_static_enable/build/zephyr/include/generated/autoconf.h -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m33 -mthumb -mabi=aapcs -mfp16-format=ieee --sysroot=C:/ncs/toolchains/c57af46cb7/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi -imacros C:/ncs/v2.5.2/zephyr/include/zephyr/toolchain/zephyr_stdint.h -Wall -Wformat -Wformat-security -Wno-format-zero-length -Wno-pointer-sign -Wpointer-arith -Wexpansion-to-defined -Wno-unused-but-set-variable -Werror=implicit-int -fno-pic -fno-pie -fno-asynchronous-unwind-tables -fno-reorder-functions --param=min-pagesize=0 -fno-defer-pop -fmacro-prefix-map=C:/ncs/v2.5.2/nrf/samples/caf_pm_static_enable=CMAKE_SOURCE_DIR -fmacro-prefix-map=C:/ncs/v2.5.2/zephyr=ZEPHYR_BASE -fmacro-prefix-map=C:/ncs/v2.5.2=WEST_TOPDIR -ffunction-sections -fdata-sections -specs=nano.specs -std=c99 -MD -MT zephyr/subsys/mgmt/mcumgr/grp/img_mgmt/CMakeFiles/subsys__mgmt__mcumgr__grp__img_mgmt.dir/src/img_mgmt.c.obj -MF zephyr\subsys\mgmt\mcumgr\grp\img_mgmt\CMakeFiles\subsys__mgmt__mcumgr__grp__img_mgmt.dir\src\img_mgmt.c.obj.d -o zephyr/subsys/mgmt/mcumgr/grp/img_mgmt/CMakeFiles/subsys__mgmt__mcumgr__grp__img_mgmt.dir/src/img_mgmt.c.obj -c C:/ncs/v2.5.2/zephyr/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt.c
In file included from C:/ncs/v2.5.2/zephyr/include/zephyr/sys/util_macro.h:34,
                 from C:/ncs/v2.5.2/zephyr/include/zephyr/sys/util.h:17,
                 from C:/ncs/v2.5.2/zephyr/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt.c:8:
C:/ncs/v2.5.2/zephyr/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt.c: In function 'img_mgmt_active_slot':
C:/ncs/v2.5.2/nrf/include/flash_map_pm.h:52:18: error: 'PM_PM_PM_mcuboot_secondary_ID_LABEL_OFFSET' undeclared (first use in this function)
   52 |         UTIL_CAT(PM_, UTIL_CAT(UTIL_CAT(PM_, UTIL_CAT(PM_ID(label), _LABEL)), x))
      |                  ^~~
C:/ncs/v2.5.2/zephyr/include/zephyr/sys/util_internal.h:105:36: note: in definition of macro 'UTIL_PRIMITIVE_CAT'
  105 | #define UTIL_PRIMITIVE_CAT(a, ...) a##__VA_ARGS__
      |                                    ^
C:/ncs/v2.5.2/nrf/include/flash_map_pm.h:52:9: note: in expansion of macro 'UTIL_CAT'
   52 |         UTIL_CAT(PM_, UTIL_CAT(UTIL_CAT(PM_, UTIL_CAT(PM_ID(label), _LABEL)), x))
      |         ^~~~~~~~
C:/ncs/v2.5.2/nrf/include/flash_map_pm.h:55:39: note: in expansion of macro 'FIXED_PARTITION_DATA_FIELD'
   55 | #define FIXED_PARTITION_OFFSET(label) FIXED_PARTITION_DATA_FIELD(label, _OFFSET)
      |                                       ^~~~~~~~~~~~~~~~~~~~~~~~~~
C:/ncs/v2.5.2/zephyr/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt.c:50:10: note: in expansion of macro 'FIXED_PARTITION_OFFSET'
   50 |         (FIXED_PARTITION_OFFSET(label) == (PM_ADDRESS - PM_ADDRESS_OFFSET))
      |          ^~~~~~~~~~~~~~~~~~~~~~
C:/ncs/v2.5.2/zephyr/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt.c:164:13: note: in expansion of macro 'FIXED_PARTITION_IS_RUNNING_APP_PARTITION'
  164 |         if (FIXED_PARTITION_IS_RUNNING_APP_PARTITION(slot1_partition)) {
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/ncs/v2.5.2/nrf/include/flash_map_pm.h:52:18: note: each undeclared identifier is reported only once for each function it appears in
   52 |         UTIL_CAT(PM_, UTIL_CAT(UTIL_CAT(PM_, UTIL_CAT(PM_ID(label), _LABEL)), x))
      |                  ^~~
C:/ncs/v2.5.2/zephyr/include/zephyr/sys/util_internal.h:105:36: note: in definition of macro 'UTIL_PRIMITIVE_CAT'
  105 | #define UTIL_PRIMITIVE_CAT(a, ...) a##__VA_ARGS__
      |                                    ^
C:/ncs/v2.5.2/nrf/include/flash_map_pm.h:52:9: note: in expansion of macro 'UTIL_CAT'
   52 |         UTIL_CAT(PM_, UTIL_CAT(UTIL_CAT(PM_, UTIL_CAT(PM_ID(label), _LABEL)), x))
      |         ^~~~~~~~
C:/ncs/v2.5.2/nrf/include/flash_map_pm.h:55:39: note: in expansion of macro 'FIXED_PARTITION_DATA_FIELD'
   55 | #define FIXED_PARTITION_OFFSET(label) FIXED_PARTITION_DATA_FIELD(label, _OFFSET)
      |                                       ^~~~~~~~~~~~~~~~~~~~~~~~~~
C:/ncs/v2.5.2/zephyr/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt.c:50:10: note: in expansion of macro 'FIXED_PARTITION_OFFSET'
   50 |         (FIXED_PARTITION_OFFSET(label) == (PM_ADDRESS - PM_ADDRESS_OFFSET))
      |          ^~~~~~~~~~~~~~~~~~~~~~
C:/ncs/v2.5.2/zephyr/subsys/mgmt/mcumgr/grp/img_mgmt/src/img_mgmt.c:164:13: note: in expansion of macro 'FIXED_PARTITION_IS_RUNNING_APP_PARTITION'
  164 |         if (FIXED_PARTITION_IS_RUNNING_APP_PARTITION(slot1_partition)) {
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[210/326] Linking C static library zephyr\libzephyr.a
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: 'C:\ncs\toolchains\c57af46cb7\opt\bin\cmake.EXE' --build 'C:\ncs\v2.5.2\nrf\samples\caf_pm_static_enable\build'

Procedures to reproduce this issue are as follows.

1. Unzipping caf_pm_static_enable.zip to C:\ncs\v2.5.2\nrf\samples folder

2. cd C:\ncs\v2.5.2\nrf\samples\caf_pm_static_enable

3. west build -b nrf5340dk_nrf5340_cpuapp

Related