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.

How to list all the files present in memory card using TI-RTOS?

Other Parts Discussed in Thread: SYSBIOS

Hi,


I want to display or list all the files present in TF/USB card with properties with the help of TI-RTOS (Memory usage and Free details also). How can i fetch these details from TF/USB card?

Thanks,

Srinivas M

  • Srinivas,
    The TI-RTOS USBMSCHFatFs drivers don't have any API's for doing this if that's what you're using. By the way, what TI-RTOS version are you using and what device?

    Thanks,
    Moses
  • Hi Moses,

    I am using tirtos_tivac_2_10_01_38 and device is TM4C129X. Just i have to list all the files and folders present in USB/TF card and display on the console with properties.

    Thanks,

    Srinivas M

  • Srinivas,

        So the TI-RTOS USBMSFatFs driver uses FatFs to manage a file-system on the USB storage device. The USBMSFatFs doesn't have API's for filesystem access but instead the FatFs API's are used for this. Here's a link to the FatFs API's. 

    To list files look at:

    f_opendir -  opens a directory

    f_readdir -  reads all contents of an opened directory into a FILINFO struct array. The names of the files can be accessed from the name field of FILINFO.

    Another API that might interest you:

    f_getfree - returns the amount of free space left on the volume

    Let me know if this helps

    Moses

  • Hi Moses,

    My main issue is how to path the DRIVE. My board is DK-TM4C129X. TF card interface is SSI3 Communication and Drive number defined in the code is 0 (I.e, #define DRIVE_NUM 0).  I should be able to read all the directories list. Can you suggest with some example. I am also following sameFatFS link.

    Thanks,

    M Srinivas

  • I'm sorry we don't have any examples that does this. I googled around and didn't find much but following the FatFs docs might be our best bet. I can help you along the way. Are you working from one of the TI-RTOS examples? The fatsdusbcopy example will be a good place to start. Confirm that you're able to import and build that project? I'll look more at FatFs docs and will let you know if I have further insight.

    Moses

  • Hi Moses,

    How to access following API's using TI-RTOS

    f_forward, f_gets f_putc f_puts f_printf f_closedir f_findfirst f_findnext f_chdir f_chdrive f_getcwd f_fdisk f_getlabel f_setlabel 

    Thanks & Regards,

    M Srinivas

  • Hi Moses,

    How to access following API's using TI-RTOS.

    f_forward, f_gets f_putc f_puts f_printf f_closedir f_findfirst f_findnext f_chdir f_chdrive f_getcwd f_fdisk f_getlabel f_setlabel

    Thanks & Regards,

    M Srinivas
  • Hi Srinivas,

            FatFs is included in TI-RTOS as is. It's not our code so we don't make modifications to it but provide it as is. This doesn't mean you can't make changes. Two things:

    1. FatFs by default doesn't enable some of those functions to be built. If you look at the docs for some of the API's for example f_forward, it says at the bottom:

                                "Available when _USE_FORWARD == 1 and _FS_TINY == 1"

      In ffconf.h which in TI-RTOS can be found in <TI-RTOS_INSTALL_DIR>/products/bios_6_41_00_26/packages/ti/sysbios/fatfs you can set the _USE_FORWARD, _FS_TINY and _USE_STRFUNC values as you want. You'll have to rebuild the TI-RTOS libraries after making this change. If you need steps on how to re-build TI-RTOS, see chapter of the TI-RTOS Users Guide.

    2. I looked into some of the functions you listed above and they are new functions added to FatFs. The version we include in TI-RTOS (v0.08a) unfortunately doesn't have these functions. You can look in ff.h to see what functions are available in v0.08a. We test TI-RTOS with v0.08a so all bets are off with the more recent ones. However I encourage you to try replacing the fatfs sources: ff.c, ff.h, ffconf.h and integer.h (don't replace diskio.h/c in TI-RTOS) and rebuild TI-RTOS and see if it works for you. You can always revert back to v0.08a if anything goes wrong.

    Let me know if this helps.

    Moses 

  • Hi Moses,

    How to access (creation & Reading) long file names in TI-RTOS using FatFs.
    Like file name 1234567890.txt

    Thanks,

    Srinivas M
  • Hi Srinivas,
    For Long file names support, you'll have to set _USE_LFN in ffconf.h to be > 0. See the link below for more about this:

    elm-chan.org/.../filename.html

    Regards,
    Moses