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.

  • Hi,

    I am not able to reproduce the error by adding the configurations you mention in smp_svr sample. Can you upload a project where this can easily be reproduced?

    Best regards,
    Marte

  • Hi,

    Did you try this with ncs v2.4.0.

    I can not upload any project due company policy restriction, smp_svr sample's complete configuration is given below:

    prj.conf: 

    # Enable MCUmgr and dependencies.
    CONFIG_NET_BUF=y
    CONFIG_ZCBOR=y
    CONFIG_CRC=y
    CONFIG_MCUMGR=y
    CONFIG_STREAM_FLASH=y
    CONFIG_FLASH_MAP=y
    
    # Some command handlers require a large stack.
    CONFIG_SYSTEM_WORKQUEUE_STACK_SIZE=2304
    CONFIG_MAIN_STACK_SIZE=8192
    
    # Ensure an MCUboot-compatible binary is generated.
    CONFIG_BOOTLOADER_MCUBOOT=y
    
    # Enable flash operations.
    CONFIG_FLASH=y
    
    # Required by the `taskstat` command.
    CONFIG_THREAD_MONITOR=y
    
    # Support for taskstat command
    CONFIG_MCUMGR_GRP_OS_TASKSTAT=y
    
    # Enable statistics and statistic names.
    CONFIG_STATS=y
    CONFIG_STATS_NAMES=y
    
    # Enable most core commands.
    CONFIG_FLASH=y
    CONFIG_IMG_MANAGER=y
    CONFIG_MCUMGR_GRP_IMG=y
    CONFIG_MCUMGR_GRP_OS=y
    CONFIG_MCUMGR_GRP_STAT=y
    
    # Enable logging
    CONFIG_LOG=y
    CONFIG_MCUBOOT_UTIL_LOG_LEVEL_WRN=y
    
    # Disable debug logging
    CONFIG_LOG_MAX_LEVEL=3
    
    CONFIG_MCUBOOT_IMAGE_VERSION="1.1.1"
    
    #qspi
    CONFIG_NORDIC_QSPI_NOR=y
    CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
    CONFIG_NORDIC_QSPI_NOR_STACK_WRITE_BUFFER_SIZE=16
    CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y
    
    #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

    nrf52840dk_nrf52840.overlay:

    /delete-node/ &boot_partition;
    /delete-node/ &slot0_partition;
    /delete-node/ &slot1_partition;
    
    
    &flash0 {
    	partitions {
    		boot_partition: partition@0 {
    			label = "mcuboot";
    			reg = <0x000000000 0x00010000>;
    		};
    		slot0_partition: partition@10000 {
    			label = "image-0";
    			reg = <0x000010000 0x0000e8000>;
    		};
    	};
    };
    
    &mx25r64 {
    	partitions {
    		compatible = "fixed-partitions";
    		#address-cells = <1>;
    		#size-cells = <1>;
    
    		slot1_partition: partition@0 {
    			label = "image-1";
    			reg = <0x000000000 0x0000e8000>;
    		};
    		external_flash: partition@e8000 {
    			label = "external flash";
    			reg = <0x0000e8000 0x000718000>;
    		};
    	};
    };
    
    / {
    	chosen {
    		nordic,pm-ext-flash = &mx25r64;
    	};
    	msc_disk0 {
    		compatible = "zephyr,flash-disk";
    		partition = <&external_flash>;
    		disk-name = "NAND";
    		cache-size = <4096>;
    	};
    };

    child_image/mcuboot/prj.conf:

    CONFIG_MAIN_STACK_SIZE=10240
    
    CONFIG_SIZE_OPTIMIZATIONS=y
    CONFIG_NORDIC_QSPI_NOR=y
    CONFIG_NORDIC_QSPI_NOR_FLASH_LAYOUT_PAGE_SIZE=4096
    CONFIG_NORDIC_QSPI_NOR_STACK_WRITE_BUFFER_SIZE=16
    
    # Enable flash operations
    CONFIG_FLASH=y
    
    CONFIG_MULTITHREADING=y
    CONFIG_BOOT_MAX_IMG_SECTORS=256
    
    CONFIG_MCUBOOT_INDICATION_LED=y
    
    CONFIG_PM_PARTITION_SIZE_MCUBOOT=0x10000
    
    CONFIG_CONSOLE=y
    CONFIG_UART_CONSOLE=y
    
    CONFIG_LOG=y
    CONFIG_LOG_MODE_IMMEDIATE=y
    CONFIG_LOG_BACKEND_UART=y
    CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=y 
    CONFIG_MCUBOOT_SERIAL_DIRECT_IMAGE_UPLOAD=y
    
    CONFIG_FW_INFO_FIRMWARE_VERSION=1
    

    child_image/mcuboot/boards/nrf52840dk_nrf52840.overlay:

    / {
    	chosen {
    		nordic,pm-ext-flash = &mx25r64;
    	};
    };
    

  • Hi,

    I got some warnings about the external_flash partition, but still not the errors you are seeing. To verify, it is the SMP server sample located in zephyr/samples/subsys/mgmt/mcumgr/smp_svr you are testing? Have you made any other changes to the sample or the SDK itself?

    Best regards,
    Marte

  • Yes, sample path is correct. Let me install the NCS by Toolchain manager and check with it.

    Actually I need to develop out of tree driver, so I installed the NCS using the below link:

    https://github.com/nrfconnect/ncs-example-application

  • Hi,

    Code build successfully When I installed the SDK by nRF Connect desktop toolchain manager application.

    But I need to develop project for OOT driver.

    Is there any way I can develop my project with OOT tree driver using NCS(Installed by toolchain manager).

Related