Slow in USB Mass Storage Detection

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

Slow in USB Mass Storage Detection

1,213 Views
pramodk_g_
Contributor III

Hi All,

I am woroking with K70 on a custom board.I have modified the USB Mass storage example code SD card and working fine. The change I made is

From

case USB_MSC_DEVICE_READ_REQUEST :         
    lba_data_ptr = (PTR_LBA_APP_STRUCT)val;
    #if RAM_DISK_APP
        USB_mem_copy(g_disk.storage_disk + lba_data_ptr->offset,
                lba_data_ptr->buff_ptr,
                lba_data_ptr->size);
    #endif        
    break;
case USB_MSC_DEVICE_WRITE_REQUEST :
    lba_data_ptr = (PTR_LBA_APP_STRUCT)val;
    #if RAM_DISK_APP
    USB_mem_copy(lba_data_ptr->buff_ptr,
                    g_disk.storage_disk + lba_data_ptr->offset,
                    lba_data_ptr->size);
    #endif                         
    break;

TO

case USB_MSC_DEVICE_READ_REQUEST :   

    lba_data_ptr = (PTR_LBA_APP_STRUCT)val;

    fread(lba_data_ptr->buff_ptr, 1, 1, filesystem_handle);

    break;

case USB_MSC_DEVICE_WRITE_REQUEST :

    lba_data_ptr = (PTR_LBA_APP_STRUCT)val;

    fwrite(lba_data_ptr->buff_ptr, 1, 1, filesystem_hanlde);

    break;

The problem I am facing is it very slow for USB detection and data transfer with PC. Please let me know what I can do for speed transfer, currently it is 100kbps.

Thanks,

Pramod.

Tags (3)
3 Replies

617 Views
soledad
NXP Employee
NXP Employee

Hi,

First all I would like to apologize for the long delay on getting back to you.  Regarding your inquiry, the slow performance of the demo is not caused by slow USB performance, no matter using full or high speed USB module. It's because in the mfs-usb demo, it only read and write 512bytes at a time, this is not efficient.

The read and write API will cause underlying USB stack to issue UFI read10 commands for data transfer. Please try to increase the data buffer size and read more at a time, this will help improve performance.

buffer = _mem_alloc(COPY_BLOCK_SIZE); // COPY_BLOCK_SIZE is 512

  if (buffer == NULL) {

  printf("Warning, unable to allocate copy buffer, copy will be slower\n" );

  copysize = sizeof(buffer);

  copybuffer= &buffer;

  } else {

  copysize = COPY_BLOCK_SIZE;

  copybuffer= buffer;

  }

  do {

  size = read(in_fd, copybuffer, copysize);

  if (size > 0) {

  wsize = write(out_fd, copybuffer, size);

  }

  else

  break;

  } while (wsize == size);

I hope this helps !!


Have a great day,
Sol

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

0 Kudos

617 Views
pramodk_g_
Contributor III

Thanks soledad for the fat reply,

Sorry for the confusion I have not used mfs-usb demo for this, I made this code from USB device Mass storage and SD card examples. Initially the USB example make RAMDISK as mass storage and I changed that for SD card. So please let me know what I can do for improving the Speed.

Thanks,

Pramod.

0 Kudos

617 Views
soledad
NXP Employee
NXP Employee

Hello Pramod,

Sorry for my long delay. The USB MFS mass storage link driver usbmfs.c uses around 20 secs( USBCFG_MFS_LWSEM_TIMEOUT ) timeout in the read, write and open functions. The mentioned timeout could be reduced by changing the macro and recompiling the USB libraries of MQX. The result will be that the timeout will be less, and it is possible that some USB sticks that are currently compatible (with long response times), will not be compatible anymore. However, it could also improve the response of the system for a faster reply when the MSD device is not compatible.


Have a great day,
Sol

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

0 Kudos