AnsweredAssumed Answered

small error in sdh driver ?

Question asked by jeanmichel on Nov 22, 2011
Latest reply on Dec 21, 2011 by MartinK

Hello,

 

I'm running under VDSP 5.0 update 10 . Im using the FSS with the SDH driver. I had a problem with the formatting of the SD card : the partition was only half the size of the sd card.

 

then I dig in the source code of the sdh driver :

 

from adi_sdh.c rev. 3578
__ADI_SDH_SECTION_CODE
static u32 adi_sdh_CalculateCardSize(
    ADI_SDH_DEF *pDevice       /* pointer to SDH device we're working on   */
){
    u32 u32Temp;
    u8  u8Temp;
    u32 Result = ADI_DEV_RESULT_SUCCESS;
    /* save the card block length */
if((pDevice->SlotStatus == ADI_SDH_SLOT_MMC) || (pDevice->SlotStatus == ADI_SDH_SLOT_MMC_HC))
{
         pDevice->CardInfo.BlockLength = pDevice->CardInfo.CardRegisters.mmc.csd.read_bl_len;
         u8Temp  = pDevice->CardInfo.CardRegisters.mmc.csd.c_size_mult;
            u32Temp = (1 << (u8Temp + 2));
            if(pDevice->SlotStatus == ADI_SDH_SLOT_MMC)
            {
                 pDevice->CardInfo.TotalBlocks = ((pDevice->CardInfo.CardRegisters.mmc.csd.c_size + 1) * u32Temp);
            }
            else
            {
                 pDevice->CardInfo.TotalBlocks = pDevice->CardInfo.CardRegisters.mmc.extcsd.sec_count;
            }
}
else
{
pDevice->CardInfo.BlockLength = pDevice->CardInfo.CardRegisters.sd.csd.read_bl_len;
u8Temp  = pDevice->CardInfo.CardRegisters.sd.csd.c_size_mult;
            u32Temp = (1 << (u8Temp + 2));
   /* IF (SDH slot has Version 2.0 SDHC card) */
         if (pDevice->SlotStatus == ADI_SDH_SLOT_SDHC_CARD)
         {
                 /* Memory capacity of version 2.0 SDHC card = (C_SIZE + 1) * 512K bytes */
                 /* Get Total block count (1 block = 512 bytes) */
                 /* so, Total block count = ((C_SIZE + 1) * (512KB / 512))
                     Total block count = ((C_SIZE + 1) * 1KB)
                 */
                 pDevice->CardInfo.TotalBlocks = ((pDevice->CardInfo.CardRegisters.sd.csd.c_size + 1) * 512);
         }
         /* ELSE (SDH slot has MMC or Version 1.X/2.0 standard capacity SD card) */
         else
         {
                 /* calculate Total number of blocks in this memory card */
                pDevice->CardInfo.TotalBlocks = ((pDevice->CardInfo.CardRegisters.sd.csd.c_size + 1) * u32Temp);
         }

 

 

 

I had to change the 512 (in red) by 1024 to make it work. Is it a bug in the driver or something else in my code that could be wrong ?

Thanks,

Jean Michel LECONTE

Outcomes