This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Stellaris Lm4f232 USB MASS STORAGE using SD card transfer speed issue

Other Parts Discussed in Thread: MSP430F5529

Hi All,

I wanted to develop a SD card reader application. I evaluated the existing stellarisware application under eklm4f232/usbdevmsc. I tested it by transferring aroung 10MB of data using 2GB SD card. I observed the speed to be very slow (around 64KB/sec under windows 7) though the chip was opearting at 50Mhz. 

Is there any dependency of read/write speed related to card sector size, FAT file system???. How shall I increase the overall transfer speed compared to the SD card readers in market.

Regards,

Harshit

  • Harshit,

    I don't know how much of an impact the sector size or file system would have on write speed.

    The SPI interface between the LM4F232 and the SD card is limited to 12.5 Mb/s. Can you probe SPICLK to make sure that SPI is correctly configured and the clock is running at 12.5 MHz?

    Have you tried to performance profile the code to see where the bottleneck is? The code to update the display will be slow, but it should not be called often.

  • Hi John,

    I tried commenting the display update code. But no change in data transfer speed of SD card. Also I changed the SPI clock to 25Mhz since system clock is at 50Mhz. But no change too.

    Any idea how to boost the speed to bring it to the level of sd card reader available in Laptops. Can i achieve higher data transfer speed. Do i need to port FAT file system other than available.Has anyone tested this application for speed.

    I was thinking of evaluating the sd card application available with MSp430F55xxx USB series devices to check for data throughput....

    Thanks and Regards,

    Harshit 

  • Hi,

    The speed is set initially at 400KHz and then set to maximum speed in the function set_max_speed() in the file SW\third_party\fatfs\port\mmc-ek-ln4f232h5qd.c, but this function is called in line 468 if the variable ty has some non-zero value. Use a breakpoint at this line and see the value of ty - if zero it means some initialization problem(s). You must check.

    Petrei

  • Harshit,

    I tested a LM4F232 with a 1GB SD card and got similar results. I increased the SPI clock to 25 MHz also and saw no speed increase. I used a debugger to verify that the SPI clock scaling registers had been set to their 12.5 and 25 MHz values, not 400KHz.

    I saw the read speed go up to 300 KB/s so the SPI interface and USB transfer overhead is not the bottleneck. Look at the "Optimization of Write Performance" section of this page by the FatFS creator. If you have a lot of writes that are smaller than the SD card's erase block size, it can seriously impact performance.

  • Hi John,

    I verified the ty variable is non zero and the setmax speed function too is executed. I tested this with 2Gb sandisk micro sd card.

    Thanks for your valuable feedback. yes even I get the same amount of read speed. But I am looking for matching it to the level of the local card readers say around 2MB/sec upto 9MB/sec sometimes. I am currently going through blocks of code and could find that the application always issued single read or single write instead of multiple write or multiple read, thought that the multiple commands would increase speed. 

    One can notice sluggishness if one try to play a mp3 file directly from sd card on PC. Track seeking takes more time. Also If i try to abort the data transfer in between then application doesnt handle it well. Can I achieve high read and write speeds using the Tiva series controller. The max speed the SD card allows would be 25Mhz

    Thanks and Regards,

    Harshit

  •  Hi, the speed of card you report is the max data speed 25Mbps or 25MHz clock speed?

     SD card controller access data thru all 4 bit interface and not in simple SPI mode, to get max performance you need an sd controller but Stellaris has not SD controller on chip so reduced performance are to be accepted, also 64KB/s is smaller than worst SD can do, I don't know the application are you using and how it is emulated but lack of performance can derive from slow response to request or some overhead you need test from where it come..

     Try at first measure read performance from SD then USB transfer speed separated. Are buffer large enough to not block the two processes?

  • Hi Roberto,

    I reported about the max speed of SPI clock that SD card specification mentioned is about 25Mhz.

    As far as my application is concerned, I am trying to develop an USB SD card reader. So it would be a generic SD card reader u find in Laptops with transfer speeds upto MB/s. I shortlisted tiva series controllers cortex-M4 and MSP430F5529 controllers to realize this and hence started with evaluating sample application but from above discussions it seems I mite not be able to achieve speeds upto MB/sec since the USB support for tiva series is upto 12Mbps. Whether USB support upto 480Mbps would help in improving performance???

    Hi John,

    I could observe the sample application code issuing single read and write command even if I was trying to write huge amount of data. As u had referred me the page related to optimising performance no of blocks per write transaction must be as high as possible. In this case I could see the ulNumBlocks count only 1 and this USBDMSCStorageWrite was called repeatedly with ulNumBlocks as 1. Could not debug properly as it was usblib and all the api's are called from ROM.

    Also how to handle if one interrupts the transfer while in progress, with Sd card still plugged in . Currently I could see slow response in closing the data transfer window in windows 7. Does OS need to handle it or even some part of logic in firmware???

    Thanks and Regards,

    Harshit 

  •  On both processor you need implement a double buffering scheme to provide service in advance to transfer, when you send to pc you get next one from sd and viceversa, again both stellaris and MSP are USB2.0 480Mbps

  • Harshit,

    Assuming sufficient processing speed, a 480 Mbps USB interface would help, but it is not present on the Stellaris parts.

    I talked to our USBLib expert and apparently changing the USBLib to write multiple blocks at once would require a significant amount of work. Also, having the device notify the host that the transfer was being interrupted would also require a lot of work. Without that notification, the Windows 7 response to stalled devices is long.

  • HI John,

    Thanks a lot to escalate this concern. Ya it looks like a lot of efforts in software side to reap in best of performance. But one thing I noticed while debugging that the code always use to sent single command request to the SD card instead of multiple block write. I wanted to try to tweak that. But I wanted to know your opinion whether I would be able to realise this application. I know i mite need little more understanding in order to tweak it but seems there is chance of improvement in terms of data transfer speed.

    As far as 480Mbps is concerned I think its available in M3 counterparts, but that chip would cost more as cost is also a concern. AS far as MSP is concerned though it mite have 480Mbps support, but the max clock frequency of MSp430 is again limited to 25Mhz.

    Would DMA transfer help here. I cold see initializtion of DMA but doubted if DMA is in picture here in the existing sample code. 

    Do u have anything to say related to double buffering scheme by Roberto in previous post.

    Thanks and Regards,

    Harshit

  • harshit said:
    Do u have anything to say related to double buffering scheme by Roberto in previous post.

     Double buffering also using concurrent DMA transfer can help a lot reducing overhead of both processors leaving just event processing to software.

     I am sorry I cannot help you about USB, I don't like USB and I never thought how it work in deep. Again Windows I learned from the past burden disk and has not clean interface to devices nor a real preemption on kernel so when a process is held waiting there where no way to communicate with this prehistoric environment.

  • Harshit,

    As stated before, modifying USBLib to do multi block writes would be a lot of work. It is possible to do it, but only you can decide whether it would be worth it. Also, without implementing the multi block writes I don't know how much faster it would be. Our USB expert said he expected even with an SD card and SPI interface of infinite speed that the 12 Mbps USB interface and overhead would limit the transfer speed to around 750 KBps. He also said that double buffering would not provide a speedup with the usb_dev_mc example.

    The Stellaris M3, M4, and the MSP430 device you linked to are all limited to 12 Mbps USB speed.

    The current usb_dev_msc example already uses DMA. The control table is in usb_dev_msc.c and the uDMA configuration functions are called in usblib/device/usbdmsc.c

  • Stellaris John said:

    The Stellaris M3, M4, and the MSP430 device you linked to are all limited to 12 Mbps USB speed.

     Some check from lsusb:

     MSP430 is connected as full speed USB2.0

    I don't own a TIVA, also on Stellaris I don't know enough device to setup it.

     Both Data Sheet report USB 2.0 FULL SPEED is full speed 12Mbps not 480Mbps???

     From TIVA TI page:

     Optional full-speed USB 2.0 with device, host, and OTG

    From MSP430 Full Speed USB 2.0 USB full speed is limited to 12Mbps..  May sound appropriate with 25MHz,MIPS where max speed can be 50MBps ~400Mbps

      Ok USB is a nightmare grown from non well designed standard, MSP430 present to HUB as 480Mbps device but is speed limited.. ???

     And also TIVA 80MHz where uDMA can drive USB at full speed is speed limited?

  • Roberto,

    I agree that the USB speed levels can be confusing at times. The USB speeds are Low (1.5Mbps), Full (12 Mbps), High (480 Mbps), and Super (5Gbps). A USB product can be USB 2.0 compliant without offering the High Speed mode.

    Could you clarify the question in your last sentence? Are you asking if the transfer speed is limited by uDMA bandwidth or USB speed?

  • Stellaris John said:
    Could you clarify the question in your last sentence? Are you asking if the transfer speed is limited by uDMA bandwidth or USB speed?

     Hi John, thank for all your thought about USB speeds, waiting for "galactic speed" clearly after grasping the concept of <<USB Full Speed>> the word act differently from literally meant.

     My last sentence was why in a so unlimited environment interface speed was lowest than resource permitted, so I learn limit came from USB interface not from processor.

     Thank a lot for advice, I forever dislike USB and forever prefer a good clean documentation with well designed specifications and behaviour. I liked Firewire by IEEE, but market is not driven by techie too and nightmare never disappear at wake up. ;)