Fat16 - Numerous Minor Bug Fixes and FAT32 Support v4.3
Posted: Sat Jun 12, 2010 11:38 pm
Hello,
For anyone using the FAT16 component in Flowcode you may have noticed some strange effects when using the component with certain types of cards.
I have been looking into this for a while and have finally discovered that the problem lies with how many sectors make up a disk cluster.
In the C code the number of sectors per cluster is read from the card's disk info section, however the value is not used in the code and instead the value of 32 is assumed.
Eg any cards with 32 sectors (16284 bytes) per cluster will work fine and any cards with a different cluster size will not work correctly causing dissapearing or missing files and FAT corruption etc.
I have recently aquired 3 new SD cards and they all have 64 sectors (32768 bytes) as a minimum per cluster so none of them worked with the current FAT16 component (v4.3).
Working Card - Minimum allocation size 16K Non Working Card - Minimum allocation size 32K Thankfully once I realised the route of the problem the fix was relativly simple.
Attached is an updated component for v4.3 of Flowcode which solves the problems described above by using the sector size value read from the card rather then using the assumed hard coded value.
To update the old FAT16 component simply save the file into your "Flowcode v4/Components" directory and restart Flowcode. You may want to make a backup of the file first just incase you want to go back to it for any reason at a later date.
FAT16 can only have a maximum partition size of 2GB so cards larger then 2GB will have to be formatted into the FAT16 (FAT) format to work correctly with the Flowcode component. The Flowcode component will only be able to access the first valid partition it see's on the card so multi-partition cards larger then 2GB should probably be avoided.
Fingers crossed now all types of SD and MMC cards sized 2GB and under will be fully compatible with the component
This should also include the new types of MMC and SD card which are supposed to be supporting the embedded SPI protocol that is currently used on the earlier cards. One small note about this is that while most cards will adopt the standard there are some that have a sector size that is not equal to 512 bytes. Any such cards will cause the Flowcode init macro to return an error code indicating the problem.
Any feedback or comments from anyone using my updated version of the FAT16 component would be appreciated.
Thanks.
For anyone using the FAT16 component in Flowcode you may have noticed some strange effects when using the component with certain types of cards.
I have been looking into this for a while and have finally discovered that the problem lies with how many sectors make up a disk cluster.
In the C code the number of sectors per cluster is read from the card's disk info section, however the value is not used in the code and instead the value of 32 is assumed.
Eg any cards with 32 sectors (16284 bytes) per cluster will work fine and any cards with a different cluster size will not work correctly causing dissapearing or missing files and FAT corruption etc.
I have recently aquired 3 new SD cards and they all have 64 sectors (32768 bytes) as a minimum per cluster so none of them worked with the current FAT16 component (v4.3).
Working Card - Minimum allocation size 16K Non Working Card - Minimum allocation size 32K Thankfully once I realised the route of the problem the fix was relativly simple.
Attached is an updated component for v4.3 of Flowcode which solves the problems described above by using the sector size value read from the card rather then using the assumed hard coded value.
To update the old FAT16 component simply save the file into your "Flowcode v4/Components" directory and restart Flowcode. You may want to make a backup of the file first just incase you want to go back to it for any reason at a later date.
FAT16 can only have a maximum partition size of 2GB so cards larger then 2GB will have to be formatted into the FAT16 (FAT) format to work correctly with the Flowcode component. The Flowcode component will only be able to access the first valid partition it see's on the card so multi-partition cards larger then 2GB should probably be avoided.
Fingers crossed now all types of SD and MMC cards sized 2GB and under will be fully compatible with the component
![Smile :)](./images/smilies/icon_smile.gif)
Any feedback or comments from anyone using my updated version of the FAT16 component would be appreciated.
Thanks.