Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

FAT file system issue while reading the file

Status
Not open for further replies.

RenesasT

Full Member level 2
Full Member level 2
Joined
Mar 11, 2016
Messages
149
Helped
0
Reputation
0
Reaction score
0
Trophy points
16
Activity points
1,330
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.
 

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
 

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.
 

Hi,

follow my instructions of post#2.

Klaus
 

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.
 

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
 

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.
 

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
 

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.
 

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.
 

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.
 

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:
...and show us your config.

Klaus
 

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 */.
 

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
 

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.
 

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?
 

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.
 

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.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top