Serial Flash filesystem size

Status
Not open for further replies.

linuxgeek

Well-known member
I assume the filesystem takes a little bit of space on the SPI flash module. Does anyone know what amount of space that is?

For a 128Mbit module, I'm trying to figure out how much I can allocate for data.
 
Thanks! And yes I meant Paul's SerialFlash.

On a side note, I notice that the # of bytes allocated is different than the amount requested, and that seems like it's because of the alignment boundaries. But (for example) if I request 1000 bytes, but the filesize then reports 1024, does that mean that a 1024 bytes can be written/read from file (which is more than the 1000 requested or is it limited to 1000)?
 
if alignment is 0 in the create(), the file starting address is rounded up to a page boundary (256), and it saves the requested file size, and won't let you write more than that (1000 in your case) -- at least that's how i read the code.

? I'm not sure what's reporting 1024 to you. if i create a 51-byte file, readdir() reports 51 bytes.
if you create an erasable file, then the starting address and length are rounded up to the blocksize() of the flash chip, and you would be able to write up to the reported file size.
 
Last edited:
if alignment is 0 in the create(), the file starting address is rounded up to a page boundary (256), but it saves the requested file size, and won't let you write more than that (1000 in your case) -- at least that's how i read the code.

? i need to study code a bit more, not sure why 1024 is being reported for size

Sorry, 1024 was just an example. I requested 12000000, but I got something greater than that when reading the filesize. My question really is what is the best way to read all the data from a file? Let's say I created a file long ago (I don't know what the filesize is anymore), and now I want to output the data over serial. What would be the best way to read out all the data?
Is there a way to request the original filesize that was requested when the file was created? Since it stores that size somewhere, is there a way to retrieve it?

This is not a show-stopper for me, I think I know enough to get by, but just wondering what makes the most sense.
 
As I read the code, i don't think you can know the original file size for erasable files. (unless you wrote the length in the file :) ) I think the blocks are erased to 0xff so if your data is not binary, you might detect "end of file"
 
Good point, I could put the length in the file. I already keep track of virtual files within the file by keeping start bytes in another file. I am storing binary data.
 
if alignment is 0 in the create(), the file starting address is rounded up to a page boundary (256), and it saves the requested file size, and won't let you write more than that (1000 in your case) -- at least that's how i read the code.

? I'm not sure what's reporting 1024 to you. if i create a 51-byte file, readdir() reports 51 bytes.
if you create an erasable file, then the starting address and length are rounded up to the blocksize() of the flash chip, and you would be able to write up to the reported file size.

Oh, just read your edit. That would work, I do create an eraseable (altho either works for me) file so I can use the filesize as the limit for writing/reading. That simplifies things.
 
Status
Not open for further replies.
Back
Top