The question about MFS in the MQX

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

The question about MFS in the MQX

Jump to solution
573 Views
小勇邹
Contributor II

              

1.The file “data.txt” is  created in the SD card the windows 7. The address is E:\ data.txt

              

2.The SD card is inserted to the TWRK64F120M.

The example C:\Freescale\Freescale_MQX_4_1_TWRK64F120M\mfs\examples\sdcard\build\iar\mfs_sdcard_twrk64f120m

is used to access the file “data.txt”.

The source code is shown below and the red part is the one to access file data.txt.

            

                    filesystem_handle = fopen(filesystem_name, NULL);
                    error_code = ferror(filesystem_handle);
                    if (error_code == MFS_NOT_A_DOS_DISK)
                    {
                        printf("NOT A DOS DISK! You must format to continue.\n");
                    }
                    else if (error_code != MFS_NO_ERROR)
                    {
                        printf("Error opening filesystem: %s\n", MFS_Error_text((uint32_t)error_code));
                        continue;
                    }
                   
                   
                    if(filesystem_handle!=NULL)
                    {printf ("SD card installed to %s\n", filesystem_name);}
                    if (readonly)
                    {
                        printf ("SD card is locked (read only).\n");
                    }
                          
                    userfile_ini=fopen("a:\\data.txt", NULL);

The a: is installed successfully.The userfile_ini is always is null.The data.txt can not be openned.

What is the resason?

Remark: The hardware is K64 and the OS is Freescale_MQX_4_1_TWRK64F120M.

               The SD card is  kingston 4G. File system is FAT32.

Labels (1)
0 Kudos
1 Solution
306 Views
RadekS
NXP Employee
NXP Employee

Hi Robin,

When you want open file, you should say in which mode you want to open this file.

For example:

fopen("a:data.txt", "w+")

For more details, please check fopen description in MQX MSF User Guide.

Available modes are:"w", "w+", "r", "r+", "r", "a", "a+", "n", "n+".

If you use MQX older than version 4.2 (or KSDK1.2), please try avoid to use append mode ("a", "a+").

There is bug. More details: Re: MFS - file access error

I hope it helps you.

Have a great day,
RadekS

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

View solution in original post

0 Kudos
1 Reply
307 Views
RadekS
NXP Employee
NXP Employee

Hi Robin,

When you want open file, you should say in which mode you want to open this file.

For example:

fopen("a:data.txt", "w+")

For more details, please check fopen description in MQX MSF User Guide.

Available modes are:"w", "w+", "r", "r+", "r", "a", "a+", "n", "n+".

If you use MQX older than version 4.2 (or KSDK1.2), please try avoid to use append mode ("a", "a+").

There is bug. More details: Re: MFS - file access error

I hope it helps you.

Have a great day,
RadekS

-----------------------------------------------------------------------------------------------------------------------
Note: If this post answers your question, please click the Correct Answer button. Thank you!
-----------------------------------------------------------------------------------------------------------------------

0 Kudos