littlefs-project / littlefs

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

lfs_error .. No more free space #533

Open baranovus opened 3 years ago

baranovus commented 3 years ago

Hello. Sorry for asking the question, which might been already answered. I have an error message lfs_error .. No more free space. I saw in discussions the following: " *I found the solution in your README mentioning LFS requires at least 6bd.erase_size() of memory allocation.." Could somebody explain what is it? Does it mean that I have to set .block_size* equal to 6 flash erasable block size values? For example, if my flash allows erasing block of 4096 bytes, should I set block_size = 6 X 4096? Or does it mean that I have to have enough heap for 64096 = 24576 bytes?

geky commented 3 years ago

Ah, I'm not sure the original source, but "memory allocation" should really be "storage". LittleFS requires ~6 blocks of storage to work with. There's not really a lower bound on memory, though a large cache_size = less bus transactions = faster.

But 6 blocks of storage is the bare minimum. If you have multiple or large files you may need more storage. How much data are you trying to write?

baranovus commented 3 years ago

Hello and thanks! I need to keep about 10 files. Most of them are about 100 bytes and a couple of them may be about 100 K. I think I am confused with the word "block". When we say "block" do we mean the size of erasable block of the flash memory (4096 Bytes in my case)? If yes, do I need ~24 K of storage and that will be the size of my cache? Now I have:

define CACHE_SIZE 256

define LOOK_AHEAD_SIZE 64

define READ_SIZE CACHE_SIZE

define PROG_SIZE CACHE_SIZE

define ERASABLE_BLOCK_SIZE 4096

.read_size = READ_SIZE, .prog_size = PROG_SIZE, .block_size = ERASABLE_BLOCK_SIZE,

Where am I wrong?

jimarcher commented 3 years ago

@baranovus any luck with this?

baranovus commented 3 years ago

Hello Jim. After some modifications which seem to be unconnected with the problem the error disappeared, but of course I am not satisfied because I don't understand what had been done wrong.

jimarcher commented 3 years ago

Okay thanks very much for your reply.