This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

NCS: Using flash/file system with 802.15.4 using MPSL does not work

I am using NCS v1.7.1. I am developing a custom application on top of 802.15.4, which is based on the 802.15.4 PHY test application.

The problem I am facing can be demonstrated using the 802.15.4 PHY test application on the nrf52840DK as well, so I will do so here.

Starting point is the 802.15.4 PHY test application from ncs\v1.7.1\nrf\samples\peripheral\802154_phy_test\.

I added the following options to my prj.conf in order to add support for both flash and littlefs filesystem:

# Flash and filesystem support
CONFIG_FLASH=y
CONFIG_FLASH_MAP=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FILE_SYSTEM=y
CONFIG_FILE_SYSTEM_LITTLEFS=y
# fs_dirent structures are big.
CONFIG_MAIN_STACK_SIZE=2048

Additionally I added an overlay file at boards\nrf52840dk_nrf52840.overlay in order to provide the necessary partition:

/ {
	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>;
		};
	};
};

The resulting application compiles fine and includes both flash and littlefs support.

However, when this application is run the following diagnostic output is shown:

[00:00:00.000,213] <inf> phy_tt: RF setup started
[00:00:00.000,854] <inf> littlefs: littlefs partition at /lfs1
[00:00:00.000,854] <inf> littlefs: LittleFS version 2.2, disk version 2.0
[00:00:00.001,098] <inf> littlefs: FS at NRF_FLASH_DRV_NAME:0xf8000 is 8 0x1000-byte blocks with 512 cycle
[00:00:00.001,098] <inf> littlefs: sizes: rd 16 ; pr 16 ; ca 64 ; la 32
[00:00:00.001,251] <err> littlefs: WEST_TOPDIR/modules/fs/littlefs/lfs.c:997: Corrupted dir pair at {0x0, 0x1}
[00:00:00.001,251] <wrn> littlefs: can't mount (LFS -84); formatting
[00:00:00.001,342] <err> flash_sync_mpsl: mpsl_timeslot_session_open failed: -12
[00:00:00.001,342] <err> littlefs: format failed (LFS -12)
[00:00:00.001,373] <err> fs: fs mount error (-12)
[00:00:00.001,403] <err> littlefs: Automount /lfs1 failed: -12

The partition is correctly recognized, but is not formatted yet of course.

However, in the course of auto-formatting the problem as shown above happens when mpsl_timeslot_session_open() is called inside nrf_flash_sync_exe().

The call stack looks as follows:

According to the documentation error -12 is NRF_ENOMEM and means "All sessions are already open."

I made sure that mpsl_init() is called and that this is really the first call to mpsl_timeslot_session_open().

Due to the fact that the MPSL is not available in source code it is impossible for me to further debug this problem at this point.

Because in this application the MPSL-aware flash functions are used I am wondering what is going on. Can somebody please explain how to add flash / filesystem support to an 802.15.4 application using MPSL?

Parents
  • Hi

    Unfortunately, the "automount" feature can't be used along with the partition manager in the current (v1.7.1) NCS version. This is set to be fixed as part of NCS v1.8.0. Unfortunately I don't have a release date on when that will be available, but you can see the pull request for the automount fix here in the upstream Zephyr project.

    Best regards,

    Simon

Reply
  • Hi

    Unfortunately, the "automount" feature can't be used along with the partition manager in the current (v1.7.1) NCS version. This is set to be fixed as part of NCS v1.8.0. Unfortunately I don't have a release date on when that will be available, but you can see the pull request for the automount fix here in the upstream Zephyr project.

    Best regards,

    Simon

Children
  • Simon, thank you very much for your answer.

    Unfortunately, the "automount" feature can't be used along with the partition manager in the current (v1.7.1) NCS version.

    Thanks for pointing me in the right direction.

    Actually I am only interested in littlefs itself, not in the "automount" feature in particular. I did not pay attention that is was included  in the overlay file at all.

    So I removed the "automout" feature and now the application starts up as expected.

    I carry out the mount operation manually in my code like this:

    #define PARTITION_NODE DT_NODELABEL(lfs1)
    FS_FSTAB_DECLARE_ENTRY(PARTITION_NODE);
    
    [...]
      struct fs_mount_t *mp = &FS_FSTAB_ENTRY(PARTITION_NODE);
    
      int rc = fs_mount(mp);
      if (rc < 0) {
        printk("FAIL: mount id %u at %s: %d\n",
            (unsigned int)mp->storage_dev, mp->mnt_point,
            rc);
        return -1;
      }
      printk("%s mount: %d\n", mp->mnt_point, rc);
    [...]
    

    This now works as expected as well and I can do file operations.

    So as you pointed out there seems to be a problem with the "automount" feature, but not with flash / littlefs support as well. As long as "automount" is disabled and the mount operation is done manually, everything works fine.

Related