Mass storage with littlefs init error with ncs2.9.1

We have our firmware developed with ncs2.7.0 and everything works as expected. However, with a recent effort of moving to ncs2.9.1, the same project can be built but during run time, I observe this error:

[00:00:00.040,435] <err> usb_msc: Storage init ERROR !!!! - Aborting USB init

Previously when we encounter the same issue, we solved it by adding pm_static.yml file and define our partition like this:

littlefs_storage:
  region: external_flash
  address: 0x120000
  size: 0x6e0000
  label: "lfs_storage"
  affiliation: disk
  extra_params: {
    disk_name: "NOR",
    disk_cache_size: 4096,
    disk_sector_size: 512,
    disk_read_only: 0
  }
And in our main code, we have this:
USBD_DEFINE_MSC_LUN(NOR, "Zephyr", "BORUS", "0.00");	// Define the USB MSC LUN
along with a kconfig in our prj.conf to define the disk name.

But apperantly, with ncs2.9.1, this no longer solves the problem. I have tried to locate the issue at this specific kconfig: 

CONFIG_DISK_DRIVER_FLASH=y. This one is successfully set to y with ncs2.7.0 but failed with ncs2.9.1. I can see from the Kconfig.flash in ncs2.9.1, this config now depends on 
DT_HAS_ZEPHYR_FLASH_DISK_ENABLED, which is not the case in ncs2.7.0, which then we we call disk access, we failed. Is there any suggestion on how to fix this?
  • OK. This is now solved by addting the following in the app.overlay

    &mx25r64 {
    	partitions {
    		compatible = "fixed-partitions";
    
    		#address-cells = <1>;
    		#size-cells = <1>;
    
    		littlefs_storage: partition@120000 {
    			label = "lfs_storage";
    			reg = <0x00120000 0x006E0000>; 
    		};
    	};
    };
    
    / {
    	msc_disk0: msc_disk0 {
    		compatible = "zephyr,flash-disk";
    		partition = <&littlefs_storage>;
    		disk-name = "NOR";
    		cache-size = <4096>; 
    	};
    };

    So previously, the partition manager can handle everything, but now, one needs to define the node specifically for flash disk in order to open disk access.

Related