Marc,
The FATFs version used is 8a.
That blurb about fixing truncating when the file size is close to 4GB (FAT32 file size limit) doesn't apply here.
My files are only 8MB, and the 4GB limit is related to overflowing a 32-bit number (explained further below).
Mark,
I understand that FAT works in sectors, as do SDHC cards, whereas the low capacity SD cards work in bytes.
I agree that a multiply by 512 in the low level routines is required for compatability with these older cards.
The issue is in the implementation.
I just created a new bareboard project with Processor Expert.
I add a FAT_FileSystem component, which references a FatFsMemSDHC compoment.
I then generated the source code.
All of the issues can be found in FATM1.c
Within both the disk_read and disk_write functions, there are calls to SD_TransferBlock, which pass sector*FATM1_BLOCK_SIZE.
Within SD_TransferBlock, there is a call to SD_ByteToCardAddress, which checks if the card is HighCapacity and does >> 9 if it is.
By this logic, the assumption is that the card is low capacity, so a multiply by 512 is done when passing the value to SD_TransferBlock.
Then, if the card is high capacity, a divide by 512 is done.
This is incorrect for two reasons, one logical and one performance.
Regarding performance...
In the case of high capacity cards, we are always multiplying by 512, then dividing by 512.
It makes more sense to only multiply by 512 if the card is NOT HighCapacity.
The true logic bug exists once we need a sector past 8388607 on an SDHC.
The initial multiply by 512 overflows, resulting in 0.
The divide by 512 stays a 0, and the FAT table gets overwritten.
I changed the calls to SD_TransferBlock to pass only the sector and not sector * FATM1_BLOCK_SIZE
I modified SD_ByteToCardAddress to << 9 if not a HighCapacity card.
With these changes, I'm still compatible with low capacity cards, and I remove the unnecessary multiply and divide by 512 for SDHC.
I'm currently filling an SD card, and I suspect it will have no issues getting past the 4GB data limit that I saw previously.
V/R,
Chandler