Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Questions regarding LittleFS page program behavior #1062

Open
bal-stan opened this issue Jan 9, 2025 · 0 comments
Open

Questions regarding LittleFS page program behavior #1062

bal-stan opened this issue Jan 9, 2025 · 0 comments

Comments

@bal-stan
Copy link

bal-stan commented Jan 9, 2025

Hi,

I am trying to answer a few questions I have regarding LittleFS page program behaviour. I would appreciate it if someone can correct me or confirm my understanding.

I am running LittleFS on a bunch of MT29F16G16ADACA flash chips. In the datasheet (table 33, page 109) it states:

Parameter Symbol Typ Max Unit Notes
Number of partial-page programs NOP 4 cycles 1

My understanding is that each page has a program limit of 4, after which the block it is in needs to be erased before the page can be programmed (reliably) again.

I've looked at the LittleFS docs but, I didn't see any documentation stating whether LittleFS will ever program the same page more than once, without first erasing the block it is in.

Arguably this is probably more trouble than it is worth as it would need to first read the page (assuming it doesn't have a copy in RAM), check if it can make the necessary changes by just flipping 1s to 0s, and if so write the changes, otherwise look for a new page.

According to my testing:

  1. For inlined files:

LittleFS will program consecutive pages of the same block during each file write. When all pages in the block are exhausted, it will find a new unused/free block, erase it, write the file to the first page of the new block and mark the old block as unused/free.

  1. For normal files:

It will program to a new block during each file write. Curiously, instead of programming consecutive blocks (like it programs consecutive pages when dealing with inlined files), it seems to split the block count in half and alternate to which half it programs to. For example, for a 32 block device, it will program to block 0, then 16, then 1, then 17, etc.

Questions:

  1. Am I correct in assuming that LittleFS will never program the same page more than once without first erasing the block it is in?
  2. In the case of an N-page wide block. If I store an inlined file on a single page, and then proceed to rewrite its contents N-1 times, does that mean that the inlined file now effectively occupies N pages, since all of the pages of the block have been written to?
  3. If 2 is true, how can I prevent this? Run garbage collection? Disable inlined files? Rewrite the file N+1 times, so it gets moved to a new block?
  4. Can multiple files (inlined or not) share the same block? What about the same page? If yes, does this change the answers to Q2 and Q3?

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant