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
# fs_dirent structures are big.

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>;
			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?