Hi GR, thank you for contacting us.
Do you have a FreeRTOS+FAT driver for your AM6442? Where did you find it?
When the driver mounts a disk partition, it will detect the type of FAT: 12, 16, or 32.
Note that ffconfigFAT12_SUPPORT
is defined as 0 by default, thus FAT12 will not be supported unless you define ffconfigFAT12_SUPPORT
as 1
in your FreeRTOSFATConfig.h.
By default, ffconfigLFN_SUPPORT
is defined as 0
, meaning that Long File Names will not be supported, only 8.3 names.
I normally have the following settings in my FreeRTOSFATConfig.h:
#define ffconfigLFN_SUPPORT 1
#define ffconfigMAX_FILENAME 129
#define ffconfigFAT12_SUPPORT 0
This means that I can use long file- and directory names, which are up to 128 bytes long ( make sure the task has enough stack space ).
I also recommend to use the functions declared in ff_stdio.h because they are compatible with the functions used in stdio.h. That makes it easy to test your programs on a PC before running it in an MCU.
Here is an example of how to read the first sector of a file:
FF_FILE * pxHandle = ff_fopen( "/files/my_long_filename.txt", "r" );
if( pxHandle != NULL )
{
char pcBuffer[ 512 ];
size_t xResult = ff_fread( pcBuffer,
1U, /* size */
sizeof( pcBuffer ), /* count */
pxHandle );
if( xResult > 0 )
{
printf("Read %u bytes\n", xResult );
}
else
{
int iNumber = stdioGET_ERRNO();
printf( "ff_fread failed with errno %d\n", iNumber );
}
ff_fclose( pxHandle );
}
I haven’t tested the above code.
stdioGET_ERRNO()
returns a value which can be looked up in projdefs.h. They are more or less the same as errno on other systems.
Note that errno is simulated using local storage pointers. Therefor, the value of “errno” and the cwd (current working directory) are local for every task.
Please define the following in your copy of FreeRTOSConfig.h:
/* FreeRTOS+FAT requires 4 pointers if a CWD is supported. */
#define configNUM_THREAD_LOCAL_STORAGE_POINTERS 4