Hi everyone!
I am working on a project where I have to store files inside a FLASH coming from a GATT server, and be able to manage them through FAT in a GATT client. The part of sending and receiving data through BLE works correctly.
I am using the following Software/Hardware tools:
- nRF5_SDK_17.1.0
- nRF52832
- SPI NOR FLASH 32Mbit (4MB)- AT25DF041B
- Segger V5.70
- FatFS - http://elm-chan.org/fsw/ff/doc/getfree.html
- Windows 10 64 bits
Looking through the examples provided by the SDK, I find the following example:
...\nRF5_SDK_17.1.0\examples\peripheral\fatfs
This example incorporates the FAT but with an SD card. For my project I need to format the FAT on my SERIAL NOR FLASH and mount the volume.
Reading ChaN's FatFS documentation I need to make my own low level disk I/O layer, and make the connection to the FatFS module. Having said the above, I have already done my low-level disk I/O layer and the connection with the FatFS module but I am not getting the expected results. Before I continue, I'd like to check a few things in my project settings to make sure it's set up correctly.
AT25DF041B can be erased in sizes of 256B, 4KB, 32KB and 64KB. Reviewing the ffconfig.h file I find that:
1 .- Set the sector size to 4096 for FAT because it fits the erase sector in FLASH which is also 4096, is this setting correct?
In my code I mount the volume with f_mount, and in case of returning FR_NO_FILESYSTEM I proceed to format the FLASH WITH f_mkfs. Everything is going perfect up to that point, but when I get the free sectors with f_getfree or I want to write a file larger than 230KB the problems start.This means that the FLASH is not being formatted or mounted correctly.
2.- What I would expect from f_getfree would be the free clusters on the volume, in my case there is one sector per cluster (4096*1). So I would expect to get (1024 clusters - VBR) * 4096 bytes and this would result in a value close to 4,194,304 = 4 MB, is this true?
If you have sample code that you can provide with SPI NOR FLASH and FATFS using nRF52832 I would greatly appreciate it.