This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

Settings via littlefs on internal flash

Hi,

I'm currently trying to use littlefs as the storage backend for the settings subsys and the internal flash for the actual memory. LittleFS is working in general but if failed so far to use it for storing settings.

Upon settings initialization it complains about not finding the mount point and according to the logs it is right about this. When I try to crate a fstab entry in order to enable automount like this:

/ {
    fstab {
        compatible = "zephyr,fstab";
        lfs1: lfs1 {
            compatible = "zephyr,fstab,littlefs";
            mount-point = "/lfs1";
            partition = <&storage_partition>;
            automount;
            read-size = <16>;
            prog-size = <16>;
            cache-size = <64>;
            lookahead-size = <32>;
            block-cycles = <512>;
            no-format;
        };
    };
};

The logging looks like this:

[00:00:00.248,260] fs.fs_register: fs register 1: 0

[00:00:00.255,889] littlefs: littlefs partition at /lfs1

[00:00:00.263,977] littlefs: LittleFS version 2.2, disk version 2.0

[00:00:00.273,010] littlefs.littlefs_mount: FS area 0 at 0x0 for 49152 bytes

[00:00:00.282,836] littlefs: FS at NRF_FLASH_DRV_NAME:0x0 is 12 0x1000-byte blocks with 512 cycle

[00:00:00.294,464] littlefs: sizes: rd 16 ; pr 16 ; ca 64 ; la 32

[00:00:00.303,405] littlefs: /lfs1 mounted

[00:00:00.310,272] fs: fs mount error (-5)

[00:00:00.317,413] littlefs: Automount /lfs1 failed: -5

Where flash offset and and number of blocks are clearly wrong. Do I do something obviously wrong here?

Regards

Caspar

Parents Reply Children
  • No difference, unfortunately.

    It seems that parts of the node are read correctly. The mount point for example is always correct. The littlefs example also works but that manages files manually. The problem seems to only exist with the automount feature.

  • Hi,

     

    caspar.friedrich said:

    No difference, unfortunately.

    It seems that parts of the node are read correctly. The mount point for example is always correct. The littlefs example also works but that manages files manually. The problem seems to only exist with the automount feature.

    I also mount in the application, and then I see this log:

    *** Booting Zephyr OS build v2.4.99-ncs1  ***
    Area 2 at 0xfa000 on NRF_FLASH_DRV_NAME for 24576 bytes
    /lfs mount: 0
    /lfs: bsize = 16 ; frsize = 4096 ; blocks = 6 ; bfree = 4
    /lfs/boot_count stat: 0
            fn 'boot_count' siz 4
    /lfs/boot_count read count 5: 4
    /lfs/boot_count seek start: 0
    /lfs/boot_count write new boot count 6: 4
    /lfs/boot_count close: 0
    /lfs opendir: 0
      F 4 boot_count
    End of files
    /lfs unmount: 0
    [00:00:00.000,030] <inf> littlefs: littlefs partition at /lfs1
    [00:00:00.000,061] <inf> littlefs: LittleFS version 2.2, disk version 2.0
    [00:00:00.000,091] <inf> littlefs: FS at NRF_FLASH_DRV_NAME:0x0 is 12 0x1000-byte blocks with 512 cycle
    [00:00:00.000,091] <inf> littlefs: sizes: rd 16 ; pr 16 ; ca 64 ; la 32
    [00:00:00.000,152] <inf> littlefs: /lfs1 mounted
    [00:00:00.000,152] <err> fs: fs mount error (-5)
    [00:00:00.000,183] <err> littlefs: Automount /lfs1 failed: -5
    
    [00:00:00.009,216] <inf> littlefs: LittleFS version 2.2, disk version 2.0
    [00:00:00.009,399] <inf> littlefs: FS at NRF_FLASH_DRV_NAME:0xfa000 is 6 0x1000-byte blocks with 512 cycle
    [00:00:00.009,399] <inf> littlefs: sizes: rd 16 ; pr 16 ; ca 64 ; la 32
    [00:00:00.010,101] <inf> littlefs: /lfs mounted
    [00:00:00.039,306] <inf> littlefs: /lfs unmounted
    
     

    The automount seems to fail on pre-boot (logs seem to be printed out-of-order based on debug behavior).

    This is tested with sample ../ncs/zephyr/samples/subsys/fs/littlefs/, with CONFIG_MPU_ALLOW_FLASH_WRITE=y as the only change in config/sources.

    overlay that I'm using:

    / {
        fstab {
            compatible = "zephyr,fstab";
            lfs: lfs {
                compatible = "zephyr,fstab,littlefs";
                mount-point = "/lfs1";
                partition = <&storage_partition>;
                /* Uncomment to show failure */
                /*automount;*/
                read-size = <16>;
                prog-size = <16>;
                cache-size = <64>;
                lookahead-size = <32>;
                block-cycles = <512>;
                label = "storage";
                no-format;
            };
        };
    };

     

    I also tested on master, which didn't change the behavior. I'll report this internally.

     

    Kind regards,

    Håkon

  • Thank you and sorry for my delayed answer! Is there any progress so far?

  • Hi,

      

    caspar.friedrich said:
    Thank you and sorry for my delayed answer! Is there any progress so far?

    Unfortunately, we have not found the root-cause of why this happens at this time. Is it possible to work around the behavior in your application by mounting in main()-context, or is the mount required to happen prior to main() for your application to run as expected?

     

    Kind regards,

    Håkon

Related