Snippet - TinyFileSystem : Extension Class for the S25FL064K Flash Memory

TinyFileSystem : Extension Class for the S25FL064K Flash Memory

This class implements the driver for the S25FL064K Flash, that is at least provided on the Mountaineer Ethernet board.

This must be added to the existing project from Taylorza : TinyFileSystem.

1 Like

@ LouisCpro,

I am glad to see someone is using the code, I hope your experience with it has been good. I suspect that you might have uploaded the wrong code, the code you have posted is the same code that is currently in TinyFileSystem.

@ Valkyrie-MT noted that the driver I have is named MX25L3206 while the actual Flash module from GHI uses the Spansion FL032PIF. Fortunately It turns out that these two devices have the same SPI interface and therefore the same driver works for both. You can get more detail on @ Valkyrie-MT’s findings at the following link
http://www.tinyclr.com/forum/topic?id=8514&page=4#msg91281

@ taylorza -

Excuse for the delay. In fact the structure is slightly the same, but in fact the intrsuctions (const) values are different for one to another flash, and I had to workaround with some changes in this part of the code…

@ LouisCpro-
Can you reupload the S25FL064KBlockDriver code?
the file in there is actually MX25l3206BlockDriver code.
Thanks

1 Like

Hi I am using a Spansion S25FL032P chip on a G400D custom board. I have try the code and with slight modification it seems to work properly. However I have some doubts about how to use it in a correct manner.

I succeed to write and read bytes. But let’s consider I have a thousand of parameters to store in the flash module. Let’s say that all are float. How to perform a good memory mapping? The programming is done by forcing bits from 1 to 0. But to set a bit to 1 the only solution is to erase and the lowest granularity of erase instruction set is 4KB! So if data are contiguous I need to load first 4Kb of data compare with the data I want to store and if only one bit need to be set, I need to erase the 4kB sector. Is it correct?

The weird thing is that I did not see any comparison of sector nor page when programming in the TinyFileSystem. Am I wrong?

@ leforban - You just write to the file like you do with a normal file system, the file system takes care of the details. Most importantly the file system takes care of wear leveling, which will be a problem with what you are suggesting.

As you know flash memory has a limit to the number of write cycles that it can endure, that limit is per sector so if you write too often to the same sector it might wear out before the rest of the flash memory and then you have to either deal with portions of the flash that do not work or just discard the entire flash module. So what the file system does is write new changes to new blocks and link them into the file as if it was continuous block of data in the file. These discarded blocks are marked as discarded and then later reclaimed for reuse through a compaction process which you can either force or automatically as required. This is similar in principal to how wear leveling works on an SD cards, SSD drives etc.

Edit: It dawned on me that you might be using this block driver directly, if that is the case then you would need to do all of the above manually. The point of the block driver is to provide a device specific driver that the original TinyFileSystem can use to access a particular device. So you should not be using this code directly, but loading it as a driver into the TinyFileSystem and then use that to access the memory.

yep you’re right my first feeling was to use the low level part and indeed it will results in some issue due to MTBF of sector. However each sector is supposed to allow 100000 write cycles which is supposed to be far from what can be done by user modification in my application.

Your file system open new perspectives on this project (avoid SD card in case of data corruption) so I will give it a try :slight_smile:

Thanks for you addition for TinyFileSystem project.

If possible, one comment. In original file taylorza uses led to show flash activity. But you remove the code, that controls activity-led. I think, that it is better to use one of onboard leds to display activity of the flash. I use onboard Red Led (OnboardIO.LedRed). So, I add one more parameter in constructor and add back removed code, that using this led…

Regards,
Nikolay