2020-07-08 01:43 AM
I traced the code flow and I found that the SPI flash should be formatted.
I used an SD-Card and traced the code while it is mounted and knew that it searches in sector 0 for the record signature and the pointer to the partition sector. Then it reads the partition sector to get all information about the physical memory. My problem is that the SD-card has 512 Bytes per sector and 236 sectors per cluster while SPI-Flash sector size is 4096 Bytes and the block is 32 Kilo Bytes . When I edit the sector data to adequate my SPI-Flash the code calculates the total memory wrong. I want to know how can I edit these data to make the code controls the SPI-Flash successfully.
Also I want to know how to calculate the Root Directory Entry Size.
Thank you!!
2020-07-09 09:53 AM
There are some remarks about porting FatFS here http://elm-chan.org/fsw/ff/doc/appnote.html#port as a starting point.
A direct mapping from FatFS to SPI flash has the disadvantage, that there is no wear-levelling layer involved. I.e. the first sectors containing the FAT (file allocation tables) etc. will change quite often when you write to a file and wear out the underlying flash cells. This may or may not be a critical point depending on your use case.
2020-07-09 10:56 AM
Use f_mkfs() to format the media, with the IOCTL in diskio.c setup to provide block counts.
Make the sector size the minimum erase size of the media unless you plan to micro-manage the deblocking yourself in diskio.c
Use of NOR media in this fashion is ill advised and very slow when writing. Chip level data storage is better done with eMMC.