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

[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,
                 from /home/tiit/ncs/v2.5.0/zephyr/include/zephyr/toolchain.h:50,
                 from /home/tiit/ncs/v2.5.0/zephyr/include/zephyr/sys/__assert.h:11,
                 from /home/tiit/ncs/v2.5.0/zephyr/drivers/disk/flashdisk.c:10:
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/init.h:125:44: error: storage class specified for parameter '__init_disk_flash_init'
  125 | #define Z_INIT_ENTRY_NAME(init_id) _CONCAT(__init_, init_id)
      |                                            ^~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/toolchain/common.h:132:26: note: in definition of macro '_DO_CONCAT'
  132 | #define _DO_CONCAT(x, y) x ## y
      |                          ^
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/init.h:125:36: note: in expansion of macro '_CONCAT'
  125 | #define Z_INIT_ENTRY_NAME(init_id) _CONCAT(__init_, init_id)
      |                                    ^~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/init.h:192:17: note: in expansion of macro 'Z_INIT_ENTRY_NAME'
  192 |                 Z_INIT_ENTRY_NAME(name) = {                                    \
      |                 ^~~~~~~~~~~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/init.h:174:9: note: in expansion of macro 'SYS_INIT_NAMED'
  174 |         SYS_INIT_NAMED(init_fn, init_fn, level, prio)
      |         ^~~~~~~~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/drivers/disk/flashdisk.c:563:1: note: in expansion of macro 'SYS_INIT'
  563 | SYS_INIT(disk_flash_init, APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
      | ^~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/init.h:190:42: error: parameter '__init_disk_flash_init' is initialized
  190 |         static const Z_DECL_ALIGN(struct init_entry)                           \
      |                                          ^~~~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/init.h:190:22: note: in expansion of macro 'Z_DECL_ALIGN'
  190 |         static const Z_DECL_ALIGN(struct init_entry)                           \
      |                      ^~~~~~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/init.h:174:9: note: in expansion of macro 'SYS_INIT_NAMED'
  174 |         SYS_INIT_NAMED(init_fn, init_fn, level, prio)
      |         ^~~~~~~~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/drivers/disk/flashdisk.c:563:1: note: in expansion of macro 'SYS_INIT'
  563 | SYS_INIT(disk_flash_init, APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
      | ^~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/init.h:125:44: error: section attribute not allowed for '__init_disk_flash_init'
  125 | #define Z_INIT_ENTRY_NAME(init_id) _CONCAT(__init_, init_id)
      |                                            ^~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/toolchain/common.h:132:26: note: in definition of macro '_DO_CONCAT'
  132 | #define _DO_CONCAT(x, y) x ## y
      |                          ^
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/init.h:125:36: note: in expansion of macro '_CONCAT'
  125 | #define Z_INIT_ENTRY_NAME(init_id) _CONCAT(__init_, init_id)
      |                                    ^~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/init.h:192:17: note: in expansion of macro 'Z_INIT_ENTRY_NAME'
  192 |                 Z_INIT_ENTRY_NAME(name) = {                                    \
      |                 ^~~~~~~~~~~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/init.h:174:9: note: in expansion of macro 'SYS_INIT_NAMED'
  174 |         SYS_INIT_NAMED(init_fn, init_fn, level, prio)
      |         ^~~~~~~~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/drivers/disk/flashdisk.c:563:1: note: in expansion of macro 'SYS_INIT'
  563 | SYS_INIT(disk_flash_init, APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
      | ^~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/init.h:190:42: warning: 'used' attribute ignored [-Wattributes]
  190 |         static const Z_DECL_ALIGN(struct init_entry)                           \
      |                                          ^~~~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/init.h:190:22: note: in expansion of macro 'Z_DECL_ALIGN'
  190 |         static const Z_DECL_ALIGN(struct init_entry)                           \
      |                      ^~~~~~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/init.h:174:9: note: in expansion of macro 'SYS_INIT_NAMED'
  174 |         SYS_INIT_NAMED(init_fn, init_fn, level, prio)
      |         ^~~~~~~~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/drivers/disk/flashdisk.c:563:1: note: in expansion of macro 'SYS_INIT'
  563 | SYS_INIT(disk_flash_init, APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
      | ^~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/init.h:125:44: error: alignment may not be specified for '__init_disk_flash_init'
  125 | #define Z_INIT_ENTRY_NAME(init_id) _CONCAT(__init_, init_id)
      |                                            ^~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/toolchain/common.h:132:26: note: in definition of macro '_DO_CONCAT'
  132 | #define _DO_CONCAT(x, y) x ## y
      |                          ^
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/init.h:125:36: note: in expansion of macro '_CONCAT'
  125 | #define Z_INIT_ENTRY_NAME(init_id) _CONCAT(__init_, init_id)
      |                                    ^~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/init.h:192:17: note: in expansion of macro 'Z_INIT_ENTRY_NAME'
  192 |                 Z_INIT_ENTRY_NAME(name) = {                                    \
      |                 ^~~~~~~~~~~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/init.h:174:9: note: in expansion of macro 'SYS_INIT_NAMED'
  174 |         SYS_INIT_NAMED(init_fn, init_fn, level, prio)
      |         ^~~~~~~~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/drivers/disk/flashdisk.c:563:1: note: in expansion of macro 'SYS_INIT'
  563 | SYS_INIT(disk_flash_init, APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
      | ^~~~~~~~
In file included from /home/tiit/ncs/v2.5.0/zephyr/drivers/disk/flashdisk.c:14:
/home/tiit/ncs/v2.5.0/zephyr/drivers/disk/flashdisk.c:563:10: error: 'disk_flash_init' undeclared (first use in this function)
  563 | SYS_INIT(disk_flash_init, APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
      |          ^~~~~~~~~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/init.h:193:45: note: in definition of macro 'SYS_INIT_NAMED'
  193 |                         .init_fn = {.sys = (init_fn_)},                        \
      |                                             ^~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/drivers/disk/flashdisk.c:563:1: note: in expansion of macro 'SYS_INIT'
  563 | SYS_INIT(disk_flash_init, APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
      | ^~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/drivers/disk/flashdisk.c:484:1: error: type of 'DEFINE_FLASHDISKS_CACHE' defaults to 'int' [-Werror=implicit-int]
  484 | PM_FOREACH_AFFILIATED_TO_disk(DEFINE_FLASHDISKS_CACHE)
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/init.h:125:44: error: declaration for parameter '__init_disk_flash_init' but no such parameter
  125 | #define Z_INIT_ENTRY_NAME(init_id) _CONCAT(__init_, init_id)
      |                                            ^~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/toolchain/common.h:132:26: note: in definition of macro '_DO_CONCAT'
  132 | #define _DO_CONCAT(x, y) x ## y
      |                          ^
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/init.h:125:36: note: in expansion of macro '_CONCAT'
  125 | #define Z_INIT_ENTRY_NAME(init_id) _CONCAT(__init_, init_id)
      |                                    ^~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/init.h:192:17: note: in expansion of macro 'Z_INIT_ENTRY_NAME'
  192 |                 Z_INIT_ENTRY_NAME(name) = {                                    \
      |                 ^~~~~~~~~~~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/include/zephyr/init.h:174:9: note: in expansion of macro 'SYS_INIT_NAMED'
  174 |         SYS_INIT_NAMED(init_fn, init_fn, level, prio)
      |         ^~~~~~~~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/drivers/disk/flashdisk.c:563:1: note: in expansion of macro 'SYS_INIT'
  563 | SYS_INIT(disk_flash_init, APPLICATION, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
      | ^~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/drivers/disk/flashdisk.c:523:30: error: declaration for parameter 'flash_disks' but no such parameter
  523 | static struct flashdisk_data flash_disks[] = {
      |                              ^~~~~~~~~~~
/home/tiit/ncs/v2.5.0/zephyr/drivers/disk/flashdisk.c:564: error: expected '{' at end of input
/home/tiit/ncs/v2.5.0/zephyr/drivers/disk/flashdisk.c:564: warning: control reaches end of non-void function [-Wreturn-type]
/home/tiit/ncs/v2.5.0/zephyr/drivers/disk/flashdisk.c: At top level:
/home/tiit/ncs/v2.5.0/zephyr/drivers/disk/flashdisk.c:415:37: warning: 'flash_disk_ops' defined but not used [-Wunused-const-variable=]
  415 | static const struct disk_operations flash_disk_ops = {
      |                                     ^~~~~~~~~~~~~~
cc1: some warnings being treated as errors
[294/314] Building C object modules/mcuboot/boot/bootutil/zephyr/CMakeFiles/mcuboot_util.dir/home/tiit/ncs/v2.5.0/bootloader/mcuboot/boot/bootutil/src/bootutil_public.c.obj
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: /home/tiit/ncs/toolchains/7795df4459/usr/local/bin/cmake --build /home/tiit/code/blindy_v3/build

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 <[email protected]>. 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

Parents
  • Hi,Tiit

    I have the same problem as you now, can you solve it now, can you share it?

    My pm_static.yml

  • Hi,

    What version of the SDK are you using? I just checked and at least for me in older versions the only way to get this working was to modify /zephyr/drivers/disk/flashdisk.c in the SDK. I think there is a fix in the newer versions but I have not worked on this issue or upgraded my SDK in a long time so I can't be sure if the fix helps. We have also moved to using LittleFS from FAT so that may have changed something. I just tried and it seems that I no longer need the manual fix in the SDK for my code to at least compile in SDK 2.5.0. I will be upgrading to the latest SDK in week or so and if there is any problems in that upgrade I will write that here.

    Tiit 

Reply
  • Hi,

    What version of the SDK are you using? I just checked and at least for me in older versions the only way to get this working was to modify /zephyr/drivers/disk/flashdisk.c in the SDK. I think there is a fix in the newer versions but I have not worked on this issue or upgraded my SDK in a long time so I can't be sure if the fix helps. We have also moved to using LittleFS from FAT so that may have changed something. I just tried and it seems that I no longer need the manual fix in the SDK for my code to at least compile in SDK 2.5.0. I will be upgrading to the latest SDK in week or so and if there is any problems in that upgrade I will write that here.

    Tiit 

Children
No Data
Related