MFS Create Directory issue

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

MFS Create Directory issue

1,158 Views
guillaumetiffin
Contributor III

Hello,

I'm using the MFS stack with MQX 4.0.

I have an issue with the stack. When I create a directory (just one subdirectory), it takes several seconds (2 or 3 seconds).

The SD card is a recent SD card and I have no issue in writting or reading the files.

I can't use an other version of MQX.

The instruction that takes time is : error_code = ioctl(filesystem_handle, IO_IOCTL_CREATE_SUBDIR, _DirectoryName);

Is it normal that a creation of directory takes so much time? How can I do it faster?

Can you help me?

This is a part of my code if it's usefull :

char * _DirectoryName;

_DirectoryName = strtok(_str, "\\");

while(_DirectoryName != NULL)

        {                       

            error_code = ioctl(filesystem_handle, IO_IOCTL_CHANGE_CURRENT_DIR, _DirectoryName);

           

            if(error_code == FS_PATH_NOT_FOUND)

            {

                error_code = ioctl(filesystem_handle, IO_IOCTL_CREATE_SUBDIR, _DirectoryName);

                error_code = ioctl(filesystem_handle, IO_IOCTL_CHANGE_CURRENT_DIR, _DirectoryName);

            }

           

            _DirectoryName = strtok(NULL, "\\");

        }

Regards,

Guillaume

Labels (1)
0 Kudos
5 Replies

716 Views
RadekS
NXP Employee
NXP Employee

For MQX up to MQX 4.1.1 we know about issue in case when disk contains too many entries (thousands files or directories). In that case searching is going be pretty slow.

So, question is how many files/subdirectories you have in this directory?

This issue was fixed in reworked MFS in MQX4.2.

What about second or third subdirectory creation? It is also slow?

Problem could be caused by in force (violently) disconnection of card. In that case, next free sector isn’t known and searching could take some time. It also depends on card occupancy.

How long is new subdirectory name?

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

716 Views
guillaumetiffin
Contributor III

Hi,

The creation of the directory takes time even when ther is no subdirectory or file.

The length of the subdirectory name is 12 characters.

It seems to take time each time that I create a directory.

There is only two levels of directory. My directory tree looks like "/Main/Secondary directory"

The SD card is not removed violently.

I can't migrate on the version 4.2 of MQX. So I can't compare the performances.

Regards,

Guillaume

0 Kudos

716 Views
RadekS
NXP Employee
NXP Employee

Hi Guillaume,

I tested MQX 4.0.2.2 MFS sdcard example code at my TWR-K70F120M board and creating directory works fine on my side – without any unusual delay.

I created Main directory at SD card and test your code with added time measurement.

My result was 87miliseconds for creating subdirectory:

char * _DirectoryName;

char _str[] = "/Main/Secondary123";

TIME_STRUCT start_time, end_time, diff_time;

                    _time_get(&start_time);

_DirectoryName = strtok(_str, "\\");

while(_DirectoryName != NULL)

{                    

                                error_code = ioctl(filesystem_handle, IO_IOCTL_CHANGE_CURRENT_DIR, _DirectoryName);

                                if(error_code == FS_PATH_NOT_FOUND)

                                {

                                    error_code = ioctl(filesystem_handle, IO_IOCTL_CREATE_SUBDIR, _DirectoryName);

                                    error_code = ioctl(filesystem_handle, IO_IOCTL_CHANGE_CURRENT_DIR, _DirectoryName);

                                }

_DirectoryName = strtok(NULL, "\\");

}

_time_get(&end_time);

_time_diff(&start_time, &end_time, &diff_time);

printf("Time to create 1 subdirectory: %ld sec %ld millisec\n", diff_time.SECONDS, diff_time.MILLISECONDS);

printf ("directory created \n");

Could you please test different SD card or test it on some supported evaluation board for excluding any side effects?

If directory already exist, it returns in 1 millisecond.

Could you please specify exact version of your MQX and whether you use SPI or ESDHC driver for SD card?

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!
-----------------------------------------------------------------------------------------------------------------------

716 Views
guillaumetiffin
Contributor III

Hi,

Thank you for your suggestion and your test.

I have done the same test on my custom board.

The diff time returns 1 second 380 milliseconds.

I forgot to precise that I have an interruption each 5ms with some calculation. So I think that it could take times.

I will try with a faster SDCard.

Regards,

Guillaume

0 Kudos

716 Views
RadekS
NXP Employee
NXP Employee

Hi Guillaume,

You are right. That is only option what sounds reasonable in this case.

Is it possible that there running some high priority task/interrupt which slows down your ioctl command.

On other side, you wrote, that read and write works correctly… so,I am not sure.

If you use SPI interface for SD card, communication with card will be slower, but difference between 87ms and 1380ms is too big. There will be probably something else.

Please test also your SD card with simple sdcard example code (in MFS directory). You just place code for creating directory after command: printf ("SD card installed to %s\n", filesystem_name);

This way, we can test your SDcard without influence of additional software.

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