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 issue (ATA_systemInit ) in C5515

Other Parts Discussed in Thread: CSD

I used two SD cards to run ATA_systemInit in C5515 before I had formatted SD cards.

ata_error = ATA_systemInit(gpstrAtaDrive, diskType);

Card 1 ata_error = 0.

Card 2 ata_error = 768.

Why did the SD card 2 return ata_error = 768?

What is error code 768?

  • Hi,

    Are both these SD cards similar types ?

    Regards 

    Vasanth

  • Yes , these both of SD cards are similar.

    SanDisk Ultra 8GB microSD  HC I

    The below is a picture.

    24h.pchome.com.tw/.../DGAG0H-A9005EVQZ

  • Any updates?
  • Hi,

    Can you share more details on which example you were running etc. and let us know if this can be reproduced here ( using CSL example & hardware-EVM ).

    Regards

     Vasanth

     

  • Hi Vasanth,

    CSL example : c55_csl_3.03
    hardware : customize

    I found a SD card issue today when I used error = ATA_systemInit(gpstrAtaDrive, diskType);.

    Before the SD card was a good card , the SD card result of error is 0.
    Recently , I used the SD card for testing , program/read/erase and PC format .


    1) The SD card was with the same.
    2) The SD card result of error was 0. (Before 6/23)
    3) The SD card result of error is 768. (current 6/24)
    4) I had used format on Win7 PC , the SD card result of error is 768.

    Why did the SD card error from 0 to 768?

    What is error message 768?

    How to fix the issue?


    Best Regards,

  • Hi Vasanth,

    I found a way to fix SD card issue when ATA_systemInit return error was 768.

    But I didn't know what did the SD card or FW root cause.

    Could you tell me the root cause?
    What is error message 768?


    //================================================

    // *********************** // Before: // ata_error = 768


    diskType = CSL_MMCSD_ATAFS_DISKTYPE;

    /* Call ATA_systemInit() to intialize some values whcih are
    used by chk_mmc() function */
    ata_error = ATA_systemInit(gpstrAtaDrive, diskType);
    if(ata_error) // SD card is not good , ata_error = 768
    {
    printf("ATA_fileInit error (0x%x)\n", ata_error);
    printf("ATA_systemInit Failed\n");
    }
    //ata_error = ATA_diskFree(gpstrAtaDrive, 0);
    chk_mmc(gpstrAtaDrive, &diskType);
    if(diskType != CSL_MMCSD_ATAFS_DISKTYPE)
    {
    ata_error = ATA_systemInit(gpstrAtaDrive, diskType);
    if(ata_error != ATA_ERROR_NONE)
    {
    printf("ATA_systemInit Failed\n");
    }
    }



    // *********************** // Current: // ata_error = 0


    diskType = CSL_MMCSD_ATAFS_DISKTYPE;
    chk_mmc(gpstrAtaDrive, &diskType); // for fix ata_error = 768
    /* Call ATA_systemInit() to intialize some values whcih are
    used by chk_mmc() function */
    ata_error = ATA_systemInit(gpstrAtaDrive, diskType);
    if(ata_error) // ata_error = 0
    {
    printf("ATA_fileInit error (0x%x)\n", ata_error);
    printf("ATA_systemInit Failed\n");

    }
    //ata_error = ATA_diskFree(gpstrAtaDrive, 0);
    chk_mmc(gpstrAtaDrive, &diskType);
    if(diskType != CSL_MMCSD_ATAFS_DISKTYPE)
    {
    ata_error = ATA_systemInit(gpstrAtaDrive, diskType);
    if(ata_error != ATA_ERROR_NONE)
    {
    printf("ATA_systemInit Failed\n");
    }
    }



    //////////



    /* <susmit : Added a new parameter, unsigned int *disk_type : 04-Mar-2003> */
    MMC_ERR_int16 chk_mmc(AtaState *pAtaDrive, unsigned int *disk_type)
    {
    AtaError ata_error = ATA_ERROR_NONE;
    AtaUint32 disk_sectors_from_csd = 0xbeefbeef ;
    unsigned long sectors_in_partition_from_MBR = 0xbeefbeef;
    unsigned long boot_record_sector = 0xbeefbeef;
    unsigned int ii = 0;
    /* <susmit : Variables to hold the error value and boot record type : 04-Mar-2003> */
    MMC_ERR_int16 mmcerror = MMC_ERR_NONE;
    unsigned int boot_record_type = HD_BOOT_RECORD;

    #if 0 /* For the cards with csd ver2.0 it is not possible to determine the file system format */
    unsigned int mmc_file_system_format = 0xbeef;

    /* Get the file format information from MMC CSD register */
    mmc_file_system_format = MMC_file_system_format(pAtaDrive->pAtaMediaState);

    /* <susmit : If the file format is Universal File Format or Unknown, return error : 04-Mar-2003> */
    if((mmc_file_system_format!=0)&&(mmc_file_system_format!=1))
    return MMC_ERR_BAD_CSD_FILE_FORMAT;
    #endif

    /* Get total number of sectors on MMC from CSD register */
    disk_sectors_from_csd = getMMCSize(pAtaDrive);

    /* Try to read Master Boot Record from sector */
    ata_error = ATA_readSector(0, pAtaDrive, (AtaUint16*)&master_boot_record, 1);

    /* ata_error should be ATA_ERROR_NONE unless the card is damaged and unreadable */
    if(ata_error != ATA_ERROR_NONE)
    return MMC_ERR_CARD_NOT_READABLE;

    /* Check for all partition entries of partitions 2,3,4 to be zero */
    for(ii = 0; ii < 3*sizeof(PARTITION_TABLE); ii++){

    if( *((int*)(&master_boot_record.partition_two) + ii) != 0)
    /*return MMC_ERR_MBR_BAD_PARTITIONS_234;*/
    mmcerror = MMC_ERR_MBR_BAD_PARTITIONS_234; /* <susmit : Set the error : 04-Mar-2003> */
    }

    /* Verify number of sectors in partition as reported by MBR is less than
    the total number of sectors reported by CSD register */

    sectors_in_partition_from_MBR =
    ((unsigned long)(master_boot_record.partition_one.byte1_no_of_sectors_in_partition) |
    (unsigned long)(master_boot_record.partition_one.byte2_no_of_sectors_in_partition)<<8|
    (unsigned long)(master_boot_record.partition_one.byte3_no_of_sectors_in_partition)<<16 |
    (unsigned long)(master_boot_record.partition_one.byte4_no_of_sectors_in_partition)<<24 );

    if(sectors_in_partition_from_MBR > disk_sectors_from_csd)
    mmcerror |= MMC_ERR_MBR_BAD_NUM_PART_SECTORS; /* <susmit : Set the error : 04-Mar-2003> */


    /* Calculate the sector number of the boot record */
    boot_record_sector =
    ((unsigned long)master_boot_record.partition_one.byte1_first_sector_position) |
    ((unsigned long)master_boot_record.partition_one.byte2_first_sector_position<<8) |
    ((unsigned long)master_boot_record.partition_one.byte3_first_sector_position<<16) |
    ((unsigned long)master_boot_record.partition_one.byte4_first_sector_position<<24);

    /* <susmit : The number of sectors in partition plus the number of reserved sectors must be equal
    * to the number of sectors present in the disk as indicated by the CSD register : 04-Mar-2003> */
    if((sectors_in_partition_from_MBR+boot_record_sector)!=disk_sectors_from_csd)
    mmcerror |= MMC_ERR_MBR_DSKSIZE_MISMATCH;

    /* <susmit : If no errors upto this, then this might be a disk with both MBR & BR.
    * Otherwise set boot sector as zero & check : 04-Mar-2003> */
    if(mmcerror) {
    boot_record_sector = 0;
    boot_record_type = FD_BOOT_RECORD;
    sectors_in_partition_from_MBR = disk_sectors_from_csd;
    *disk_type = 1; /* floppy-like file format (without partition table) */
    }

    /* Now check Boot Record */
    return Check_boot_record(boot_record_sector,
    sectors_in_partition_from_MBR,
    boot_record_type, /* <susmit : Can be HD or FD boot record : 04-Mar-2003> */
    pAtaDrive,
    &boot_record);

    }


    //================================================
    Best Regards,
  • Hi,

     How did you fix this issue?  Is the issue reproducible on C5515 EVM ?

     Let me know.

    Regards

     Vasanth

  •  Hi Vasanth,

    I tried the SD card on C5515 EVM , the ata_error was 768 , too.

    Before ATA_systemInit , I call chk_mmc(gpstrAtaDrive, &diskType); to fix ata_error = 768 issue.

    Could you tell me the ata_error = 768 root cause?


    // CCS version : c55_csl_3.04
    // CSL_MMCSD_SdCardFSExtExample
    ata_error = ATA_systemInit(gpstrAtaDrive, diskType); // ata_error = 768



    Best Regards,

  • Hi,

    It looks like its formatting issue. I formatted using SDformatter and it worked. Later I formatted with windows7 SD formatter & I did not see issue their either. I tried with SD and SDHC both works.

    Attached is the snapshot for your reference.

    Regards

     Vasanth