code build issue with mcuboot and mass storage

Hi,

I switched from NCS v2.3.0 to NCS v2.4.0. My code was building correctly with mcuboot and flash disk with NCS v2.3.0, but now I am getting the following error with newer SDK:

C:\Backup\ncs-workspace\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)
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/Backup/ncs-workspace/zephyr/drivers/disk/flashdisk.c: In function 'PM_FOREACH_AFFILIATED_TO_disk':
C:\Backup\ncs-workspace\zephyr\drivers\disk\flashdisk.c:523:30: error: storage class specified for parameter 'flash_disks'
  523 | static struct flashdisk_data flash_disks[] = {
      |                              ^~~~~~~~~~~
C:\Backup\ncs-workspace\zephyr\drivers\disk\flashdisk.c:523:15: error: parameter 'flash_disks' is initialized
  523 | static struct flashdisk_data flash_disks[] = {
      |               ^~~~~~~~~~~~~~
C:\Backup\ncs-workspace\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)
      |                                       ^~~~~~~~~~~~~~~~~~~~~~~~
C:\Backup\ncs-workspace\zephyr\drivers\disk\flashdisk.c:524:39: note: each undeclared identifier is reported only once for each function it appears in
C:\Backup\ncs-workspace\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 C:\Backup\ncs-workspace\zephyr\include\zephyr\toolchain\gcc.h:92,
                 from C:\Backup\ncs-workspace\zephyr\include\zephyr\toolchain.h:50,
                 from C:\Backup\ncs-workspace\zephyr\lib\libc\minimal\include\string.h:13,
                 from C:\Backup\ncs-workspace\zephyr\drivers\disk\flashdisk.c:8:
C:\Backup\ncs-workspace\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)
      |                                            ^~~~~~~
C:\Backup\ncs-workspace\zephyr\include\zephyr\init.h:190:17: note: in expansion of macro 'Z_INIT_ENTRY_NAME'
  190 |                 Z_INIT_ENTRY_NAME(name) = {                                    \
      |                 ^~~~~~~~~~~~~~~~~
C:\Backup\ncs-workspace\zephyr\include\zephyr\init.h:172:9: note: in expansion of macro 'SYS_INIT_NAMED'
  172 |         SYS_INIT_NAMED(init_fn, init_fn, level, prio)
      |         ^~~~~~~~~~~~~~
C:\Backup\ncs-workspace\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);
      | ^~~~~~~~
C:\Backup\ncs-workspace\zephyr\include\zephyr\init.h:188:42: error: parameter '__init_disk_flash_init' is initialized
  188 |         static const Z_DECL_ALIGN(struct init_entry)                           \
      |                                          ^~~~~~~~~~
C:\Backup\ncs-workspace\zephyr\include\zephyr\init.h:172:9: note: in expansion of macro 'SYS_INIT_NAMED'
  172 |         SYS_INIT_NAMED(init_fn, init_fn, level, prio)
      |         ^~~~~~~~~~~~~~
C:\Backup\ncs-workspace\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);
      | ^~~~~~~~
C:\Backup\ncs-workspace\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)
      |                                            ^~~~~~~
C:\Backup\ncs-workspace\zephyr\include\zephyr\init.h:190:17: note: in expansion of macro 'Z_INIT_ENTRY_NAME'
  190 |                 Z_INIT_ENTRY_NAME(name) = {                                    \
      |                 ^~~~~~~~~~~~~~~~~
C:\Backup\ncs-workspace\zephyr\include\zephyr\init.h:172:9: note: in expansion of macro 'SYS_INIT_NAMED'
  172 |         SYS_INIT_NAMED(init_fn, init_fn, level, prio)
      |         ^~~~~~~~~~~~~~
C:\Backup\ncs-workspace\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);
      | ^~~~~~~~
C:\Backup\ncs-workspace\zephyr\include\zephyr\init.h:188:42: warning: 'used' attribute ignored [-Wattributes]
  188 |         static const Z_DECL_ALIGN(struct init_entry)                           \
      |                                          ^~~~~~~~~~
C:\Backup\ncs-workspace\zephyr\include\zephyr\init.h:172:9: note: in expansion of macro 'SYS_INIT_NAMED'
  172 |         SYS_INIT_NAMED(init_fn, init_fn, level, prio)
      |         ^~~~~~~~~~~~~~
C:\Backup\ncs-workspace\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);
      | ^~~~~~~~
C:\Backup\ncs-workspace\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)
      |                                            ^~~~~~~
C:\Backup\ncs-workspace\zephyr\include\zephyr\init.h:190:17: note: in expansion of macro 'Z_INIT_ENTRY_NAME'
  190 |                 Z_INIT_ENTRY_NAME(name) = {                                    \
      |                 ^~~~~~~~~~~~~~~~~
C:\Backup\ncs-workspace\zephyr\include\zephyr\init.h:172:9: note: in expansion of macro 'SYS_INIT_NAMED'
  172 |         SYS_INIT_NAMED(init_fn, init_fn, level, prio)
      |         ^~~~~~~~~~~~~~
C:\Backup\ncs-workspace\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 C:\Backup\ncs-workspace\zephyr\drivers\disk\flashdisk.c:14:
C:\Backup\ncs-workspace\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);
      |          ^~~~~~~~~~~~~~~
C:\Backup\ncs-workspace\zephyr\include\zephyr\init.h:191:45: note: in definition of macro 'SYS_INIT_NAMED'
  191 |                         .init_fn = {.sys = (init_fn_)},                        \
      |                                             ^~~~~~~~
C:\Backup\ncs-workspace\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);
      | ^~~~~~~~
C:\Backup\ncs-workspace\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)
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:\Backup\ncs-workspace\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)
      |                                            ^~~~~~~
C:\Backup\ncs-workspace\zephyr\include\zephyr\init.h:190:17: note: in expansion of macro 'Z_INIT_ENTRY_NAME'
  190 |                 Z_INIT_ENTRY_NAME(name) = {                                    \
      |                 ^~~~~~~~~~~~~~~~~
C:\Backup\ncs-workspace\zephyr\include\zephyr\init.h:172:9: note: in expansion of macro 'SYS_INIT_NAMED'
  172 |         SYS_INIT_NAMED(init_fn, init_fn, level, prio)
      |         ^~~~~~~~~~~~~~
C:\Backup\ncs-workspace\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);
      | ^~~~~~~~
C:\Backup\ncs-workspace\zephyr\drivers\disk\flashdisk.c:523:30: error: declaration for parameter 'flash_disks' but no such parameter
  523 | static struct flashdisk_data flash_disks[] = {
      |                              ^~~~~~~~~~~
C:\Backup\ncs-workspace\zephyr\drivers\disk\flashdisk.c:565: error: expected '{' at end of input
C:\Backup\ncs-workspace\zephyr\drivers\disk\flashdisk.c:565: warning: control reaches end of non-void function [-Wreturn-type]
C:/Backup/ncs-workspace/zephyr/drivers/disk/flashdisk.c: At top level:
C:\Backup\ncs-workspace\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.exe: some warnings being treated as errors

For generate the above error, please add below configuration in smp_svr sample:

#USB related configs
CONFIG_USB_DEVICE_STACK=y
CONFIG_USB_DEVICE_PRODUCT="Zephyr MSC sample"
CONFIG_LOG=y
CONFIG_USB_DRIVER_LOG_LEVEL_ERR=y
CONFIG_USB_MASS_STORAGE=y
CONFIG_USB_DEVICE_LOG_LEVEL_ERR=y
CONFIG_USB_MASS_STORAGE_LOG_LEVEL_ERR=y

CONFIG_APP_MSC_STORAGE_FLASH_LITTLEFS=y

Please help to solve this build issue with ncsv2.4.0.

Related