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.

Parents
  • 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,

    Did you run west update after updating the revision of the nRF Connect SDK in your repository?

    Using the application as the manifest repository is the recommended method for out-of-tree drivers, but it is possible to install nRF Connect SDK with Toolchain Manager and create an oot driver without west manifest.

    As an example, I have made an oot driver without west manifest. I copied the BME680 sensor driver and simply renamed it to BME681. To use it in an application, I added it with ZEPHYR_EXTRA_MODULES in the application's CMakeLists.txt, for example:

    set(ZEPHYR_EXTRA_MODULES ${CMAKE_CURRENT_SOURCE_DIR}/../out_of_tree_driver_bme681)

    This code is not thoroughly tested or qualified and should be considered provided “as-is”. Please test it with your application and let me know if you find any issues.

    out_of_tree_driver_bme681.zip

    Best regards,
    Marte

  • Yes, I ran the west update as well as pull the fresh SDK but got the same error.

    I successfully tested a sensor using an out-of-tree driver by following the sample you provided, and its working fine.

    Could you please explain the pros and cons of developing an application with oot driver using manifest and without manifest repo?

  • Hi,

    The advantage of using a manifest repo is that you can easily configure the version of nRF Connect SDK, and other repositories, associated with your driver directly in the west.yml manifest file. So it can be more organized in that regard. It is perfectly fine to not use a manifest repo as well, but then you need to make sure that the installed SDK is the correct version associated with your driver.

    Best regards,
    Marte

  • Thank you for sharing valuable knowledge.

    When I am running combined project then getting following error without manifest:

    Despite increasing the stack size, heap size and thread stack size, the error persists.

    Please help me.  

  • Hi,

    Are you able to figure out which thread it is failing in? You can try to set CONFIG_THREAD_NAME=y in prj.conf to see if you get the name of the thread in the assert, or you can debug the application and enable breakpoints on Zephyr fatal errors to see which thread is running when it asserts.

    Best regards,
    Marte

Reply Children
No Data
Related