This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

SD card sector size

Other Parts Discussed in Thread: CSD

I'm using the eZDSP5535 with the c55_csl_3.04 CSL and a 2GB microSD card from SanDisk.  My code follows an example from the CSL.  My SD card is only half full when the CSL throws an error at line 1289 in csl_mmcsd_atIf.c:

    if((startSector > (hMmcSd->cardObj->totalSectors - 1)) ||
       (sectorCount > validSectors))
    {
        ataResult = ATA_ERROR_INVALID_PARAM;
        return (ataResult);
    }

hMmcSd->cardObj->totalSectors is roughly half of that for gpstrAtaDrive->TotalSectors.  I new to using an SD card.  It appears to me that cardObj->blockLength being set 1024 instead of (the usual?) 512 may be the problem.  As a quick check, I doubled the value of cardObj->totalSectors and was able to completely fill up the SD card.

I did have to comment out chk_mmc() since this line kept throwing an error with my Windows formatted FAT32 card.

     if((sectors_in_partition_from_MBR+boot_record_sector)!=disk_sectors_from_csd)
            mmcerror |= MMC_ERR_MBR_DSKSIZE_MISMATCH;

I would rather not override the CSL value for the total number of sectors.  Am I doing something wrong somewhere?  Is a sector always 512 bytes?

Thanks.

  • I wonder whether it has to do with the Windows formatter. What Windows OS are you using? Have you tried with different cards?
    Regards.
  • Steve, thanks for the reply.

    I have been using the built-in Windows 7 formatter for the 2GB card and guiformat.exe (www.ridgecrop.demon.co.uk/index.htm) for a 64 GB SanDisk card. guiformat.exe reports 124702720 sectors at 512 bytes per sector for the 64GB card. cardObj->totalSectors shows 57626624 sectors with a blockLength of 512. gpstrAtaDrive->TotalSectors = 124702720.

    Using guiformat.exe on the 2GB card didn't solve the problem. cardObj->totalSectors is still about half of gpstrAtaDrive->TotalSectors. Again, I'm new at using SD cards and I'm assuming those two values for the total number of sectors should be roughly equal.