cancel
Showing results for 
Search instead for 
Did you mean: 

sdio sd card write speed problem

jimmjimmshen
Associate III
Posted on August 30, 2013 at 03:17

hi guys i'm new to stm32, i got a problem that i used sdio and fatfs to test maximum speed of write sd card, its only around 330kb/s but when i try to use sd card reader its up to 2mb/s, so i want to figure out why its so different between them and how can i fix it?

(i tried two ways of test: first use f_write function write 10k data once, second separate 10k data into 64byte package to send, result looks similar )

i use dma mode 4bits bus

#sdio-fatfs
11 REPLIES 11
Posted on August 30, 2013 at 05:40

Yes that would appear quite slow, but I know nothing about your board, clocks, software or cards.

Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
jimmjimmshen
Associate III
Posted on August 30, 2013 at 08:06

sorry , there is my test program and my card is sandisk 4gb card

________________

Attachments :

Test_progarm.rar : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006I10O&d=%2Fa%2F0X0000000bgn%2F6wDYUzl3NIenKfG5TCqKnub2XVTadVucz.vyPigbzAQ&asPdf=false
Posted on August 30, 2013 at 11:17

What board? Is the card a MicroSD? What class?

Not much experience here with the STM32F103VE and SDIO.

Looks to be running the card at 24 MHz, confirm.

You could perhaps run it at 36 MHz, or 48 MHz if you run the processor at 48 MHz and use BYPASS mode.

Code won't support cards >4GB

Some bugs in USART output code
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
alexandr
Associate II
Posted on August 31, 2013 at 22:44

Hello,

According to my experience, SD-card write speed is very depends of how the card was formatted.

On order of increasing the write (and read) speed:

- PC format disk under Windows

- using FatFs command mkfs

- PC format using ''sdformatter program

The difference could be 10 tiimes or more!

https://www.sdcard.org/downloads/formatter_4/

Also the writing speed depends of a chunk size you are writing - 4K-64K make the higher speed then 256-2048 bytes chunk(but if you are not use OS - higher chunk blocks your program for a longer time!)

___

Alex.

Posted on September 01, 2013 at 02:31

Preformatted cards should be fine as delivered.

You would want to run CHKDSK on cards after being written on an embedded system to confirm nothing is going wrong, the 4GB (3.9 real) shouldn't have the 32-bit limit inherent in the ST code.

On the F1 the SPI interface to the cards is very slow. I haven't built an F1 SDIO implementation, but on the F2/F4 I'd expect a Class 4 card to write at a few MBps, with some Ultra ones probably 7-8 MBps

The speed is also very dependent on the SDIO clock, pretty sure the MicroSD are rated at 50 MHz, and significantly faster than the full size cards.

Ideally you want sector or cluster sized interactions, at similarly aligned addresses. I'd expect 8KB to be a better multiple than 10KB which will more often than not fall awkwardly on the media.
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
martinmartin9129
Associate II
Posted on September 01, 2013 at 09:21

>Preformatted cards should be fine as delivered.

Should, but...

At the same device (STM32F407 based) I have seen increasing the  writing speed 5-10 times (depend of a block size) after formating using SDFORMATTER.

HW/SW were not changed.

Posted on September 01, 2013 at 15:51

Any particular brand that's not using the equivalent to SDFormatter to initialize cards?

Any before/after observation about FAT and cluster size variations?

I've run into the odd camera that wants to reformat things.
Tips, buy me a coffee, or three.. PayPal Venmo Up vote any posts that you find helpful, it shows what's working..
alexandr
Associate II
Posted on September 01, 2013 at 19:28

Hi Clive,

I don't know what the software used by brands.

The card I have tested were Sandisk, Kingstone and PKI.

I don't remember what the speed was before, but after SDFORMATTER I got these results:

block_size write/read (MBytes/S)

512 0.26/1.53

1K  0.56/2.7

4K 2.1/6.6

16K 5.5/9.7

all with 4 bit @24MHz and Kingstone Class4 SDHC card.

What is ineresting - that FatFs' command (mkfs) make better result then Windows' format, but worth then SDFormatter.

jimmjimmshen
Associate III
Posted on September 02, 2013 at 05:22

yeah, its MicroSD sdhc, er i try to set SDIO_InitStructure.SDIO_ClockBypass enable but the whole program looks going wrong, it stack at SD_WaitReadOperation.

and i run chkdsk there is no error. 

finally, the 32-bit limit inherent in the ST code. I'm not sure whats this.

thinks your help