apache / apache/nuttx

[BUG] Issues on NXFFS

Open
#18,803 2 comments 0 reactions 0 assignees View on GitHub
Arch: risc-v Area: File System OS: Linux Type: Bug
Dominant language
C
Stars
4k
Forks
1.7k
Avg merge
1d 17h
Merged PRs (30d)
237

Description

### Description / Steps to reproduce the issue

Hello all!

I would like to report some issues with the NuttX wear-leveling FLASH file system (NXFFS). I'll try and be very brief on the description and how to replicate.

The `fstest` program fails on the first iteration after creating and deleting a file from the mount point.

On the Espressif CI, we test SPI Flash in all devices available on NuttX using four different file systems: `smartfs`, `littlefs`, `spiffs` and `nxffs`.
The test only fails for `nxffs` and it happens on all devices.

On this example, I cleared the flash and uploaded the test binary.
The test creates a file on `/data`, then deletes it and runs `fstest`. You can see that it fails to open files for writing.

```
---- boot ----
nsh> mount
/data type nxffs
/proc type procfs
nsh> echo "Espressif" > /data/esp.txt
nsh> cat /data/esp.txt
Espressif
nsh> rm /data/esp.txt
nsh> fstest -n 2 -o 10 -m /data

=== FILLING 1 =============================
ERROR: Failed to open file for writing: 22
File name: /data/v8xKNJW8E7fgewGMhS0kQkI
File size: 1655
Filled file system
Number of files: 6
Number deleted: 0
Directory:
1. Type[8]: File Name: PRMIRHz9ZwgHgakAejh
2. Type[8]: File Name: jbLT
3. Type[8]: File Name: WwWHiuUqCk4tOjT9NEtR
4. Type[8]: File Name: 1znKEEWzPcGJyrfEpylQLGn8bT
5. Type[8]: File Name: 9CBmwAHkVZqmYCJFs0Y
6. Type[8]: File Name: E0SSae6eriB1tdTW
Total file size: 20783
ERROR: Bad CRC: -2100950977 vs 1413162872
File name: /data/1znKEEWzPcGJyrfEpylQLGn8bT
File size: 2111
ERROR: Failed to read a file: 3
File name: /data/1znKEEWzPcGJyrfEpylQLGn8bT
File size: 2111
ERROR: Failed to verify files
Number of files: 6
Number deleted: 0
nsh> echo $?
1
nsh>
```

To reproduce this binary on ESP32-S3 (its similar for other devices):
- ./tools/configure.sh esp32s3-devkit:spiflash
- Enable NXFFS on board bringup and FSTEST:
```
CONFIG_ARCH_BOARD_COMMON=y
CONFIG_DEBUG_FEATURES=y
CONFIG_DEBUG_ASSERTIONS=y
CONFIG_DEBUG_ASSERTIONS_EXPRESSION=y
CONFIG_DEBUG_SYMBOLS=y
CONFIG_ESP32S3_MERGE_BINS=y
CONFIG_ESP32S3_SPIFLASH_NXFFS=y
CONFIG_ESP32S3_SPIFLASH_SMARTFS=n
CONFIG_ESP32S3_SPI_FLASH_DONT_USE_ROM_CODE=y
CONFIG_NDEBUG=n
CONFIG_TESTING_FSTEST=y
CONFIG_TESTING_FSTEST_STACKSIZE=8192
```

I would appreciate if anyone could assist on debugging this issue, if possible even on a different board.

Thanks all,
Filipe

### On which OS does this issue occur?

[OS: Linux]

### What is the version of your OS?

Linux Mint 22

### NuttX Version

master

### Issue Architecture

[Arch: risc-v]

### Issue Area

[Area: File System]

### Host information

_No response_

### Verification

- [x] I have verified before submitting the report.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.