I want to implement FAT32 on FreeRTOS for USB OTG USB Memory.

kevinbescom wrote on Tuesday, March 21, 2017:

Hi everyone.

I want to implement FAT32 on FreeRTOS for USB OTG USB Memory.
In my information, FreeRTOS have provided FAT32 with FreeRTOS Source Code.
But it is only for RAM Media FAT32 not Flash Media FAT32.
How to implement FAT32 for Flash Media?

Thank advance.

Kevin

rtel wrote on Tuesday, March 21, 2017:

Just as TCP code is generic, but must be ported to an Ethernet
controller, the FAT code is generic, but must be ported to the media
that is going to store the file file system. Information on how to do
this is provided on the following link:
http://www.freertos.org/FreeRTOS-Plus/FreeRTOS_Plus_FAT/Creating_a_file_system_media_driver.html

kevinbescom wrote on Wednesday, July 05, 2017:

Below is SD Disk API from FreeRTOS. Can i use below for USB Stick like "FF_USBDiskDetect() with just porting for reading, writing, IOMan Initializing and DISK IO "?

BaseType_t FF_SDDiskDetect( FF_Disk_t *pxDisk );
FF_Disk_t *FF_SDDiskInit( const char *pcName );
BaseType_t FF_SDDiskReinit( FF_Disk_t *pxDisk );
BaseType_t FF_SDDiskUnmount( FF_Disk_t *pDisk );
BaseType_t FF_SDDiskMount( FF_Disk_t *pDisk );
BaseType_t FF_SDDiskDelete( FF_Disk_t *pDisk );
BaseType_t FF_SDDiskShowPartition( FF_Disk_t *pDisk );
void FF_SDDiskFlush( FF_Disk_t *pDisk );
BaseType_t FF_SDDiskFormat( FF_Disk_t *pxDisk, BaseType_t aPart );
BaseType_t FF_SDDiskInserted( BaseType_t xDriveNr );
FF_IOManager_t *sddisk_ioman( FF_Disk_t *pxDisk );

Thank you

Kevin.

rtel wrote on Wednesday, July 05, 2017:

I’m not sure I fully understand your question, but yes, you should be
able to port to USB storage. It may be a little trickier than most port
as you will need to start with a working USB stack with appropriate drivers.

heinbali01 wrote on Wednesday, July 05, 2017:

I think that the documentation pointed-out by Richard is quite complete.

But the most important functions to be implemented are:

    static int32_t prvFFRead( uint8_t *pucBuffer, uint32_t ulSectorNumber, uint32_t ulSectorCount, FF_Disk_t *pxDisk );
    static int32_t prvFFWrite( uint8_t *pucBuffer, uint32_t ulSectorNumber, uint32_t ulSectorCount, FF_Disk_t *pxDisk );

You’ll bind the address of these functions to the so-called io-handler.

Note that these functions use sector numbers, not a byte offset.

For the other FF_SDDisk functions you can use the existing implementation in most cases.