USB Mass Storage Host - speed

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

USB Mass Storage Host - speed

1,943 Views
martindusek
Contributor V

Hello,

I get only 25 kb/s transfer speed from TWR-K70 (full speed usb module used) to 2GB Flash stick (FAT32, 512 b allocation unit). Several different sticks used.

My program is derived from msd_mfs_generic_test - no changes made to the project, only transfer speed benchmark added to it.

The transfer speed is measured at disk_write() function - its takes 20 ms to execute it. Every call writes one sector (512) so the transfer speed is 25 kb/s.

I have no clue how to speed it up...

Thanks

Labels (2)
Tags (3)
0 Kudos
10 Replies

1,101 Views
martindusek
Contributor V

Nobody has problems with such a lazy USB mass storage host? We need to transfer a huge amount of data and with 25 kb/s speed it will last a century.

Can you please provide some tips how to tune the host to achieve at least 100 kb/s?

0 Kudos

1,101 Views
JerryFan
NXP Employee
NXP Employee

It is very likely that the cache policy of your FAT is “write through”, and this will result many FAT flush which decrease the data rate very much. Please change it to "write back" using iotcl(mfs, IO_IOCTL_SET_FAT_CACHE_MODE, &para) with para = MFS_WRITE_BACK_CACHE. I tested this on twrk60d100m, the write speed got much faster, 100KB/s vs 25KB/s.

0 Kudos

1,101 Views
ava
Contributor II

Hi Chongbin,

I am using kinetis MK60FX512VLQ12 controller, CW10.6 and MQX4.1.

For USB I have checked the FAT cache policy is "write through" as you said but how to change it to "write back" to increase speed.

I have checked but didn't get in which file I have to change it.

Please let me know where I have to change "write through" to "write back".

Thanks.

0 Kudos

1,101 Views
JerryFan
NXP Employee
NXP Employee

TonyLiu, could you help on this, please?

0 Kudos

1,101 Views
yichangwang-b49
NXP Employee
NXP Employee

For changing the “write through” to “write back” in MQX4.1

  typedef enum {

MFS_WRITE_THROUGH_CACHE=0,    // No write caching (only read caching)

MFS_MIXED_MODE_CACHE=1,       // Write Caching allowed on file write only

MFS_WRITE_BACK_CACHE=2        // Write Caching fully enabled

} _mfs_cache_policy;

For the example mfs_usb in the path “mfs\examples\mfs_usb”:

You can change the file USB_File.c line 300.

From

msd_dev_data->FS_FD_PTR[part] = msd_assign_drive_letter(msd_dev_data->PM_FD_PTR[part], msd_dev_data->FS_NAME[part], mountp);

            if (msd_dev_data->FS_FD_PTR[part] != NULL) {

printf("Partition %d installed as %s\n", part, msd_dev_data->FS_NAME[part]);

            }

To

msd_dev_data->FS_FD_PTR[part] = msd_assign_drive_letter(msd_dev_data->PM_FD_PTR[part], msd_dev_data->FS_NAME[part], mountp);

            if (msd_dev_data->FS_FD_PTR[part] != NULL) {

                printf("Partition %d installed as %s\n", part, msd_dev_data->FS_NAME[part]);

_mfs_cache_policy param = MFS_WRITE_BACK_CACHE;

_io_ioctl(msd_dev_data->FS_FD_PTR[part], IO_IOCTL_SET_FAT_CACHE_MODE, &param);

                _io_ioctl(msd_dev_data->FS_FD_PTR[part], IO_IOCTL_WRITE_CACHE_ON, NULL);

            }

0 Kudos

1,101 Views
praveenhegde
Contributor I

Hi Chongbin,

I am using the MFS_USB example from MQX. How to understand the present or default cache policy for FAT? If I want to modify it to WRITE_BACK how to change it?

Thanks,

Praveen

0 Kudos

1,101 Views
martindusek
Contributor V

I'm quite sure, that my problem is not caused with the cache policy. I have to repeat, that I measure speed of disk_write() function - it takes 20 ms to execute it. As it writes buffers of 512 bytes, I can't ever get speed faster than 512/0.02 = 25kb/s.

Please can you provide your project with complete source code?

0 Kudos

1,101 Views
niallmcnamara
Contributor I

I'm having the same issue but haven't even gotten the 512 byte packets to work. I'm using the

C:\Freescale\MQX\4.0\usb\device\examples\msd

example also on the TWR-K70. I'm only seeing 7ish kb/s and also see data loss. I want to reliably (and faster than 20+ minutes) upload a firmware file on about 10MB. I tried the MFS_WRITE_BACK_CACHE mode and IO_IOCTL_FAT_CACHE_ON ioctl modes which didn't improve my rate.

How did you get to 512 packet size? I tried to edit the usb_descriptor.h file to enable it but was not able to get the USB to enumerate anymore.

0 Kudos

1,101 Views
martindusek
Contributor V

512 bytes packet size was default setting in my msd_mfs_generic_test project.

0 Kudos

1,101 Views
niallmcnamara
Contributor I

Oh and I'm trying to write to an SD card.

0 Kudos