2020-08-24 11:35 AM
Hi All,
I am trying to make data-logger using STM32L0, I application demands to store 2Mb data in .txt and .CSV format for that I am using SPI NOR Flash by Winbond W25Q32JV. I have never used SPI Nor Flash before and new to the file system.
Please help me how I can implement file system.
2020-08-24 12:11 PM
STM32 + W25Q NOR flash has been done before. There are drivers around, search the internet. NOR flash with file system is unusual because SPI NOR are unmanaged flash chips. Those are also not removable chips, so I don't see the need for a file system. But, that has also been done before. Who is reading the files and how? STM32 + file system + removable SD-card?
2020-08-24 04:00 PM
The NOR has 4KB erase blocks, so probably want to configure your files system to use that size.
Would suggest you review data sheets and
Write SPI access routines.
Test command interactions with the SPI NOR. Perhaps JEDEC READ ID, and READ BLOCK type commands.
Move on to ERASE BLOCK, and WRITE BLOCK commands.
Test that you can read/write assorted blocks to the NOR device, confirm you can do this successfully, and retrieve exactly the data you wrote previously.
Examine file systems, perhaps looks at FATFS, depends a lot on what you want to do, how many files you expect, if you connect to a PC or not.
2020-08-24 08:09 PM
Thanks @KnarfB and @Community member for the suggestion.
The device I am going to connect with USB and retrieve the data from the memory.
I have written the low level SPI driver to communicate with NOR Flash. Till I am able to read , write, erase the raw data in the memory.
Now I Implementing the FATFS, but problem I am facing with NOR flash is to write any new data or rewrite I have to erase the block which is erasing my whole data
so I am not sure how to handle that. FATFS do many read write for even opening and closing of file.
2020-08-24 08:28 PM
You'd want to tell FATFS to use 4KB blocks
Yes, there will be a lot of interaction for and open/write, this type of flash isn't particularly fast either.
The alternative would be a journalling type file system, that can incrementally write, with less read-erase-write cycling.
This might be more of a struggle on an L0 system as resources tend to be finite.
2020-08-24 11:14 PM
> write any new data or rewrite I have to erase the block which is erasing my whole data
This is expected behaviour. I would align the length (strlen including trailing \n) of each single line you are printing to a power of 2, say 16, 32 or such (depending on the data format you are using) by using appropriate format specifiers and padding with spaces if neccessary. You could also use a RAM buffer of block size (4k) for caching output lines and write to the file only when the entire block is full.