Problem with flashdisk and partition_manager

Hi,

I'm upgrading our application from v2.3.0 to v2.5.0 and I ran into an issue where I can't even get the code to compile any more. 

We are using USB mass storage with a filesystem mounted on an external memory device. Since we also use the bootloader we have to rely on partition_manager to set up the partitions. In the older version I had to have an ugly hack in flashdisk.c to make this work as this combination was not supported by your SDK. Now I see that this should be fixed but I'm completely lost and can't get this to work at all.

Here is the errors I get

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
[286/314] Building C object zephyr/drivers/disk/CMakeFiles/drivers__disk.dir/flashdisk.c.obj
FAILED: zephyr/drivers/disk/CMakeFiles/drivers__disk.dir/flashdisk.c.obj
ccache /home/tiit/ncs/toolchains/7795df4459/opt/zephyr-sdk/arm-zephyr-eabi/bin/arm-zephyr-eabi-gcc -DKERNEL -DNRF52840_XXAA -DUSE_PARTITION_MANAGER=1 -D_ANSI_SOURCE -D_FORTIFY_SOURCE=1 -D__LINUX_ERRNO_EXTENSIONS__ -D__PROGRAM_START -D__ZEPHYR_SUPERVISOR__ -D__ZEPHYR__=1 -I/home/tiit/ncs/v2.5.0/nrf/drivers/mpsl/clock_control -I/home/tiit/ncs/v2.5.0/zephyr/include -Izephyr/include/generated -I/home/tiit/ncs/v2.5.0/zephyr/soc/arm/nordic_nrf/nrf52 -I/home/tiit/ncs/v2.5.0/zephyr/lib/libc/newlib/include -I/home/tiit/ncs/v2.5.0/zephyr/soc/arm/nordic_nrf/common/. -I/home/tiit/ncs/v2.5.0/zephyr/subsys/mgmt/mcumgr/util/include -I/home/tiit/ncs/v2.5.0/bootloader/mcuboot/boot/bootutil/include -I/home/tiit/ncs/v2.5.0/zephyr/subsys/mgmt/mcumgr/transport/include -I/home/tiit/ncs/v2.5.0/zephyr/subsys/usb/device -I/home/tiit/ncs/v2.5.0/zephyr/subsys/bluetooth -I/home/tiit/ncs/v2.5.0/zephyr/subsys/settings/include -I/home/tiit/ncs/v2.5.0/nrf/include -I/home/tiit/ncs/v2.5.0/nrf/lib/multithreading_lock/. -I/home/tiit/ncs/v2.5.0/nrf/subsys/bluetooth/controller/. -I/home/tiit/ncs/v2.5.0/zephyr/drivers/flash -I/home/tiit/ncs/v2.5.0/nrf/tests/include -I/home/tiit/ncs/v2.5.0/modules/hal/cmsis/CMSIS/Core/Include -I/home/tiit/ncs/v2.5.0/zephyr/modules/cmsis/. -I/home/tiit/ncs/v2.5.0/modules/hal/nordic/nrfx -I/home/tiit/ncs/v2.5.0/modules/hal/nordic/nrfx/drivers/include -I/home/tiit/ncs/v2.5.0/modules/hal/nordic/nrfx/mdk -I/home/tiit/ncs/v2.5.0/zephyr/modules/hal_nordic/nrfx/. -I/home/tiit/ncs/v2.5.0/modules/debug/segger/SEGGER -I/home/tiit/ncs/v2.5.0/modules/debug/segger/Config -I/home/tiit/ncs/v2.5.0/modules/crypto/tinycrypt/lib/include -I/home/tiit/ncs/v2.5.0/modules/lib/zcbor/include -I/home/tiit/ncs/v2.5.0/nrfxlib/mpsl/fem/common/include -I/home/tiit/ncs/v2.5.0/nrfxlib/mpsl/fem/nrf21540_gpio/include -I/home/tiit/ncs/v2.5.0/nrfxlib/mpsl/fem/nrf21540_gpio_spi/include -I/home/tiit/ncs/v2.5.0/nrfxlib/mpsl/fem/simple_gpio/include -I/home/tiit/ncs/v2.5.0/nrfxlib/mpsl/fem/include -I/home/tiit/ncs/v2.5.0/nrfxlib/mpsl/fem/include/protocol -I/home/tiit/ncs/v2.5.0/nrfxlib/mpsl/include -I/home/tiit/ncs/v2.5.0/nrfxlib/mpsl/include/protocol -I/home/tiit/ncs/v2.5.0/nrfxlib/softdevice_controller/include -isystem /home/tiit/ncs/v2.5.0/nrfxlib/crypto/nrf_cc310_platform/include -Wshadow -fno-strict-aliasing -Os -imacros /home/tiit/code/blindy_v3/build/zephyr/include/generated/autoconf.h -fno-common -g -gdwarf-4 -fdiagnostics-color=always -mcpu=cortex-m4 -mthumb -mabi=aapcs -mfp16-format=ieee --sysroot=/home/tiit/ncs/toolchains/7795df4459/opt/zephyr-sdk/arm-zephyr-eabi/arm-zephyr-eabi -imacros /home/tiit/ncs/v2.5.0/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=/home/tiit/code/blindy_v3=CMAKE_SOURCE_DIR -fmacro-prefix-map=/home/tiit/ncs/v2.5.0/zephyr=ZEPHYR_BASE -fmacro-prefix-map=/home/tiit/ncs/v2.5.0=WEST_TOPDIR -ffunction-sections -fdata-sections -specs=nano.specs -std=c99 -MD -MT zephyr/drivers/disk/CMakeFiles/drivers__disk.dir/flashdisk.c.obj -MF zephyr/drivers/disk/CMakeFiles/drivers__disk.dir/flashdisk.c.obj.d -o zephyr/drivers/disk/CMakeFiles/drivers__disk.dir/flashdisk.c.obj -c /home/tiit/ncs/v2.5.0/zephyr/drivers/disk/flashdisk.c
/home/tiit/ncs/v2.5.0/zephyr/drivers/disk/flashdisk.c:484:1: error: return type defaults to 'int' [-Werror=implicit-int]
484 | PM_FOREACH_AFFILIATED_TO_disk(DEFINE_FLASHDISKS_CACHE)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/drivers/disk/flashdisk.c: In function 'PM_FOREACH_AFFILIATED_TO_disk':
/home/tiit/ncs/v2.5.0/zephyr/drivers/disk/flashdisk.c:523:30: error: storage class specified for parameter 'flash_disks'
523 | static struct flashdisk_data flash_disks[] = {
| ^~~~~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/drivers/disk/flashdisk.c:523:15: error: parameter 'flash_disks' is initialized
523 | static struct flashdisk_data flash_disks[] = {
| ^~~~~~~~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/drivers/disk/flashdisk.c:524:39: error: 'DEFINE_FLASHDISKS_DEVICE' undeclared (first use in this function)
524 | PM_FOREACH_AFFILIATED_TO_disk(DEFINE_FLASHDISKS_DEVICE)
| ^~~~~~~~~~~~~~~~~~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/drivers/disk/flashdisk.c:524:39: note: each undeclared identifier is reported only once for each function it appears in
/home/tiit/ncs/v2.5.0/zephyr/drivers/disk/flashdisk.c:533:1: error: expected declaration specifiers before 'PM_FOREACH_AFFILIATED_TO_disk'
533 | PM_FOREACH_AFFILIATED_TO_disk(VERIFY_CACHE_SIZE_IS_NOT_ZERO_IF_NOT_READ_ONLY)
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /home/tiit/ncs/v2.5.0/zephyr/include/zephyr/toolchain/gcc.h:92,
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

It looks to me that partition_manager is probably supposed to replace the "PM_FOREACH_AFFILIATED_TO_disk" part with something as this does not seem to be a C macro defined anywhere. But how this is actually supposed to happen is not clear to me. I have tried grep-ing for that macro and it only appears in that file and it is never defined. The comments in this file seem to tell me to add some extra parameters to the partition manager definition file but I've tried multiple combinations and nothing seems to work. It doesn't look like this combination is ever used in any of the examples either.

It seems that this macro was added here https://github.com/nrfconnect/sdk-zephyr/commit/6fba504e5e4026e1b563013ac6e7858ca73ea260 by Dominik Ermel <dominik.ermel@nordicsemi.no>. Would it be possible to ask him to provide any help on this issue? It looks to me like maybe this macro definition was mistakenly not added to the release.

Hoping to hear back from you soon,

Tiit