• Join
  • Sign In with my.TI Login
Texas Instruments
  • Products
  • Applications
  • Tools & Software
  • Support & Community
  • Sample & Buy
  • About TI
Sample & Purchase Cart Sample & Purchase Cart
  • Search
  • Advanced
TI E2E™ Community
  • Support Forums
  • Blogs
  • Groups
  • Videos
  • 简体中文
  • More ...
TI Home » TI E2E Community » Support Forums » Embedded Software » BIOS » BIOS forum » FATFS and long file name
Share
BIOS
  • Forum
  • Announcements
Options
  • Subscribe via RSS

FATFS and long file name

FATFS and long file name

This question is answered
cobsonchael
Posted by cobsonchael
on Sep 07 2012 15:55 PM
Expert1970 points

Does the version of FATFS that SYS/BIOS has in it support long file name? i tried to define "_USE_LFN" but i think i would have to rebuild sys bios for that....is that correct?

also, when i try to do an fopen("file.bla", "r") it seems it requires me to add the "fat:1:" prefix to the file. otherwise it wont let me open it. is there a reason for this when i am trying to open a file in the root directory?

Report Abuse
  • Reply
You have posted to a forum that requires a moderator to approve posts before they are publicly available.
All Replies
  • Tom Kopriva
    Posted by Tom Kopriva
    on Sep 07 2012 18:20 PM
    Expert6570 points

    Hi cobsonchael,

    cobsonchael
    Does the version of FATFS that SYS/BIOS has in it support long file name? i tried to define "_USE_LFN" but i think i would have to rebuild sys bios for that....is that correct?

    Long filename support is included with the 3rd party module but we do not test for its functionality with our regression tests.

    cobsonchael
    also, when i try to do an fopen("file.bla", "r") it seems it requires me to add the "fat:1:" prefix to the file. otherwise it wont let me open it. is there a reason for this when i am trying to open a file in the root directory?

    Yes, there is a reason for it. fopen is part of the C standard I/O routine which calls a FatFs API. The C standard I/O library is registered at runtime to the FatFs APIs which is done for you in the FatFS module (FatFS.xdt). The way the C I/O library extracts the "fat:" prefix in the fopen("fat:1:filename", ...) call to determine which hook functions are to be called (ffcio.c). This prefix can also changed but not removed in the FatFS module.

    FatFS.fatfsPrefix = "yourOwnPrefix";

    The remaining string is then passed on to the FatFs API to parse (e.g. f_open("1:filename,)). The FatFs API also parses this prefix to determine which drive it is supposed to access. Here you would include a digit [0-9] followed by a ":". If the string isn't formatted properly, it will assume drive number 0.

    See this User's Guide at section 8.2.

    Thanks,

    Tom

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • cobsonchael
    Posted by cobsonchael
    on Sep 10 2012 08:42 AM
    Expert1970 points

    so how do i enable long file name?

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Tom Kopriva
    Posted by Tom Kopriva
    on Sep 10 2012 14:00 PM
    Expert6570 points

    Hi Cobsonchael,

    ffconf.h in 'ti/sysbios/fatfs' has a few options to enable long file name support.

    The easiest option is to define _USE_LFN to 2. This will place the long file name buffer on your (task) stack keeping it re-entrant. If you don't want to keep this buffer in your stack, you can set _USE_LFN to 3, which gets the buffer from the heap by calling ff_memalloc and ff_memfree (which are both included in memsysbios.c)

    After you change ffconf.h you need to rebuild SYS/BIOS (more specifically, the FatFS module). I'm not sure which version of SYS/BIOS you are using and whether or not your using it with another product (e.g. BIOS PSP) However, in any case there should be a SYS/BIOS User's Guide that explains how to rebuild SYS/BIOS (The latest version can be found here: spruex3k.pdf).

    If you have SYS/BIOS v6.32 or newer you can use LibType_Custom which will create the libraries for you.

    var BIOS = xdc.useModule('ti.sysbios.BIOS');
    BIOS.libType = BIOS.LibType_Custom;

    Thanks,

    Tom

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • cobsonchael
    Posted by cobsonchael
    on Sep 10 2012 14:07 PM
    Expert1970 points

    so what i am understanding is that long file name is not supported by default and that for EVERY SINGLE SYSBIOS version i update to i have to make this change for this to work?

    i tried changing the file and making my .cfg file to use "custom" but that didn't do anything. it is still defined as 0 as far as the system is concerned. i am using SYSBIOS 6.33.07.53. so it looks like i have to manually compile the library.

    why is this not an option in the SYSBIOS FATFS portion? 

    i would suggest defining the _USE_LFN = 2 by default because, seriously, who is using this thing and limiting the file names to only 8 chars? this isn't 1989.

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • cobsonchael
    Posted by cobsonchael
    on Sep 10 2012 17:14 PM
    Expert1970 points
    FATFSLFNRequired.c

    ok so i was able to rebuild SYSBIOS with the LFN define set to 2

    there are 3 issues i see after that

    1) after i did that i had to come up with 2 functions that controlled the conversion from one file name to another or something to that effect.  ff_convert and ff_wtoupper.  i figured out how to make those (there is no support for this by the way) by downloading the collection of FATFS examples from the website http://elm-chan.org/fsw/ff/00index_e.html i have no idea if those are right. i attached what i have i would like some kind of indication that this is what those functions should be (for american only)

    i can now open files with long file names and read them, though. which is nice

    2) in the FILINFO structure that gets filled in when you do a f_readdir still doesn't recognize the lfn variables.  there are errors that get posted when i compile.  the compile still happens and i get an .out file (which i didn't think you could do. why don't those fields show up when i build the library with _USE_LFN?). i can't use that data apparently....

    THIS LEADS ME #3

    3) i can no longer seem to use the f_readdir to sort through my file system. the long file names do not come out when i try to sort through the files and the whole thing is useless.  this is very important to our project that this functionality works. how do i use f_readdir when using lfn and be able to read the file names? i guess i can try long file name define of 3 or 1 tomorrow....

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Tom Kopriva
    Posted by Tom Kopriva
    on Sep 10 2012 18:24 PM
    Verified Answer
    Verified by David Friedland
    Expert6570 points

    Cobsonchael,

    cobsonchael

    so what i am understanding is that long file name is not supported by default and that for EVERY SINGLE SYSBIOS version i update to i have to make this change for this to work?

    i tried changing the file and making my .cfg file to use "custom" but that didn't do anything. it is still defined as 0 as far as the system is concerned. i am using SYSBIOS 6.33.07.53. so it looks like i have to manually compile the library.

    I just looked into this a bit further. The FatFs API is a 3rd party application which wasn't designed as a RTSC module. So the short story is that we can't build the FatFS module with LibType_Custom without some internal hacks to the build flow. So, you are correct, the only option is to rebuild SYS/BIOS (gmake -f bios.mak)

    I opened a bug to track this feature enhancement (SDOCM00095699) so we can simply use LibType_Custom. When this feature has been implemented, it would make more sense to create some sort of configuration parameter to change items in ffconf.h as they would have to be rebuilt every time something is modified.

    cobsonchael
    i would suggest defining the _USE_LFN = 2 by default because, seriously, who is using this thing and limiting the file names to only 8 chars? this isn't 1989.

    There are 2 reasons to keep LFN disabled by default:

    1. SYS/BIOS is also used with micro controllers will very limited resources (MSP430 and Stellaris M3/M4F's and etc..) and to avoid extra code and ram usage LFN support is kept off by default.

    2. Patent infringement is still an issue today. Before jumping to conclusions, take a look at the FatFs developer's Application Note. He states that you might be required to get a license from Microsoft if you want to use LFN in a commercial product. LFN is kept disabled to avoid this licensing requirement.

    Thanks,

    Tom

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • Tom Kopriva
    Posted by Tom Kopriva
    on Sep 10 2012 19:09 PM
    Expert6570 points

    Cobsonchael,

    This looks like FatFs specific issue for which I'm not familiar with. Have you checked with the FatFs forum?

    Thanks,

    Tom

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
  • cobsonchael
    Posted by cobsonchael
    on Sep 11 2012 09:59 AM
    Expert1970 points
    FATFSLFNRequired.c

    thanks for creating a bug report for this. that will make it at least a little easier to handle

    is it possible, within the cfg file, to make a section in the FATFS to change these settings, but then require a custom library type? like when custom library type was enabled all these FATFS features with then become available. that would solve some headaches i think.

    apparently the issue i was having with the f_readdir went away after i rebooted CCS. apparently the program didn't update a symbol inside itself and was prevent things from being compiled without errors. also, i changed my ff_convert to apply to the default settings in FATFS which is the japanese, not english which seems to make things better as well. i am attaching the file for future individuals who might be looking for this thing as well.

    Report Abuse
    • Reply
    You have posted to a forum that requires a moderator to approve posts before they are publicly available.
TI E2E™ Community
  • Support Forums
  • Blogs
  • Videos
  • Groups
  • Site Support & Feedback
  • Settings
TI E2E™ Community Groups
  • TI University Program
  • Make the Switch
  • Microcontroller Projects
  • Motor Drive & Control
Other Communities
  • Deyisupport
  • Designsomething.org
  • beagleboard.org
  • TI on Element 14
  • TI on TechXchangeSM
Other Technical & Support Resources
  • WEBENCH® Design Center
  • Product Information Centers
  • Technical Documents
  • TI Design Network
  • TI Technical Articles
  • TI Training

All content and materials on this site are provided "as is". TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with regard to these materials, including but not limited to all implied warranties and conditions of merchantability, fitness for a particular purpose, title and non-infringement of any third party intellectual property right. TI and its respective suppliers and providers of content make no representations about the suitability of these materials for any purpose and disclaim all warranties and conditions with respect to these materials. No license, either express or implied, by estoppel or otherwise, is granted by TI. Use of the information on this site may require a license from a third party, or a license from TI.

Content on this site may contain or be subject to specific guidelines or limitations on use. All postings and use of the content on this site are subject to the Terms of Use of the site; third parties using this content agree to abide by any limitations or guidelines and to comply with the Terms of Use of this site. TI, its suppliers and providers of content reserve the right to make corrections, deletions, modifications, enhancements, improvements and other changes to the content and materials, its products, programs and services at any time or to move or discontinue any content, products, programs, or services without notice.

Follow Us Texas Instruments on Facebook Texas Instruments on Twitter Texas Instruments on LinkedIn Texas Instruments on Google+
TI Worldwide | Contact Us | my.TI Login | Site Map | Corporate Citizenship | mobile m.ti.com (Mobile Version)

TI is a global semiconductor design and manufacturing company. Innovate with 100,000+ analog ICs and
embedded processors, along with software, tools and the industry’s largest sales/support staff.

© Copyright 1995-2013 Texas Instruments Incorporated. All rights reserved.
Trademarks | Privacy Policy | Terms of Use