USB OTG Mass Storage Pefromance

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

USB OTG Mass Storage Pefromance

5,615 Views
matthewreynolds
Contributor III

Greetings All,

I am getting sub-par read performance from the USB OTG port of a IMX6Q in host mode.  The g_mass_storage driver is used with a mSATA SSD drive file backing to transfer many large files (up to ninety ~350MB files) from the IMX's to my PC.  However, read transfer rates are around 2-3 MB per second with my expectation for the high speed port to be 20+ MBs.

The software release we are using is the Yocto 3.10.17 dora release.  I checked everything I could think of in the IMX6 system and from what I can tell the drivers are configured for hi-speed 480mps.  It should also be noted that the mSATA SSD drive is formatted as a FAT32.

Mass Storage Setup

unmount /media/sda1

modprobe g_mass_storage file=/dev/sda

The  following is printed after loading the g_mass_storage module.
g_mass_storage gadget: Mass Storage Gadget, version: 2009/09/11
g_mass_storage gadget: userspace failed to provide iSerialNumber
g_mass_storage gadget: g_mass_storage ready

g_mass_storage gadget: high-speed config #1: Linux File-Backed Storage


"lsusb -t" prints
/:  Bus 01.Port 1: Dev 1, class="root_hub", Driver=ci_hdrc/1p, 480M


sys info verifies usb device 1 version is 2.0 and speed is 480 mps
# /sys/bus/usb/devices/usb1/version
2.0

# /sys/bus/usb/devices/usb1/speed
480


The Write and Read performance of the SSD drive using dd commands has been very good at +60MBs so I don't think it is the bottleneck.  Although, I am getting the following errors when reading from the device.  Hopefully this can be cleared up with a reformat and this does not indicate the drive is failing.


ata1.00: status: { DRDY }

ata1: hard resetting link

ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 310)

ata1.00: configured for UDMA/33

ata1: EH complete

ata1.00: exception Emask 0x10 SAct 0x1 SErr 0x280100 action 0x6 frozen

ata1.00: irq_stat 0x08000000, interface fatal error

ata1: SError: { UnrecovData 10B8B BadCRC }

ata1.00: failed command: READ FPDMA QUEUED

ata1.00: cmd 60/00:00:f8:f4:01/01:00:00:00:00/40 tag 0 ncq 131072 in

         res 40/00:04:f8:f4:01/00:00:00:00:00/40 Emask 0x10 (ATA bus error)


Can anyone help explain the slow transfer rates?


Sincerely,

Matthew


Edit:
Mistakenly said SD instead of SSD

Message was edited by: Matthew Reynolds

Tags (3)
0 Kudos
Reply
8 Replies

2,916 Views
EricNelson
Senior Contributor II

Hi Matthew,

I'm not sure how you're measuring, but I'm seeing ~18MB/s using dd:

~/$ sudo dd if=/dev/sdd bs=1M count=20 of=/dev/null

[sudo] password for ericn:

20+0 records in

20+0 records out

20971520 bytes (21 MB) copied, 1.12867 s, 18.6 MB/s

And slightly less copying from a FAT32 partition:

~/$ ls -lh /media/ericn/prodtest/

...

-rw-r--r-- 1 ericn ericn  33M Jun  3 16:17 vivante.squashfs

~/$ time cp -fv /media/ericn/prodtest/vivante.squashfs ./

‘/media/ericn/prodtest/vivante.squashfs’ -> ‘./vivante.squashfs’

You can't really trust either without disabling caching though.

I tested on a Nitrogen6x and this image:

     http://boundarydevices.com/a-very-expensive-sd-card-reader

2,915 Views
matthewreynolds
Contributor III

Eric,

The difference in speed is probably from using a mSATA Solid State Drive (SSD) that is much faster than micro SD cards.  I mistakenly said SD in my first post, which was misleading.

Running the same dd test resulted in 200MB/s (20MB in 0.1 Sec).

20MB read - 200MB/s

time sudo dd if=/dev/sda bs=1M count=20 of=/dev/null

20+0 records in

20+0 records out

real    0m0.099s

user    0m0.010s

sys     0m0.080s

1GB read - 102MB/s

time sudo dd if=/dev/sda bs=1M count=1000 of=/dev/null

real    0m9.737s
user    0m0.000s
sys     0m7.270s

The USB transfer rates were obtained from the file copy dialog boxes on my PC when moving files.

Thanks,
Matthew

0 Kudos
Reply

2,916 Views
EricNelson
Senior Contributor II

Hi Matthew,

Your numbers are obviously for either USB 3.0 or SATA connection (>480 Mbits/s).

The numbers I posted above were through USB 2.0 and the Mass Storage Gadget. Isn't that what you were after?

0 Kudos
Reply

2,916 Views
matthewreynolds
Contributor III

Eric,

Yes, I am seeking to improve the performance of the USB 2.0 and Mass Storage Gadget.  I appologize, but I misunderstood how you used dd.  I ran the command on my IMX system, while I think you ran yours on a linux desktop, which would have tested the USB 2.0 transfer rates.  The 102MBs numbers I got would be only the read rate of the SSD drive through the mSATA connection.  Sorry for the confusion.

I had used Nautilus or Windows Explorer on my desktop to transfer files and the rate was poor.  While my performance numbers of the SSD drive through the mSATA are very good (102MBs), they drop to 2-3MBs through the USB with the g_mass_storage driver.

0 Kudos
Reply

2,916 Views
EricNelson
Senior Contributor II

Just to clarify, my tests were from my laptop (running Ubuntu 14.04) and one of our i.MX6 boards.

The transfer throughput of ~150Mbit/s didn't change much between accessing SD or SATA connected to the Nitrogen6x.

0 Kudos
Reply

2,916 Views
matthewreynolds
Contributor III

Eric,

I may have jumped the gun in marking my answer correct.   My guess is that it is more likely a driver problem.

I have been unmounting the SSD before loading the g_mass storage driver.   This seems to work good the fist time after a reboot, but the speed drops and the following ata errors continuously print as files are read through the USB the second time.

ata1: hard resetting link
ata1: SATA link up 1.5 Gbps (SStatus 113 SControl 310)
ata1.00: configured for UDMA/33
ata1: EH complete
ata1.00: exception Emask 0x10 SAct 0x1 SErr 0x280100 action 0x6 frozen
ata1.00: irq_stat 0x08000000, interface fatal error
ata1: SError: { UnrecovData 10B8B BadCRC }
ata1.00: failed command: READ FPDMA QUEUED
ata1.00: cmd 60/00:00:58:a4:14/01:00:00:00:00/40 tag 0 ncq 131072 in
         res 40/00:04:58:a4:14/00:00:00:00:00/40 Emask 0x10 (ATA bus error)
ata1.00: status: { DRDY }

The speed remains fast and I don't get those errors if I don't unmount however, the IMX file system gets out of sync to any changes done from the PC side.  In other words, after unloading g_mass_storage the IMX does not "see" added or removed by the PC.  The only way I know how to resync the file system is by umounting and remounting the volume, but then I run into the ata errors above.

I am considering doing a sync && reboot like in your article after unloading the g_mass_storage.  This would not be ideal because our system takes around 25 seconds to shutdown and start up.

Do you have any thoughts on how to resync the system or the ata errors?

Best regards,

Matthew

0 Kudos
Reply

2,916 Views
matthewreynolds
Contributor III

Eric,

Thank you again for the test data.

The problem on our board seems to be from a failing drive.  I replaced it with a new one and the speeds jumped up to around 15MB/s, which is close to what you had measured.   Those error messages also stopped with the new drive installed.

Best Regards,

Matthew

0 Kudos
Reply

2,916 Views
SergioSolis
NXP Employee
NXP Employee

Hello,

Sorry, but the information you are requesting is treated as confidential info at this time and requires a signed NDA (Non-Disclosure Agreement). Naturally, we cannot discuss this with you in public anyway, this requires to be handled as a Service Request (SR). Be aware that to give you remote support through a SR, we will still need the confirmation of a Freescale employee that the NDA is in place. If you want to go this route, the next steps will be: If you have already signed a NDA agreement for this product, please contact the person who assisted you or create a SR and name us a Freescale person that can confirm this. If you have not signed an agreement, please contact your local Freescale Distributor Salesperson or FAE for assistance. For a listing of our distributors, refer to: http://www.freescale.com/webapp/sps/site/overview.jsp?code=DISTRIBUTORS

Best regards,
Sergio

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

0 Kudos
Reply