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-AM335X: eMMC format with FATFS

Part Number: PROCESSOR-SDK-AM335X
Other Parts Discussed in Thread: AM3352

Tool/software: TI-RTOS

Dear TI support team,

we have a custom board which features a AM3352 processor.
The processor is connected to an internal eMMC and a SD card slot (MMC0 and MMC1 peripheral).

I have implemented your FATFS procedure so far and the access to both media seems to work.
I can read/write to an already formatted SD card and the (unformatted) eMMC responds with a FR_NO_FILESYSTEM to a f_stats request.

We would like to format the eMMC in case it is not formatted yet.
I have tried to implement the f_mkfs command but it does not seem to work.
It looks like the disk_ioctl command, which is used by the f_mkfs command, is implemented but it does nothing.

As far as I've investigated, the disk_ioctl calls the registered function FATFS_diskIOctrl from the FATFS_drv.c file.
This function does some checks and returns with "RES_OK" but without doing anything.
This behaviour causes some trouble and undefined behaviour in the f_mkfs function here:

if (disk_ioctl(pdrv, GET_SECTOR_COUNT, &n_vol) != RES_OK || n_vol < 128) {
    return FR_DISK_ERR;
}

The variable n_vol is a local variable but is not initialized.
The disk_ioctl function returns with no error but leaves the n_vol variable untouched.
Therefore I did not get an error at first but had to debug until I found the problem.

So it looks like this command is not implemented and therefore it is not possible to use the f_mkfs command.
Am I correct in the assumption that the f_mkfs command is not useable?

Thank you,
Markus

  • Hi Markus,

    The Processor SDK RTOS driver for MMCSD/EMMC and FATFS don't provide the disk format function. But we rely on an external source (PC) to format a raw disk.

    • For MMCSD, it is easy, you can insert it into a MMCSD card reader and plug into PC to format it as FAT32.
    • For EMMC, it is not detachable from your board. If you have USB interface, we have code example to bundle USB+EMMC together. You connect your board to PC via USB interface, the EMMC drive is exposed to PC as un-formatted mass storage class (MSC), you can see that from the PC just as you plug a regular USB stick. Then use the PC tool to format it. The example is  USB_DevMsc_emmc_bbbAM335x_armExampleProject under pdk_am335x_1_0_14\packages\ti\drv\usb.

    If you don't have USB on your board, we have no way to format it and have no plan to implement disk format inside our driver.

    Regards, Eric

  • Hello Eric,

    thanks for the info.

    There is a third possibility to setup the eMMC.
    I used the TI Linux SDK to setup a SD card containing a customized Linux for our board.
    The Linux OS boots from the SD medium and lets you partition and format the eMMC with linux tools (fdisk, mkfs).
    Now my application (TI RTOS) using FatFS is able to access the eMMC.

    Kind regards,
    Markus