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.

RTOS/PROCESSOR-SDK-AM437X: FAT volume size issue

Part Number: PROCESSOR-SDK-AM437X

Tool/software: TI-RTOS

Hi,

I'm trying to make f_mkfs() work on TI-RTOS.
I define : 

#define	_USE_MKFS		1

in ffconf.h.

In example I add:

FATFS_DrvFxnTable FATFS_drvFxnTable = {
    MMCSD_close,
	CS_eMMC_control,//MMCSD_control
    MMCSD_init,
    MMCSD_open,
    MMCSD_write,
    MMCSD_read
};

In IOctr function, sector and block data reports was impelmented:

MMCSD_Error CS_eMMC_control(MMCSD_Handle handle, uint32_t cmd, void *arg){
//	MMCSD_OK
	MMCSD_v1_Object            *object = NULL;
	DWORD *tmp;
	tmp = arg;
    /* Input parameter validation */
    OSAL_Assert(handle == NULL);

    object = (MMCSD_v1_Object *)((MMCSD_Config *) handle)->object;

    switch(cmd){
    case CTRL_SYNC:
    	//check
    	return FATFS_OK;
    	break;
    case GET_SECTOR_COUNT:
    		*tmp = (DWORD)object->size / (DWORD)object->blockSize;
    	return FATFS_OK;
    	break;
    case GET_SECTOR_SIZE:
    	*tmp = (DWORD)object->blockSize;
    	return FATFS_OK;
    	break;
    case GET_BLOCK_SIZE:
    	*tmp = (DWORD)object->blockSize;
    	return FATFS_OK;
    	break;
    case CTRL_TRIM:
    	return FATFS_OK;
    	break;
    case CTRL_EJECT:
    	return MMCSD_close(handle);
    	break;
    default:
    	break;
    }
    return (((MMCSD_Config *) handle)->fxnTablePtr->controlFxn(handle, cmd, arg));
}

f_mkfs() make partition of approx. size  1.7MB or it fail to make filesiystem....

Any knowing issues?

Best Regards,

Mare

  • The RTOS team have been notified. They will respond here.
  • Hi,

    I found bug in f_mkfs():

    on line 5333:

    	st_word(tbl + BPB_RootEntCnt, (WORD)i);
    	if (n_vol < 0x10000) {					/* Number of total sectors */
    		st_word(tbl + BPB_TotSec16, (WORD)n_vol);
    	} else {
    		st_dword(tbl + BPB_TotSec32, (WORD)n_vol);
    	}

    there is "WORD" cast in case of writing to BPB_TotSec32.
    It should be:

    st_dword(tbl + BPB_TotSec32, (DWORD)n_vol);

    Also I add :

    disk_ioctl(drive,CTRL_EJECT,NULL);

    in function DRESULT disk_unregister(BYTE drive) (discio.c).
    In previews post you can see in CS_eMMC_control() that I add 

        case CTRL_EJECT:
        	return MMCSD_close(handle);
        	break;

    Without that functionality you can't  "FATFS_close" and re-open with FATFS_open.


    *****************************************
    Now f_mkfs work on SD.
    My plan is to use eMMC on instance(1).

    I have already problems with working on MMCSD API level:

        if(MMCSD_socGetInitCfg(eMMC_INSTANCE,&hwAttrsConfig)!=0) {
    //       MMCSD_log ("\nUnable to obtain MMCSD config.Exiting. TEST FAILED.\r\n");
           return;
        }
    
        hwAttrsConfig.edmaHandle = NULL;
        hwAttrsConfig.enableDma = 0;
        hwAttrsConfig.enableInterrupt = 0;
    //    hwAttrsConfig.edmaHandle = *gEdmaHandle;
        hwAttrsConfig.cardType = MMCSD_CARD_EMMC;
        hwAttrsConfig.supportedBusWidth = MMCSD_BUS_WIDTH_4BIT;
        if(MMCSD_socSetInitCfg(eMMC_INSTANCE,&hwAttrsConfig)!=0) {
    //        MMCSD_log ("\nUnable to set config.Exiting. TEST FAILED.\r\n");
             return;
        }
        mmcStat = MMCSD_init();
        mmcStat = MMCSD_open(eMMC_INSTANCE, NULL, &emmc_handle); 
        for(index = 0; index<512;index++){
        	TxBufferMMCTest[index] = (char)index;
        }
        memset(RxBufferMMCTest, 0, 512);
        mmcStat = MMCSD_write(emmc_handle, TxBufferMMCTest , 0x0, 1);
        mmcStat = MMCSD_read(emmc_handle, RxBufferMMCTest , 0x0, 1);

    After reading RxBufferMMCTest is empty (0x00).
    eMMC init on line 2034 ( MMCSD_v1.c) force busWidth to 8-bit. I have on PCB 4-bit eMMC bus...
    I change to 4-bit:

    object->busWidth = MMCSD_BUS_WIDTH_4BIT;

    but eMMC reading still not work...

    Is any particular reason why is for eMMC hard coded 8-bit bus width?

    Any suggestion what to check?

    Best Regards,
    Mare

  • This is my "working driver fix" in MMCSD_v1_initEmmc:

    LINE 2033:
                object->size = (object->blockCount * object->blockSize);
                object->busWidth = MMCSD_BUS_WIDTH_4BIT;
                object->sdVer = object->ecsd[192];
    
    LINE 2038:
            if(MMCSD_OK == ret)
            {
                transaction.cmd = MMCSD_CMD(6U);
                transaction.arg = 0x03B90100;//HS_TIMING
                transaction.flags = MMCSD_CMDRSP_BUSY;
                ret = MMCSD_v1_transfer(handle, &transaction);
            }
    
    LINE 2077:
            if(MMCSD_OK == ret)
            {
                transaction.cmd = MMCSD_CMD(6U);
                transaction.arg = 0x03B70100;//4-bit //0x03B70200;//BUS_WIDTH-> 02 8-bit
                transaction.flags = MMCSD_CMDRSP_BUSY;
    
                ret = MMCSD_v1_transfer(handle, &transaction);
            }
    
    LINE 2089:
            if (MMCSD_OK == ret)
            {
                HSMMCSDSetBusWidth(hwAttrs->baseAddr, HS_MMCSD_BUS_WIDTH_4BIT);
            }


    For those who need change eMMC bus width to 4-bit bus....

    I didn't make real stress test with 4-bit bus...
    I still waiting on TI replay...
    Should I expect any problems? Or why is driver fixed to 8-bus width?


    Best Regards,
    Mare

  • Sorry, we are looking into this and will reply here.

    Regards, Eric