I am trying to reference the sample project fatsdraw and implement the fatfs with the internal flash on MSP432E401Y.
I set the flash base address as the following in MSP_EXP432E401Y.c:
#define SECTORSIZE (0x4000)
#define NVS_REGIONS_BASE (0x80000)
#define REGIONSIZE (SECTORSIZE * 32)
For the block size, sector count and sector size, I set them in the new created NVSFatFS_diskIOctrl:
GET_SECTOR_COUNT=1024
GET_SECTOR_SIZE=512
GET_BLOCK_SIZE=512
Then I run the f_mkfs to create the file system for the flash memory:
fresult = f_mkfs(STR(DRIVE_NUM), FM_FAT, 0x1000, src.obj.fs->win , sizeof(src.obj.fs->win));
The size of the allocation unit (cluter) is set to 4096 bytes in f_mkfs().
The fresult is result with FR_OK. However, when trying to get the free cluster with running fresult = f_getfree(driveNumber, &freeClusterCount, fatfs);, the freeClusterCount always return 0. (fresult is FR_OK)
Can you please suggest the more proper sector count/sector size/block size or any other configuration setting for creating FATFS on flash?