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.

EVMK2G: Error in writing files more than 4GB using FATFS driver.

Part Number: EVMK2G

I need to write three files from the host to a USB flash memory stick. I am enabling exFAT in the FATFS driver and formatting the USB stick to exFAT. I am opening three files simultaneously and writing to them in serial order. I observe that each file throws error exactly after 4GB of data been written. Can you provide some input on this issue?

  • Hi,

    Which Processor SDK RTOS version are you using?
    Can you share the error log?

    Best Regards,
    Yordan
  • Hi Yordan,

    I am using processor_sdk_rtos_k2g_4_03_00_05 RTOS.
    Error code returned from f_write is (-39553)

    Thanks,
    Aakash
  • Aakash,

    That is interesting. I am following up with the FATFS driver team to see if we do support and validate the exFAT feature that allows usage upto 32 GB flash sizes as I do see the support in the driver but the default settings disable the feature. From the driver code it appears that the default setup doesn`t define _EX_FATFS in the ffconf.h file so by default the driver only supports FAT32 filesystem mode.

    #define _FS_EXFAT 0
    /* This option switches support of exFAT file system in addition to the traditional
    / FAT file system. (0:Disable or 1:Enable) To enable exFAT, also LFN must be enabled.
    / Note that enabling exFAT discards C89 compatibility. */

    Did you try to rebuild the driver with _EX_FATFS defined in the file at location pdk_k2g_1_0_9\packages\ti\fs\fatfs\ffconf.h.

    If possible it might also be useful if you can provide some details on why you need greater the 4GB in you application and if you have simple way for us to reproduce this setup locally.

    Regards,
    Rahul
  • Hi Rahul,

    We have built the filesystem driver with _FS_EXFAT = 1 and LFN = 1.

    Our application requires to write a file with size greater than 4 GB. I am sharing the code snippet that we are using.

    int writeStd( uint32_t pattern )
    {
    uint32_t bytesWritten;
    dataPatternFill(stdData, STD_DATA_SZ, pattern );
    FRESULT fresult = f_write(&gStdFileObj, stdData, STD_DATA_SZ, &bytesWritten);
    if(fresult != FR_OK )
    consolePrintf("\n****fresult = %d****\n", fresult);
    return fresult == FR_OK ? bytesWritten - STD_DATA_SZ : fresult;
    }

    while ( Event_pend( evntLogger, Event_Id_01, Event_Id_NONE, waitTicks ) != Event_Id_01 )
    {
    // write STD data
    if (!stdFailed ) {
    if ( (fresult = writeStd(stdWrites++)) == FR_OK )
    stdGood++;
    else {
    stdFailed = stdWrites+1;
    consolePrintf("\nWrite to Std first failed (%d) on write %d\n", fresult, stdFailed );
    }
    }

    }

    Regards,

    Aakash

  • Aakash,

    It appears the current version of the FATFS driver doesn`t support FATFS and there will be additional effort required to support exFAT format. Please check Todd`s response on the ti RTOS forum where the user was planning to use exFAT on one of our MCU platforms.
    e2e.ti.com/.../654634

    It has been indicated that exFAT would require us to define 64bit integer and discard C89 compatability as you can see from the app note here:
    e2e.ti.com/.../654634

    I don`t think this is a feature that we can support in short term but we are tracking this as an enhancement. Please highlight if this is a priority for your project and we can indicate that in our tracking system.

    Regards,
    Rahul
  • Rahul,

    There is no application note about defining 64bit integers at the link you provided. Is that the correct link?

    Mike

  • Mike,

    Thanks for pointing that out. I posted the E2e thread link twice but the app note that I was referring to is available at the following location:
    elm-chan.org/.../appnote.html

    Regards,
    Rahul
  • Your first post had two links to the same E2E unless I'm seeing it wrong. I have seen the elm-chan note and we have the proper configuration setting set and the pdk recompiled. We can write to afile until we reach 4G at which point we get ungraceful write failures. We require larger files for our logging. In the link you provided Todd says: "TI did make a change to the downloaded code. It's probably easiest to download the old version (.11a) from the web and compare it to the one in TI-RTOS to see the differences. You'll need to make similar changes to get it to work." I have PDK 4.0.7 and it did not have fatfs. Where can we find the version that Todd is referring to?

    The ability to write files larger than 4G is a critical requirement in our project. Please add it to your tracking system as soon as you can and provide an estimate for a fix if possible.

    Mike

    XDCtools 3.32, SYS/BIOS 6.46, CCS 7.4, PDK 4.0.7, NDK 2.25