Problem with first connection to external storage using littlefs and nRF Connect SDK 2.6.0

Let me point out that when compiling on nRF Connect SDK 2.5.0, everything works perfectly.

This always happens when the external memory is not initialized yet. I have several of my own prototype boards and the same thing happens on the new nrf52840dk board.

I configure littlefs like this:

in proj.conf:

CONFIG_FILE_SYSTEM=y
CONFIG_FILE_SYSTEM_LITTLEFS=y

In pm_static.yml

external_flash:
  address: 0x0
  end_address: 0x800000
  region: external_flash
  size: 0x800000
littlefs_storage:
  address: 0x0
  end_address: 0x800000
  region: external_flash
  size: 0x800000

I use mcuboot so in child_image/mcuboot.conf

CONFIG_PM_EXTERNAL_FLASH_MCUBOOT_SECONDARY=n

In code:

FS_LITTLEFS_DECLARE_DEFAULT_CONFIG (storage_data);

static const struct device *storage_dev = NULL;

static struct fs_mount_t mnt_storage =
{
	.type = FS_LITTLEFS,
	.fs_data = &storage_data,
	.storage_dev = (void *)FLASH_AREA_ID(LITTLEFS_STORAGE),
	.mnt_point = "/lfs",
};

void storage_init ()
{
    storage_dev = DEVICE_DT_GET (DT_NODELABEL (mx25r64));
    if (storage_dev != NULL)
    {
        printk ("[Storage] Device is found\n");

    	int res = fs_mount (&mnt_storage);
        if (res == 0)
        {
            printf("[Storage] Mounted\n");
            
            res = fs_unmount (&mnt_storage);
            if (res == 0)
            {
                printf("[Storage] Unmounted\n");
            }
            else
            {
                printf("[Storage] Error unmounting: %d\n", res);
            }
        }
        else
        {
            printf("[Storage] Error mounting: %d\n", res);
        }
    }
    else
    {
        printk ("[Storage] Device not found\n");
    }
}

When I compile on SDK 2.5.0, everything is always OK.
When I compile on SDK 2.6.0, I always get error -19 with the fs_mount function, i.e.: ENODEV 19 /* No such device */ (but only if the memory has never been initialized)

Interestingly, when I compile on SDK 2.5.0 and start the memory, it initializes itself correctly, then when I compile on SDK 2.6.0, everything will work correctly, because the memory has already been initialized on 2.5.0. So the problem is only with the first initialization when using the fs_mount function on SDK 2.6.0.

Has something changed in SDK 2.6.0 that requires adding some configuration to be able to initialize external storage from littlefs?

Or do I need to add some flag to the fs_mount_t.flags structure?

Related