+ Post New Thread
Page 1 of 2 1 2 LastLast
Results 1 to 20 of 28
  1. #1
    Full Member level 2
    Points: 1,192, Level: 7

    Join Date
    Mar 2016
    Posts
    147
    Helped
    0 / 0
    Points
    1,192
    Level
    7

    FAT file system issue while reading the file

    Hi All,

    I need a suggestion cum help over the issue regarding the FAT file system in Renesas.

    I am using sample program given when I bought RX111 RSK board. The sample program is for MASS storage of USB host. The program is working properly. I am able to create a text file in pen drive and able to read also. Now thing is that , I have saved .cpmld file inside the pendrive and tried to read that file. The file open function which is normaly gives "TFAT_FR_OK" as a return value is giving TFAT_FR_INVALID_NAME.

    The .cpmld is basically binary file. Please suggest cum help me as I have to read that file and process the file data through micro controller according to my requirement.

    Please help me.

  2. #2
    Super Moderator
    Points: 77,851, Level: 68
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    15,776
    Helped
    3592 / 3592
    Points
    77,851
    Level
    68

    Re: FAT file system issue while reading the file

    Hi,

    Find out if the problem is
    1) write by RSK board
    2) read by RSK board

    with the folowing tests:

    ****
    can you read the file from the pen drive with a PC?

    What is the exact full path and filename? (Take care of capaitals)

    ****
    Can you create a similar file with the PC on the pen drive?
    Then try to read this file with your RSK board.
    How does it behave? Eventually give the error code/description.

    ***********
    Please do the tests step by step and give detailed information on each step.

    Klaus



  3. #3
    Full Member level 2
    Points: 1,192, Level: 7

    Join Date
    Mar 2016
    Posts
    147
    Helped
    0 / 0
    Points
    1,192
    Level
    7

    Re: FAT file system issue while reading the file

    Dear KluasSt,

    Its good to find your response as you are one of the best quick re-sponsor here. Appreciated too.

    Please let me clear my points so that you can understand the issue clearly.

    I have that sample code and it runs fine. If I put .txt file by writing "Hello World" in pendrive and connected pendrive to the board and run the program. The data can be successfully read by me. But once I put .cpmld file in pd with some data and run program followed by connecting it to board ,then I am unable to read the data. .cmpld is basically a binary file. I am able to read the .cmpld file while the pendrive is connected to the PC.

    Hope you are clear with the issue. Awaiting for your resolution message.



    •   AltAdvertisement

        
       

  4. #4
    Super Moderator
    Points: 77,851, Level: 68
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    15,776
    Helped
    3592 / 3592
    Points
    77,851
    Level
    68

    Re: FAT file system issue while reading the file

    Hi,

    follow my instructions of post#2.

    Klaus



  5. #5
    Full Member level 2
    Points: 1,192, Level: 7

    Join Date
    Mar 2016
    Posts
    147
    Helped
    0 / 0
    Points
    1,192
    Level
    7

    Re: FAT file system issue while reading the file

    Find out if the problem is
    1) write by RSK board
    2) read by RSK board

    with the folowing tests:

    ****
    can you read the file from the pen drive with a PC?

    What is the exact full path and filename? (Take care of capaitals)

    ****
    Can you create a similar file with the PC on the pen drive?
    Then try to read this file with your RSK board.
    How does it behave? Eventually give the error code/description.

    ***********
    Please do the tests step by step and give detailed information on each step.
    I am concern with reading part only still I have done the all tests and here are the results,

    1)

    I am able to read the file from pendrive with a PC.
    the full path is I:\ as the file is in root folder. The file name is text test.Cpmld

    2)

    yes I can create the same file using pc to sd card.
    Yes I am trying to read the file through RSK.
    Its running perfectly. If I use .txt file then fopen(***) function returns TFAT_FR_OK. and if I use .Cpmld file then fopen(***) function returns TFAT_FR_INVALID_OBJECT.

    note: *** means the argument inside the function.

    I have given all the answers sequentially. Please feel free to ask anything.



  6. #6
    Super Moderator
    Points: 52,942, Level: 56

    Join Date
    Apr 2011
    Location
    Minneapolis, Minnesota, USA
    Posts
    12,949
    Helped
    2580 / 2580
    Points
    52,942
    Level
    56

    Re: FAT file system issue while reading the file

    Quote Originally Posted by RenesasT View Post
    The file name is text test.Cpmld
    Could this be a long file name issue? DOS has the conventional 8.3 format for filenames. Eight places for the name, three places for the extension.

    Does the problem occur when your file has a short name?



  7. #7
    Super Moderator
    Points: 77,851, Level: 68
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    15,776
    Helped
    3592 / 3592
    Points
    77,851
    Level
    68

    Re: FAT file system issue while reading the file

    Hi,

    Thanks for the detailed feedback.
    Now we can exclude some error scenarios.

    Brad´s answer is reasonable.

    Try this and give feedback.

    Good luck

    Klaus



  8. #8
    Full Member level 2
    Points: 1,192, Level: 7

    Join Date
    Mar 2016
    Posts
    147
    Helped
    0 / 0
    Points
    1,192
    Level
    7

    Re: FAT file system issue while reading the file

    Dear Brad and klaussT,

    Thanks for being with me.

    What to do to reduce the name. I have another file which is abc.jc5 and it is also giving the same issue.

    I am writting the correct file names in the fopen function, the text files i.e. ".txt" files can be able to read.

    Awaiting for your suggestions.



  9. #9
    Super Moderator
    Points: 77,851, Level: 68
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    15,776
    Helped
    3592 / 3592
    Points
    77,851
    Level
    68

    Re: FAT file system issue while reading the file

    Hi,
    In your post#1:
    file open function which is normaly gives "TFAT_FR_OK" as a return value is giving TFAT_FR_INVALID_NAME.
    In your post#5:
    fopen(***) function returns TFAT_FR_INVALID_OBJECT.
    Two different error messages. We don't know wich one is true.
    Please clarify.

    ****
    Did you properly close the file?
    Did you properly unmount?

    ****
    Post the code you refer to.
    What exact library do you use?

    Klaus



  10. #10
    Full Member level 2
    Points: 1,192, Level: 7

    Join Date
    Mar 2016
    Posts
    147
    Helped
    0 / 0
    Points
    1,192
    Level
    7

    Re: FAT file system issue while reading the file

    Dear klausST,

    Sorry for miss confusion. Let me clarify this. The fopen function always giving TFAT_FR_INVALID_NAME. Basically fread function gives TFAT_FR_INVALID_OBJECT.
    hope its clarified.

    Yes I have closed the file and unmounted it.

    The .txt file is purely working. I am able to read .txt file. Does anything is related to file size?

    Awaiting for your response.

    Have a great day ahead.



    •   AltAdvertisement

        
       

  11. #11
    Super Moderator
    Points: 260,253, Level: 100
    Awards:
    1st Helpful Member

    Join Date
    Jan 2008
    Location
    Bochum, Germany
    Posts
    45,447
    Helped
    13828 / 13828
    Points
    260,253
    Level
    100

    Re: FAT file system issue while reading the file

    The fopen function always giving TFAT_FR_INVALID_NAME. Basically fread function gives TFAT_FR_INVALID_OBJECT.
    Makes sense. You can't read a file that wasn't opened before.

    Unfortunately the discussion is almost useless without detail information about the FAT software.

    Hopefully, the error messages mean what they say. INVALID_NAME should be expected to complain about an illegal filename (e.g. not corresponding to the DOS 8.3 format). Possibly it could also indicate a problem with the directory entry. Starting with a freshly formatted pen drive with only supported file names seems reasonable.



  12. #12
    Full Member level 2
    Points: 1,192, Level: 7

    Join Date
    Mar 2016
    Posts
    147
    Helped
    0 / 0
    Points
    1,192
    Level
    7

    Re: FAT file system issue while reading the file

    Dear FVM ,

    Its not useless.

    I am using chan library of filesystem.

    I am able to read .txt,.xls,.dat file. but still, I have .cpmld and .jc5 files to read which are unable to read.

    What extra information you need, please let me know. I will sincerely give it to you.

    thanks.



  13. #13
    Super Moderator
    Points: 77,851, Level: 68
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    15,776
    Helped
    3592 / 3592
    Points
    77,851
    Level
    68

    Re: FAT file system issue while reading the file

    Hi,

    The fopen function always giving TFAT_FR_INVALID_NAME.
    If there alwyas is the error "invalid filename" how can you read .txt files?
    ****

    Basically fread function gives TFAT_FR_INVALID_OBJECT.
    hope its clarified.
    always, too?
    ****

    I have .cpmld and .jc5 files to read which are unable to read.
    Unable to read or unable to open?
    ****

    What extra information you need, please let me know. I will sincerely give it to you.
    --> As I wrote before:
    Post the code you refer to.
    ***

    Did you read documentation about filenames:
    _USE_LFN
    This option switches the support for long file name (LFN). When enable the LFN, Unicode support functions option/unicode.c need to be added to the project. The working buffer occupies (_MAX_LFN + 1) * 2 bytes and additional 608 bytes when exFAT enabled.
    Klaus

    - - - Updated - - -

    Added:

    please read: http://elm-chan.org/fsw/ff/en/config.html
    ...and show us your config.

    Klaus



  14. #14
    Full Member level 2
    Points: 1,192, Level: 7

    Join Date
    Mar 2016
    Posts
    147
    Helped
    0 / 0
    Points
    1,192
    Level
    7

    Re: FAT file system issue while reading the file

    Dear KlausST,

    Let me give you all answers.

    If there alwyas is the error "invalid filename" how can you read .txt files?
    I am pointing the same. I can able to read .xls,.txt,.dat files but unable to read .cpmld,.jc5 files which are binary files. I have used word "always" which one for those binary files not for read.txt file.

    always, too?
    Its because of fopen file is giving error. Until and unless file is not opened its not be able to read.

    Unable to read or unable to open?
    Both unable to open and unable to read. Without opening file it will not read.

    --> As I wrote before:
    I am giving the code for opening and writing as below.
    Code:
     if( usb_ghmsc_open == USB_E_OK )
            {
            	///////res = R_tfat_f_rename("CAMAY_RDR-413.jc5", "am.jc5");
    
    
            	usb_ghmsc_SmpAplProcess = USB_HMSC_FILEREAD;
                /* File open in read mode */
                res = R_tfat_f_open(&file, "ko.jc5", (TFAT_FA_OPEN_ALWAYS | TFAT_FA_READ));
                if( res != TFAT_FR_OK )
                {
                }
                else
                {
                    /* File access LED control. Shift LED position each successful 100 file reads. */
                    ++usb_sLedwork1;
                    if( usb_sLedwork1 > 100 )
                    {
                        usb_sLedwork1 = 0;
                        /* usb_sLedwork2 = 1,2,4,8 */
                        if( usb_sLedwork2 > 15 )
                        {
                            usb_sLedwork2 = 1;
                        }
                        /* RSK LED ON output shift in order; LED0 LED1 LED2 LED3. */
                        usb_cpu_led_set_data(usb_sLedwork2);
    
                        /* Shift LED ON position. */
                        usb_sLedwork2 = usb_sLedwork2 << 1;
                    }
                }
    
                /* Move pointer in file object. */
                res = R_tfat_f_lseek(&file, 0);
                if( res != TFAT_FR_OK )
                {
                }
    
                /* Read data from file. */
                res = R_tfat_f_read(&file, Rusb_gBuf, sizeof(Rusb_gBuf), &file_rw_cnt);
                if( res != TFAT_FR_OK )
                {
                    usb_shmsc_demo_state = USB_TRANSFER_STOP;
                    file_err = USB_E_ERROR;
                }
    
                for( i = 0; i < file_rw_cnt; ++i )
                {
                }
    
                /* Close the file object. */
                res = R_tfat_f_close(&file);
                if( res != TFAT_FR_OK )
                {
                }


    Did you read documentation about filenames:
    I have searched LFN in my code and I got this

    Code:
    #define TFAT_AM_LFN	0x0F	/* LFN entry */.



  15. #15
    Super Moderator
    Points: 77,851, Level: 68
    Achievements:
    7 years registered
    Awards:
    Most Frequent Poster 3rd Helpful Member

    Join Date
    Apr 2014
    Posts
    15,776
    Helped
    3592 / 3592
    Points
    77,851
    Level
    68

    Re: FAT file system issue while reading the file

    Hi,

    Did you read documentation about filenames:
    I have searched LFN in my code and I got this

    Code:

    Code:
    #define TFAT_AM_LFN	0x0F	/* LFN entry */.
    --->It seems yo did not read the documentation.
    --->Please do this first.

    ****
    As FvM explained: If f_open gives an error, then it makes no sense to try to read the file.

    Debug it step by step: First "f_open". So please don´t talk about "f_read" as long as the "f_open" problem is not solved.

    Klaus



  16. #16
    Full Member level 2
    Points: 1,192, Level: 7

    Join Date
    Mar 2016
    Posts
    147
    Helped
    0 / 0
    Points
    1,192
    Level
    7

    Re: FAT file system issue while reading the file

    Absolutely KluasST,

    Exactly the same point I am trying figure out. I am able to open and read all other files except .jc5 and .cpmld files.

    Dont know why. But i will read LFN doc. Please tell me something quick about it. Dont mind.



  17. #17
    Super Moderator
    Points: 52,942, Level: 56

    Join Date
    Apr 2011
    Location
    Minneapolis, Minnesota, USA
    Posts
    12,949
    Helped
    2580 / 2580
    Points
    52,942
    Level
    56

    Re: FAT file system issue while reading the file

    Just one more possibility...

    Have you examined your file Attributes? These could have a part. (The DOS command ATTRIB followed by the filename.) Attributes include System, Hidden, Read only, Archive.

    File recognition problems might arise from a certain attribute (or combination of them). Are you certain your file-creating code doesn't set certain attributes by default?



  18. #18
    Full Member level 2
    Points: 1,192, Level: 7

    Join Date
    Mar 2016
    Posts
    147
    Helped
    0 / 0
    Points
    1,192
    Level
    7

    Re: FAT file system issue while reading the file

    Dear Brad,

    How to examine file Attributes?

    Dear Brad and KlausST,

    Let me tell you the point on which I worked :

    1) I searched for LFN and let me tell you, the renesas programs doesn't support LYN.

    2) I got solution for opening file as now there is no TFAT_FR_INVALID_NAME error. What I did is, I found the short naming for files and tried to open the files. The files are opened succesfully.

    3) when I am going to read file then the return value from fuction is successful but there is no data in my array.

    Please need your help.



  19. #19
    Super Moderator
    Points: 52,942, Level: 56

    Join Date
    Apr 2011
    Location
    Minneapolis, Minnesota, USA
    Posts
    12,949
    Helped
    2580 / 2580
    Points
    52,942
    Level
    56

    Re: FAT file system issue while reading the file

    Quote Originally Posted by RenesasT View Post
    Dear Brad,

    How to examine file Attributes?
    Type ATTRIB and the filename.

    Look for letters h,s,r,a.



    •   AltAdvertisement

        
       

  20. #20
    Super Moderator
    Points: 31,612, Level: 43
    ads-ee's Avatar
    Join Date
    Sep 2013
    Location
    USA
    Posts
    7,311
    Helped
    1719 / 1719
    Points
    31,612
    Level
    43

    Re: FAT file system issue while reading the file

    One suggestion that hasn't been attempted. Rename the file with the *.jc5 or *.Cmpld using a PC to *.txt or *.xls or *.dat. If there is a problem with either of the names having numeric or long extensions that would allow the file to be opened as the file would now have a valid name.

    The opposite test is take a file that does open and read like a *.txt file and change it's name to *.jc5 and *.Cmpld and see if it is no longer readable with those extensions.



--[[ ]]--