FreeRTOS+FAT for NOR SPI Flash

hssathya wrote on Wednesday, June 20, 2018:

Hi All,

Would you recmmond FreeRTOS+FAT for SPI based NOR FLASH?
Is there a port already available for this?


heinbali01 wrote on Wednesday, June 20, 2018:

Hi Sathya, you have probably heard that FAT is not an optimal file system to be implemented in NOR flash. But yes, at leat one person has implemented a driver that works well with FreeRTOS+FAT. I will ask if that person is willing to share his code.

If you do not need compatibility with FAT, you could also look around and find a file system especially designed for NOR flash.

loszi wrote on Thursday, June 21, 2018:

Hi Sathya,
Please find an FreeRTOS+FAT driver for Spansion s25fl164k attached.

As Hein mentioned - using NOR Flash + FAT fs (without some form of wear leveling) is not the best idea, because the intensive usage could kill the FAT area of the device. I recommend using it only for write rarely / read many application like storing configuration.

If you still want to use the driver, you need to customize / implement the following low level functions in the portable directory:

static uint8_t ucSpiTransferByte(uint8_t ucTX_Data)
static uint8_t ucSpiQuadReadByte(void)

and don’t forget to call:
BaseTypet xSpansionSPISyncCache(FFDiskt pxDisk, cachestampt xOlderThan);
before umount / power down for write back the changes.*

As you might see the code is quite experimental so no warranty at all, please use your own risk, and consider that each cache entry consumes 4KiB of RAM.

Regards, Szilárd

Dear Szilárd,

I came across this post but could not find the attached driver. I’d like to take a look to see if I might be able to use it.
Would it be ok, if you attach it again?

Best regards,


Here is the file that was originally attached by Szilárd. (14.5 KB)

Thanks for your immediate response!

Best regards,