code build errors with mcuboot and mass storage: nRF52840

1. I am trying to implement DFU(with USB&BLE) and USB Mass Storage with FAT FS filesystems on external QSPI flash. I am getting the following build errors- with SDK version 2.9.0

2. without mcuboot configurations i could access the usb mass storage drive.


3. From the overlay file, when i remove the flashdisk node(i.e compatible="zephyr,flash-disk"), i did not get any build errors but i was not able to access the usb mass storage drive.

/********************* overlay ****************************/

&qspi {
	status = "okay";
	pinctrl-0 = <&qspi_default>;
	pinctrl-1 = <&qspi_sleep>;
	pinctrl-names = "default", "sleep";
	p25q16h: p25q16h@0 {
		compatible = "nordic,qspi-nor";
		reg = <0>;
		sck-frequency = <104000000>;
		quad-enable-requirements = "S2B1v1";
		jedec-id = [85 60 15];
		sfdp-bfp = [
			e5 20 f1 ff  ff ff ff 00  44 eb 08 6b  08 3b 80 bb
			ee ff ff ff  ff ff 00 ff  ff ff 00 ff  0c 20 0f 52
			10 d8 08 81
		];
		label = "NAND";
		size = <16777216>;  //size is in bits
		has-dpd;
		t-enter-dpd = <3000>;
		t-exit-dpd = <8000>;
	

         partitions {
		compatible = "fixed-partitions";
		#address-cells = <1>;
		#size-cells = <1>;

		fatfs_part: partition@0 {
   			 label = "fatfs";
    		reg = <0x00000000 0x00200000>;  // 2MB
			};

		};

	};
};



/ {
	disk0: disk {
	 compatible = "zephyr,flash-disk";
		disk-name = "NAND";
		partition = <&fatfs_part>;
		sector-size = <512>;
		cache-size = <4096>;
	};
};


&flash0 {
	status = "okay";
	partitions {
		compatible = "fixed-partitions";
		#address-cells = <1>;
		#size-cells = <1>;

		boot_partition: partition@0 {
			label = "mcuboot";
			reg = <0x00000000 0x0000C000>;
		};
		slot0_partition: partition@c000 {
			label = "image-0" ;                                //"mcuboot_primary";
			reg = <0x0000C000 0x00076000>;
		};
		slot1_partition: partition@82000 {
			label =  "image-1" ;                                             //"mcuboot_secondary";
			reg = <0x00082000 0x00076000>;
		};

		/*
		 * The flash starting at 0x000f8000 and ending at
		 * 0x000fffff is reserved for use by the application.
		 */

		/*
		 * Storage partition will be used by FCB/LittleFS/NVS
		 * if enabled.
		 */
		storage_partition: partition@f8000 {
			label = "storage";
			reg = <0x000f8000 0x00008000>;
		};
	};
};


/*********************Build errors*************************/

D:/ncs/v2.9.0/zephyr/drivers/disk/flashdisk.c:533:1: error: return type defaults to 'int' [-Werror=implicit-int]
  533 | PM_FOREACH_AFFILIATED_TO_disk(DEFINE_FLASHDISKS_CACHE)
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
D:/ncs/v2.9.0/zephyr/drivers/disk/flashdisk.c: In function 'PM_FOREACH_AFFILIATED_TO_disk':
D:/ncs/v2.9.0/zephyr/drivers/disk/flashdisk.c:572:30: error: storage class specified for parameter 'flash_disks'
  572 | static struct flashdisk_data flash_disks[] = {
      |                              ^~~~~~~~~~~
D:/ncs/v2.9.0/zephyr/drivers/disk/flashdisk.c:572:15: error: parameter 'flash_disks' is initialized
  572 | static struct flashdisk_data flash_disks[] = {
      |               ^~~~~~~~~~~~~~
D:/ncs/v2.9.0/zephyr/drivers/disk/flashdisk.c:573:39: error: 'DEFINE_FLASHDISKS_DEVICE' undeclared (first use in this function)
  573 |         PM_FOREACH_AFFILIATED_TO_disk(DEFINE_FLASHDISKS_DEVICE)
      |                                       ^~~~~~~~~~~~~~~~~~~~~~~~
D:/ncs/v2.9.0/zephyr/drivers/disk/flashdisk.c:573:39: note: each undeclared identifier is reported only once for each function it appears in
D:/ncs/v2.9.0/zephyr/drivers/disk/flashdisk.c:582:1: error: expected declaration specifiers before 'PM_FOREACH_AFFILIATED_TO_disk'
  582 | PM_FOREACH_AFFILIATED_TO_disk(VERIFY_CACHE_SIZE_IS_NOT_ZERO_IF_NOT_READ_ONLY)
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from D:/ncs/v2.9.0/zephyr/include/zephyr/toolchain/gcc.h:98,
                 from D:/ncs/v2.9.0/zephyr/include/zephyr/toolchain.h:50,
                 from D:/ncs/v2.9.0/zephyr/include/zephyr/sys/__assert.h:11,
                 from D:/ncs/v2.9.0/zephyr/drivers/disk/flashdisk.c:10:
D:/ncs/v2.9.0/zephyr/include/zephyr/init.h:141:44: error: storage class specified for parameter '__init_disk_flash_init'
  141 | #define Z_INIT_ENTRY_NAME(init_id) _CONCAT(__init_, init_id)
      |                                            ^~~~~~~
D:/ncs/v2.9.0/zephyr/include/zephyr/toolchain/common.h:137:26: note: in definition of macro '_DO_CONCAT'
  137 | #define _DO_CONCAT(x, y) x ## y
      |                          ^
D:/ncs/v2.9.0/zephyr/include/zephyr/init.h:141:36: note: in expansion of macro '_CONCAT'
  141 | #define Z_INIT_ENTRY_NAME(init_id) _CONCAT(__init_, init_id)
      |                                    ^~~~~~~
D:/ncs/v2.9.0/zephyr/include/zephyr/init.h:241:17: note: in expansion of macro 'Z_INIT_ENTRY_NAME'
  241 |                 Z_INIT_ENTRY_NAME(name) = {.init_fn = {.sys = (init_fn_)},                \
      |                 ^~~~~~~~~~~~~~~~~
D:/ncs/v2.9.0/zephyr/include/zephyr/init.h:223:9: note: in expansion of macro 'SYS_INIT_NAMED'
  223 |         SYS_INIT_NAMED(init_fn, init_fn, level, prio)
      |         ^~~~~~~~~~~~~~
D:/ncs/v2.9.0/zephyr/drivers/disk/flashdisk.c:612:1: note: in expansion of macro 'SYS_INIT'
  612 | SYS_INIT(disk_flash_init, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
      | ^~~~~~~~
D:/ncs/v2.9.0/zephyr/include/zephyr/init.h:239:42: error: parameter '__init_disk_flash_init' is initialized
  239 |         static const Z_DECL_ALIGN(struct init_entry)                                      \
      |                                          ^~~~~~~~~~
D:/ncs/v2.9.0/zephyr/include/zephyr/toolchain/common.h:195:55: note: in definition of macro 'Z_DECL_ALIGN'
  195 | #define Z_DECL_ALIGN(type) __aligned(__alignof(type)) type
      |                                                       ^~~~
D:/ncs/v2.9.0/zephyr/include/zephyr/init.h:223:9: note: in expansion of macro 'SYS_INIT_NAMED'
  223 |         SYS_INIT_NAMED(init_fn, init_fn, level, prio)
      |         ^~~~~~~~~~~~~~
D:/ncs/v2.9.0/zephyr/drivers/disk/flashdisk.c:612:1: note: in expansion of macro 'SYS_INIT'
  612 | SYS_INIT(disk_flash_init, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
      | ^~~~~~~~
D:/ncs/v2.9.0/zephyr/include/zephyr/init.h:141:44: error: section attribute not allowed for '__init_disk_flash_init'
  141 | #define Z_INIT_ENTRY_NAME(init_id) _CONCAT(__init_, init_id)
      |                                            ^~~~~~~
D:/ncs/v2.9.0/zephyr/include/zephyr/toolchain/common.h:137:26: note: in definition of macro '_DO_CONCAT'
  137 | #define _DO_CONCAT(x, y) x ## y
      |                          ^
D:/ncs/v2.9.0/zephyr/include/zephyr/init.h:141:36: note: in expansion of macro '_CONCAT'
  141 | #define Z_INIT_ENTRY_NAME(init_id) _CONCAT(__init_, init_id)
      |                                    ^~~~~~~
D:/ncs/v2.9.0/zephyr/include/zephyr/init.h:241:17: note: in expansion of macro 'Z_INIT_ENTRY_NAME'
  241 |                 Z_INIT_ENTRY_NAME(name) = {.init_fn = {.sys = (init_fn_)},                \
      |                 ^~~~~~~~~~~~~~~~~
D:/ncs/v2.9.0/zephyr/include/zephyr/init.h:223:9: note: in expansion of macro 'SYS_INIT_NAMED'
  223 |         SYS_INIT_NAMED(init_fn, init_fn, level, prio)
      |         ^~~~~~~~~~~~~~
D:/ncs/v2.9.0/zephyr/drivers/disk/flashdisk.c:612:1: note: in expansion of macro 'SYS_INIT'
  612 | SYS_INIT(disk_flash_init, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
      | ^~~~~~~~
D:/ncs/v2.9.0/zephyr/include/zephyr/init.h:239:42: warning: 'used' attribute ignored [-Wattributes]
  239 |         static const Z_DECL_ALIGN(struct init_entry)                                      \
      |                                          ^~~~~~~~~~
D:/ncs/v2.9.0/zephyr/include/zephyr/toolchain/common.h:195:55: note: in definition of macro 'Z_DECL_ALIGN'
  195 | #define Z_DECL_ALIGN(type) __aligned(__alignof(type)) type
      |                                                       ^~~~
D:/ncs/v2.9.0/zephyr/include/zephyr/init.h:223:9: note: in expansion of macro 'SYS_INIT_NAMED'
  223 |         SYS_INIT_NAMED(init_fn, init_fn, level, prio)
      |         ^~~~~~~~~~~~~~
D:/ncs/v2.9.0/zephyr/drivers/disk/flashdisk.c:612:1: note: in expansion of macro 'SYS_INIT'
  612 | SYS_INIT(disk_flash_init, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
      | ^~~~~~~~
D:/ncs/v2.9.0/zephyr/include/zephyr/init.h:141:44: error: alignment may not be specified for '__init_disk_flash_init'
  141 | #define Z_INIT_ENTRY_NAME(init_id) _CONCAT(__init_, init_id)
      |                                            ^~~~~~~
D:/ncs/v2.9.0/zephyr/include/zephyr/toolchain/common.h:137:26: note: in definition of macro '_DO_CONCAT'
  137 | #define _DO_CONCAT(x, y) x ## y
      |                          ^
D:/ncs/v2.9.0/zephyr/include/zephyr/init.h:141:36: note: in expansion of macro '_CONCAT'
  141 | #define Z_INIT_ENTRY_NAME(init_id) _CONCAT(__init_, init_id)
      |                                    ^~~~~~~
D:/ncs/v2.9.0/zephyr/include/zephyr/init.h:241:17: note: in expansion of macro 'Z_INIT_ENTRY_NAME'
  241 |                 Z_INIT_ENTRY_NAME(name) = {.init_fn = {.sys = (init_fn_)},                \
      |                 ^~~~~~~~~~~~~~~~~
D:/ncs/v2.9.0/zephyr/include/zephyr/init.h:223:9: note: in expansion of macro 'SYS_INIT_NAMED'
  223 |         SYS_INIT_NAMED(init_fn, init_fn, level, prio)
      |         ^~~~~~~~~~~~~~
D:/ncs/v2.9.0/zephyr/drivers/disk/flashdisk.c:612:1: note: in expansion of macro 'SYS_INIT'
  612 | SYS_INIT(disk_flash_init, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
      | ^~~~~~~~
In file included from D:/ncs/v2.9.0/zephyr/include/zephyr/device.h:13,
                 from D:/ncs/v2.9.0/zephyr/include/zephyr/sw_isr_table.h:18,
                 from D:/ncs/v2.9.0/zephyr/include/zephyr/arch/arm/irq.h:19,
                 from D:/ncs/v2.9.0/zephyr/include/zephyr/arch/arm/arch.h:24,
                 from D:/ncs/v2.9.0/zephyr/include/zephyr/arch/cpu.h:19,
                 from D:/ncs/v2.9.0/zephyr/include/zephyr/kernel_includes.h:36,
                 from D:/ncs/v2.9.0/zephyr/include/zephyr/kernel.h:17,
                 from D:/ncs/v2.9.0/zephyr/include/zephyr/drivers/disk.h:30,
                 from D:/ncs/v2.9.0/zephyr/drivers/disk/flashdisk.c:12:
D:/ncs/v2.9.0/zephyr/drivers/disk/flashdisk.c:612:10: error: 'disk_flash_init' undeclared (first use in this function)
  612 | SYS_INIT(disk_flash_init, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
      |          ^~~~~~~~~~~~~~~
D:/ncs/v2.9.0/zephyr/include/zephyr/init.h:241:64: note: in definition of macro 'SYS_INIT_NAMED'
  241 |                 Z_INIT_ENTRY_NAME(name) = {.init_fn = {.sys = (init_fn_)},                \
      |                                                                ^~~~~~~~
D:/ncs/v2.9.0/zephyr/drivers/disk/flashdisk.c:612:1: note: in expansion of macro 'SYS_INIT'
  612 | SYS_INIT(disk_flash_init, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
      | ^~~~~~~~
D:/ncs/v2.9.0/zephyr/drivers/disk/flashdisk.c:533:1: error: type of 'DEFINE_FLASHDISKS_CACHE' defaults to 'int' [-Werror=implicit-int]
  533 | PM_FOREACH_AFFILIATED_TO_disk(DEFINE_FLASHDISKS_CACHE)
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
D:/ncs/v2.9.0/zephyr/include/zephyr/init.h:141:44: error: declaration for parameter '__init_disk_flash_init' but no such parameter
  141 | #define Z_INIT_ENTRY_NAME(init_id) _CONCAT(__init_, init_id)
      |                                            ^~~~~~~
D:/ncs/v2.9.0/zephyr/include/zephyr/toolchain/common.h:137:26: note: in definition of macro '_DO_CONCAT'
  137 | #define _DO_CONCAT(x, y) x ## y
      |                          ^
D:/ncs/v2.9.0/zephyr/include/zephyr/init.h:141:36: note: in expansion of macro '_CONCAT'
  141 | #define Z_INIT_ENTRY_NAME(init_id) _CONCAT(__init_, init_id)
      |                                    ^~~~~~~
D:/ncs/v2.9.0/zephyr/include/zephyr/init.h:241:17: note: in expansion of macro 'Z_INIT_ENTRY_NAME'
  241 |                 Z_INIT_ENTRY_NAME(name) = {.init_fn = {.sys = (init_fn_)},                \
      |                 ^~~~~~~~~~~~~~~~~
D:/ncs/v2.9.0/zephyr/include/zephyr/init.h:223:9: note: in expansion of macro 'SYS_INIT_NAMED'
  223 |         SYS_INIT_NAMED(init_fn, init_fn, level, prio)
      |         ^~~~~~~~~~~~~~
D:/ncs/v2.9.0/zephyr/drivers/disk/flashdisk.c:612:1: note: in expansion of macro 'SYS_INIT'
  612 | SYS_INIT(disk_flash_init, POST_KERNEL, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT);
      | ^~~~~~~~
D:/ncs/v2.9.0/zephyr/drivers/disk/flashdisk.c:572:30: error: declaration for parameter 'flash_disks' but no such parameter
  572 | static struct flashdisk_data flash_disks[] = {
      |                              ^~~~~~~~~~~
D:/ncs/v2.9.0/zephyr/drivers/disk/flashdisk.c:614: error: expected '{' at end of input
D:/ncs/v2.9.0/zephyr/drivers/disk/flashdisk.c:614: warning: control reaches end of non-void function [-Wreturn-type]
D:/ncs/v2.9.0/zephyr/drivers/disk/flashdisk.c: At top level:
D:/ncs/v2.9.0/zephyr/drivers/disk/flashdisk.c:464:37: warning: 'flash_disk_ops' defined but not used [-Wunused-const-variable=]
  464 | static const struct disk_operations flash_disk_ops = {
      |                                     ^~~~~~~~~~~~~~
cc1.exe: some warnings being treated as errors
[183/674] Building C object zephyr/subsys/bluetooth/host/CMakeFiles/subsys__bluetooth__host.dir/gatt.c.obj
ninja: build stopped: subcommand failed.
FATAL ERROR: command exited with status 1: 'C:\ncs\toolchains\b620d30767\opt\bin\cmake.EXE' --build 'd:\FYZKS\Wearable_Steth\Firmware_Codes\File_Systems\Pending\BLE_USB_MSC\build'

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

Related