I am still trying to get to the bottom of this.
In SDVolume.cpp, when we do init of the SDVolume class, it never gets any information from the SD Card. More specifically, Total Sectors, First Sector everything is 0 all the time. I don't think this has something to do with bad sectors, it's a different problem. We added some debugging messages to see the values of everything related to the SD card as follows:
Code:
part_t* p = &cacheBuffer_.mbr.part[part-1];
if ((p->boot & 0X7F) !=0 ||
p->totalSectors < 100 ||
p->firstSector == 0)
{
// not a valid partition
USB.println("Error: SdVolume::init() Invalid partition, (Total Sectors, First Sectors, boot), ");
USB.println(p->boot, DEC);
USB.println(p->totalSectors, DEC);
USB.println(p->firstSector, DEC);
return false;
}
volumeStartBlock = p->firstSector;
}
if (!cacheRawBlock(volumeStartBlock, CACHE_FOR_READ))
{
USB.println("Error: SdVolume::init() Cache for read2");
return false;
}
bpb_t* bpb = &cacheBuffer_.fbs.bpb;
if (bpb->bytesPerSector != 512 ||
bpb->fatCount == 0 ||
bpb->reservedSectorCount == 0 ||
bpb->sectorsPerCluster == 0)
{
// not valid FAT volume
USB.println("Error: SdVolume::init() invalid FAT volume, (BytePerSector, fatCount,reservedSectorCount,sectorsPerCluster)");
USB.println(bpb->bytesPerSector, DEC);
USB.println(bpb->fatCount, DEC);
USB.println(bpb->reservedSectorCount, DEC);
USB.println(bpb->sectorsPerCluster, DEC);
return false;
}
Any ideas on this?