Assistance Needed with Zephyr Project for File System Implementation

Dear Nordic DevZone Support Team,

I hope this message finds you well. I am reaching out for assistance with a project I am working on that involves implementing a file system using Zephyr.

My task involves creating a file system on an nRF52840 board using Zephyr. The goal is to create a text file (e.g., .txt) on the board, write data to this file, and then access this file from a PC via USB connection.

To achieve this, I have configured Zephyr to use LittleFS as the file system. I have carefully followed the documentation and configured the `prj.conf` file to enable LittleFS and specified the mount point as `/lfs`. Additionally, I have set up the LittleFS mount point to `/lfs` in my main application code.

However, when running the application, I encounter an error indicating that the LittleFS filesystem fails to mount properly during runtime. Specifically, I receive an error indicating that the file `/lfs/data.txt` cannot be opened (`FAIL: open /lfs/data.txt: -16`).

I have attached a zip file containing my project folder for your reference. Could you please review my configuration and code to help me identify the cause of this issue? Additionally, if there are any specific steps or configurations I may have overlooked, I would greatly appreciate your guidance in resolving this matter.

Thank you very much for your attention to this matter, and I look forward to your assistance.

Main.c : 

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <stdio.h>
#include <zephyr/kernel.h>
#include <zephyr/device.h>
#include <zephyr/fs/fs.h>
#include <zephyr/fs/littlefs.h>
#include <zephyr/usb/usb_device.h>
#include <zephyr/usb/usbd.h>
#include <zephyr/usb/class/usbd_msc.h>
/* LittleFS Code */
#define MAX_PATH_LEN 255
#define FILENAME "/lfs/data.txt"
/* LittleFS configuration */
FS_LITTLEFS_DECLARE_DEFAULT_CONFIG(storage);
static struct fs_mount_t lfs_storage_mnt = {
.type = FS_LITTLEFS,
.fs_data = &storage,
.storage_dev = (void *)FLASH_AREA_ID(littlefs_storage),
.mnt_point = "/lfs", // Point de montage du système de fichiers LittleFS
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

prj.conf : 

Fullscreen
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Optionally force the file system to be recreated
#CONFIG_APP_WIPE_STORAGE=y
# fs_dirent structures are big.
CONFIG_MAIN_STACK_SIZE=4096
# Let __ASSERT do its job
CONFIG_DEBUG=y
CONFIG_LOG=y
CONFIG_LOG_MODE_MINIMAL=y
CONFIG_FLASH=y
CONFIG_FLASH_MAP=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FILE_SYSTEM=y
CONFIG_FILE_SYSTEM_LITTLEFS=y
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

untitled_1.zip

Best regards.