do not open flash nor area partition

Hi Support,

I'm working on a project where I need to copy the contents of the internal flash from slot_0 to an external NOR flash partition. However, I'm currently unable to access the partition named fota-body. After building the project, I get the following errors when trying to access it:

Memory region         Used Size  Region Size  %age Used
           FLASH:       38948 B        48 KB     79.24%
             RAM:       22736 B       448 KB      4.96%
        IDT_LIST:          0 GB        32 KB      0.00%
[171/189] Building C object CMakeFiles/app.dir/src/main.c.obj
FAILED: CMakeFiles/app.dir/src/main.c.obj 
ccache /opt/nordic/ncs/toolchains/15b490767d/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc -DKERNEL -DNRF5340_XXAA_APPLICATION -DNRF_SKIP_FICR_NS_COPY_TO_RAM -DPICOLIBC_LONG_LONG_PRINTF_SCANF -DUSE_PARTITION_MANAGER=1 -D_FORTIFY_SOURCE=1 -D_POSIX_C_SOURCE=200809 -D__LINUX_ERRNO_EXTENSIONS__ -D__PROGRAM_START -D__ZEPHYR__=1 -I/opt/nordic/ncs/v2.6.2/zephyr/include -I/Users/babos/Documents/github_fota_project/hexdump_slot_0/build/zephyr/include/generated -I/opt/nordic/ncs/v2.6.2/zephyr/soc/arm/nordic_nrf/nrf53 -I/opt/nordic/ncs/v2.6.2/zephyr/soc/common/nordic_nrf/. -I/opt/nordic/ncs/v2.6.2/zephyr/soc/arm/nordic_nrf/common/. -I/opt/nordic/ncs/v2.6.2/nrf/include -I/opt/nordic/ncs/v2.6.2/nrf/tests/include -I/opt/nordic/ncs/v2.6.2/modules/hal/cmsis/CMSIS/Core/Include -I/opt/nordic/ncs/v2.6.2/zephyr/modules/cmsis/. -I/opt/nordic/ncs/v2.6.2/modules/hal/nordic/nrfx -I/opt/nordic/ncs/v2.6.2/modules/hal/nordic/nrfx/drivers/include -I/opt/nordic/ncs/v2.6.2/modules/hal/nordic/nrfx/mdk -I/opt/nordic/ncs/v2.6.2/zephyr/modules/hal_nordic/nrfx/. -I/opt/nordic/ncs/v2.6.2/modules/lib/zcbor/include -isystem /opt/nordic/ncs/v2.6.2/zephyr/lib/libc/common/include -isystem /opt/nordic/ncs/v2.6.2/nrfxlib/crypto/nrf_cc312_platform/include -fno-strict-aliasing -Os -imacros /Users/babos/Documents/github_fota_project/hexdump_slot_0/build/zephyr/include/generated/autoconf.h -fno-printf-return-value -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m33 -mthumb -mabi=aapcs -mfp16-format=ieee -mtp=soft --sysroot=/opt/nordic/ncs/toolchains/15b490767d/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi -imacros /opt/nordic/ncs/v2.6.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 -ftls-model=local-exec -fno-reorder-functions --param=min-pagesize=0 -fno-defer-pop -fmacro-prefix-map=/Users/babos/Documents/github_fota_project/hexdump_slot_0=CMAKE_SOURCE_DIR -fmacro-prefix-map=/opt/nordic/ncs/v2.6.2/zephyr=ZEPHYR_BASE -fmacro-prefix-map=/opt/nordic/ncs/v2.6.2=WEST_TOPDIR -ffunction-sections -fdata-sections --specs=picolibc.specs -std=c99 -MD -MT CMakeFiles/app.dir/src/main.c.obj -MF CMakeFiles/app.dir/src/main.c.obj.d -o CMakeFiles/app.dir/src/main.c.obj -c /Users/babos/Documents/github_fota_project/hexdump_slot_0/src/main.c
In file included from /opt/nordic/ncs/v2.6.2/zephyr/include/zephyr/storage/flash_map.h:275,
                 from /Users/babos/Documents/github_fota_project/hexdump_slot_0/src/main.c:3:
/Users/babos/Documents/github_fota_project/hexdump_slot_0/src/main.c: In function 'main':
/opt/nordic/ncs/v2.6.2/nrf/include/flash_map_pm.h:43:22: error: 'PM_fota_body_ID' undeclared (first use in this function); did you mean 'fa_fota_body'?
   43 | #define PM_ID(label) PM_##label##_ID
      |                      ^~~
/opt/nordic/ncs/v2.6.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)
      |                                   ^~~~~
/opt/nordic/ncs/v2.6.2/nrf/include/flash_map_pm.h:49:30: note: in expansion of macro 'FIXED_PARTITION_ID'
   49 | #define FLASH_AREA_ID(label) FIXED_PARTITION_ID(label)
      |                              ^~~~~~~~~~~~~~~~~~
/Users/babos/Documents/github_fota_project/hexdump_slot_0/src/main.c:82:29: note: in expansion of macro 'FLASH_AREA_ID'
   82 |       err = flash_area_open(FLASH_AREA_ID(fota_body), &fa_fota_body);
      |                             ^~~~~~~~~~~~~
/opt/nordic/ncs/v2.6.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
      |                      ^~~
/opt/nordic/ncs/v2.6.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)
      |                                   ^~~~~
/opt/nordic/ncs/v2.6.2/nrf/include/flash_map_pm.h:49:30: note: in expansion of macro 'FIXED_PARTITION_ID'
   49 | #define FLASH_AREA_ID(label) FIXED_PARTITION_ID(label)
      |                              ^~~~~~~~~~~~~~~~~~
/Users/babos/Documents/github_fota_project/hexdump_slot_0/src/main.c:82:29: note: in expansion of macro 'FLASH_AREA_ID'
   82 |       err = flash_area_open(FLASH_AREA_ID(fota_body), &fa_fota_body);
      |                             ^~~~~~~~~~~~~
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: /opt/nordic/ncs/toolchains/15b490767d/bin/cmake --build /Users/babos/Documents/github_fota_project/hexdump_slot_0/build

 *  The terminal process terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it. 

It seems like the partition fota-body is not being defined properly in the build, or it's missing from the partition manager configuration. I've tried using FLASH_AREA_ID(FOTA_BODY_PARTITION_ID) but get compilation errors because PM_FOTA_BODY_ID (or whatever index it resolves to) is undefined.

My goal is to build a 'delta FOTA' system where I can generate and write only the differences between the current firmware and a new image to slot_1, stored in external flash, before performing a firmware swap. This approach is intended to reduce write time and flash wear. However, I'm currently blocked by this partition access issue and can't proceed.

I'm attaching a demo project that reproduces the issue. Any help would be greatly appreciated.

When I comment this code, it correctly reads part of the slot_0 without any issues.
I suspect the fota_body partition is either not properly defined in the partition manager (.yml) or it’s not being exposed with the expected PM_ macro during build.

   // Get information about the slot_0 partition using the flash_map API
   // If I comment out the line below, the project compiles successfully, but I’m still unable to open the fota_body area.
   // =======================================================================================
   const struct flash_area *fa_fota_body;
   err = flash_area_open(FLASH_AREA_ID(fota_body), &fa_fota_body);
   if (err)
   {
      LOG_ERR("Errore nell'apertura della partizione QSPI (fota_body): %d", err);
      flash_area_close(fa);
      return -1;



Best regards,
Babos

ToolChain 2.8.0
SDK 2.6.2

Archivio.zip


Related