Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

FAT32 Fixes for SD lib (easy) #161

Open
JacobChrist opened this Issue · 1 comment

2 participants

@JacobChrist

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:
uint32_t *pfileSize_ = new uint32_t();
*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() {
uint32_t *curClusterP_ = new uint32_t();
*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;
}

@GeneApperson

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.

GeneApperson

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.