Use FSRW on flash?
Rayman
Posts: 14,646
I'm thinking about trying to use FSRW on the flash chip on the P2 eval board...
I have no idea if it will actually work though.
I think Chip suggested that we can use addresses above 1 kB freely.
So, I'm going to see about copying the contents of a newly formatted uSD card onto flash and then adapting FSRW to work with it...
Anybody know if this will or won't work?
I have no idea if it will actually work though.
I think Chip suggested that we can use addresses above 1 kB freely.
So, I'm going to see about copying the contents of a newly formatted uSD card onto flash and then adapting FSRW to work with it...
Anybody know if this will or won't work?
Comments
A better alternative would be littlefs, which Tubular also suggested a few months ago. It's is a simple filesystem designed for constrained systems using flash memory. It does wear leveling, and it never causes filesystem corruption if power is lost at the wrong time.
YES. That would be extremely useful.
Think I can use info from this to format flash in a way that makes sense...
I would use it in a heartbeat!
The flash is 128 Mbit or 16,777,216 bytes.
This gives 32,768 sectors of the standard 512 bytes each.
But, we need to reserve 1 MB (or so) for boot from flash data. That is 2,000 sectors.
We are left with 30,768 sectors.
Looks like FAT16 with 4 sectors per cluster makes most sense. Then, we have 7,692 clusters.
At least, my first test works... Here's the output:
How much memory does it use?
But, there is an issue that I may or may not have resolved...
Turns out you can't just add to the file directory without erasing it first.
And, the smallest amount you can erase is a 4kB block.
What seems like it might work is only doing this for directory. It seems like the FAT chain and the new data might be OK.
Right now, I only erase for the first sector in the FAT directory, #613. This may work for some small number of files.
But, will eventually have to make for entire FAT directory...
@Cluso99 FSRW is tiny...
Might start new thread with code and instructions...
Was able to flash this bitmap file and then show it using FRSW.
Speed is decent, but obviously not assembly speed.
From what I understand, you are using C to access the fsrw pasm driver.
If so, what is the space used for a minimal implementation in KB please?
We all know how bloated C is with its' minimum requirements. I want to know how bloated this minimum requirement is please. If it's only a few KB then great, but if it's 10's-100's KB then it's a no-go for me.
I can't envision any scenario where I'd have to erase/write more than 100k times...
You could easily hit that limit if you were to continually log data to the flash chip for long periods of time. If you used an appropriate filesystem for the application, all the sectors would wear out at around the same time, but if you use FAT, you'd destroy the FAT table long before any of the data sectors wore out, seriously shortening the usable lifetime of the chip.
Yes, of course you could avoid this by pre-allocating each file when you create it, but that defeats the whole purpose of having a file system to begin with - that of automatically dealing with allocations and hierarchy for you - effectively building your own filesystem on top of the underlying one. Why bother with a filesystem at all if all you need is a circular buffer?
SDcards and SSDs have controller chips that manage wear leveling for you. The bare flash chip isn't going to do that, so you are going to wear out the blocks with the FAT table and directory way before any other blocks.
But if I think about it again, it's not so bad:
The FAT only changes when a new cluster is allocated, which is not so often the case.
Most sensitive is the directory, but neither name nor time will change with FSRW. Actually only the filesize has to be rewritten. Maybe you can save the size at the beginning of the file instead of in the directory.
Of course you should not use this for logging, but if you just want to save modified, or newly created images or text, I don't see a big problem.
If you save a file 10 times per day, you can do this for 27 years to reach 100'000 write operations.
Until then we already work with the P3
Andy
Mike
Don’t do that and should be fine.
If we have all 3 SD/Flash/HyperRAM interfaces to some common upper layer tracking each mounted or active volume that could be quite good and versatile from a software application standpoint.
don’t know if it makes any sense, but should work
Yes for reads. For writes it seems like it will be a dog from what erase speeds numbers I found.
The HyperRAM reads and HyperFlash reads will have the same driver interface, just a different "bank" field of an address which would represent the device.
Considering that LittleFS tries to avoid needing to do erases by only writing partial blocks until the block is full (at least with metadata blocks), I imagine that the slow erase speeds of HyperFlash won't be so bad if you're modifying lots of small files.