Can’t read files bigger than 2Kb using FreeRTOS+FAT

I am using FreeRTOS v 10.1.0 , in addition I have downloaded FreeRTOS+FAT from the labs area (160919 release) I am using an Altera Cyclone V evaluation board and have succesfully ran FreeRTOS projects on the board using the Demo project and the available port for my board as the basis for my own applications. I have also succesfully mounted a partion on my SD Card and read files from the SD Card and also written files to the SD Card. My problems begin when I try to read a file bigger than 2K. I am using the following ff_fread command to read from a file I have previous opened and I know to be 5777 bytes long: ff_fread( &byteBuffer[0],1,5777, pxSourceFile ); What I find is the byte buffer is repetedly populated with the same 2048 bytes, up to the maximum of 5777 bytes. So byteBuffer[0] to byteBuffer[2047] are what I expect but then this data is repeated. I have also tried to read the data in 512 byte chunks and also in 2048 byte chunks in case the issue was related to a sector boundary (512 byte sector) or a cluster boundary (4 sectors per cluster). My suspicion is that the issue is in FreeRTOS + Fat as opposed to the Altera code for interfacing with the SD Card. This is becasue when I put a break point in the following function I see that the FreeRTOS+Fat api does actually seem to jump back to the first sector after it has successfully read 4 sectors of data. So it would seem that the Altera Api is returning the data requested by FreeRTOS + FAT. static int32t prvReadSd( uint8t *pucDestination, uint32_t ulSectorNumber, uint32_t ulSectorCount, FF_Disk_t *pxDisk ) { int32_t errorCode = alt_sdmmc_read(pucDestination, ulSectorNumber * 512, ulSectorCount * 512); return errorCode } Any insights anyone can offer into the issues I am having will be greatly appreciated.

Can’t read files bigger than 2Kb using FreeRTOS+FAT

Ok, I have resolved my issue. My apologies for blaming FreeRTOS+FAT, I will explain the issue below just in case others have the same issue. I had created a 1MB partition on my SD Card which I believed to be Fat16. After trying various things I decided to reformat my sd care using the following command in Linux. sudo mkdosfs -F 16 /dev/sdc4 linux gave the following warning WARNING: Not enough clusters for a 16 bit FAT! The filesystem will be misinterpreted as having a 12 bit FAT without mount option “fat=16”. This prompted me to enable Fat12 support in the FreeRTOS+Fat config file and this fixed my issue.

Can’t read files bigger than 2Kb using FreeRTOS+FAT

Thanks for taking the timer to report back.