littlefs-project / littlefs

A little fail-safe filesystem designed for microcontrollers
BSD 3-Clause "New" or "Revised" License
5.25k stars 803 forks source link

Getting LFS_ERR_NOSPC way before memory is full #1011

Closed pedromarinho94 closed 2 months ago

pedromarinho94 commented 4 months ago

I am having some issues with my littlefs (v2.9.3) implementation using a W25Q128 via QSPI.

I am getting the following error way before the flash memory is full. (approx 98% free space left to write) I can successfully write aprox. 2000 bytes before this happens.

1722291908 [ERROR] lfs.c:689: ./fw-fdk/3rd-party/littlefs/lfs.c:689:error: No more free space 0x3

I have exhausted all possibilities. I have written a similar application with littlefs-python that replicates what I'm doing and it writes 98%99% of all the possible bytes.

What could it be?

geky commented 2 months ago

Hi @pedromarinho94, thanks for creating an issue, sorry about the late response.

That is a strange, the presence of the error log suggests littlefs truly can't find a free block.

Are there any other logging statements with LFS_DEBUG/WARN? do you have asserts enabled? It's possible writes are failing and after trying every block littlefs gives up.

What is your configuration?

pedromarinho94 commented 2 months ago

@geky I'm sorry. We had a bug in our SPI driver in which we were always deleting block 0. It's fixed now.

geky commented 2 months ago

Ah, glad to hear you found the issue.