ound a part of the FAT32 bug. It's in the same SDFile.cpp, openRoot method, where in calling vol->chainSize(firstCluster, &fileSize), fileSize_'s address is not correct. Tried this and works to open a FAT32 card , it says it creates a new file, but I didn't check the card. So I don't know if there is another bug remained or not.
Initial code in the openRoot method is:
Code:
if (!vol->chainSize(firstCluster, &fileSize)) return false;
Modified code in the openRoot method is:
Code:
uint32t *pfileSize = new uint32t();
*pfileSize = fileSize;
if (!vol->chainSize(firstCluster, pfileSize))
{
Serial.println("Error opening FAT32 filesystem"); return false;
}
Serial.println("Success opening filesystem");
fileSize = *pfileSize;
delete pfileSize;
pfileSize_ = NULL;
Jacob,
Thanks for this information. I have someone working on trying to track down the problems with SD right now. I'll have her look at this right away.
The following changes are needed for Fat32 file systems:
hardware/pic32/libraries/SD/utility/SdFile.cpp
http://www.chipkit.org/forum/viewtopic.php?p=2702#p2702
ound a part of the FAT32 bug. It's in the same SDFile.cpp, openRoot method, where in calling vol->chainSize(firstCluster, &fileSize), fileSize_'s address is not correct. Tried this and works to open a FAT32 card , it says it creates a new file, but I didn't check the card. So I don't know if there is another bug remained or not.
Initial code in the openRoot method is: Code: if (!vol->chainSize(firstCluster, &fileSize)) return false;
Modified code in the openRoot method is: Code: uint32t *pfileSize = new uint32t(); *pfileSize = fileSize; if (!vol->chainSize(firstCluster, pfileSize)) { Serial.println("Error opening FAT32 filesystem"); return false; } Serial.println("Success opening filesystem"); fileSize = *pfileSize; delete pfileSize; pfileSize_ = NULL;
The Serial.println's are just for debugging.
http://www.chipkit.org/forum/viewtopic.php?p=2669#p2669
uint8_t SdFile::addCluster() { uint32t *curClusterP = new uint32t(); *curClusterP = curCluster; if (!vol->allocContiguous(1, curClusterP)) return false; curCluster = *curClusterP; delete curClusterP; curClusterP = NULL; // if first cluster of file link to directory entry if (firstCluster == 0) { firstCluster = curCluster; flags_ |= F_FILE_DIR_DIRTY; } return true; }