Skip to main content
elec_st
Associate III
January 22, 2014
Question

sdio fatfs speed problem

  • January 22, 2014
  • 25 replies
  • 3840 views
Posted on January 22, 2014 at 20:31

i use fatfs and i read at about 200to300KB/SECOND

 it's very low speed . i test sd card speed from computer and it's speed reading 12.5MB/SECOND

how to speed up sd card reading i want about 5MB/sec are this hard ?

#metoo-maybe
    This topic has been closed for replies.

    25 replies

    Tesla DeLorean
    Guru
    January 22, 2014
    Posted on January 22, 2014 at 21:22

    Depends on the size of the read in question. I've got SDHC cards reading at 10.6 MBps using nominal clocks, and 15.8 MBps with aggressive clocks.

    Sandisk Extreme MicroSD Card, 32 MB read as 32 KB blocks. STM32F4-Discovery + STM32F4-DIS-BB

    If you're read small, or oddly aligned bits of data it's likely to be slow and awkward.

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    elec_st
    elec_stAuthor
    Associate III
    January 23, 2014
    Posted on January 23, 2014 at 11:03

    i try to increacing reading buffer from   Buff[512]; To   Buff[16384];

    Buff[32767]; at32kb this not work and f_read cant read file

    but the speed is same no change in speed  i read at ver low speed <200K/sec

    elec_st
    elec_stAuthor
    Associate III
    January 24, 2014
    Posted on January 24, 2014 at 10:38

    are there a project  that can read at good speed i use keil .

    please help me .

    i just want to know where is problem .

    thank you

    chen
    Associate II
    January 24, 2014
    Posted on January 24, 2014 at 11:32

    Hi

    Can you get to he SD card /connector pins?

    Have you checked the clock speed when accessing the SD card.

    Can you examine it with oscilloscope?

    If I remember correctly, this is determined in part by what the part says it is capable of.

    Check through the driver code if this clock speed has been set to a low default number or whether it is set to what the card says it can do.

    (I may be wrong - I am going from memory on what the SD card protocol is

    Just some ideas for you to look at)

    Tesla DeLorean
    Guru
    January 24, 2014
    Posted on January 24, 2014 at 12:09

    32768 perhaps?

    Ok, from other threads I've concluded that you're already using code I posted, and you've got this wired up oddly, I've written several times on the forum, and in posting notes how to wire these things up.

    I've illustrated, to my own satisfaction, that a 4-bit SDIO bus clocked at 24 MHz, using DMA, can achieve at least 10 MBps with large multi-sector transfers.

    So let's focus on what you're doing, and draw out from you something about your software, hardware and testing methods...

    How do you have the interface wired up? Provide a schematic, details about the socket, and length of cabling.

    What kind of card(s) are you using? Form-factor, size, speed, rating etc.

    What speed are you clocking the interface?

    Is your lack of speed observable at the SDIO code interface, ie below FatFs?

    How are you benchmarking the speed?

    Do you have a large file written to the media, and can you validate it's content as read by the STM32?

    Are you using DMA? Are you using 4-bit mode? What are your processor and bus clocks?

    Are you using SDIO and/or DMA interrupts?
    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    elec_st
    elec_stAuthor
    Associate III
    January 24, 2014
    Posted on January 24, 2014 at 17:41

    i'm beginner with sd card and i use this your project at this link

    https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/DispForm.aspx?ID=25551&RootFolder=https%3a//my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/SDIO%20and%20SD%20fat%20access%20example

    -i use stm32f4 discovery. and i clocked cpu at 42MHZ AND 24MHZ for SDIO .

    -i just want READING 2MB/SEC AT 42 MHZ . AND READING about 8MB AT 168MHZ. this is my dream

    - i use your project and read 150KB FILE IN ONE SECOND with 16KB BUFFER. with 42MHZ CPU AND 24MHZ SDIO

    - sorry i can't answer all your question because i'm beginner and i don't know if your project using dma or what .

    https://my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/DispForm.aspx?ID=23354&RootFolder=https%3a//my.st.com/public/STe2ecommunities/mcu/Lists/cortex_mx_stm32/ST32f4discovery%2bsdcard%2bfatfs%20problem

    i use 2gb micro sd and it's reading speed is 5MB/SECOND tested from my computer.

    my cabel is 10CM with sd adapter like this with 47k pullup resistor.

    http://3.bp.blogspot.com/-YRk9TlY-nd0/USNnZXgEJeI/AAAAAAAADsI/e8PyI58nWjA/s320/DSCF14JPG

    thank you very much

    Tesla DeLorean
    Guru
    January 24, 2014
    Posted on January 24, 2014 at 19:19

    Ok, I don't think running the CPU at 42 MHz and the SDIOCLK at 48 MHz (24 MHz @ card) is desirable. It causes a clock precedence inversion. The documents suggest it can tolerate an APB2 as low as 9 MHz, but doesn't discuss the AHB/CPU clocks. Not saying this is the issue, but it's where I'd start.

    You perhaps want to either clock the CPU >= 48 MHz, or get SDIOCLK (PLL_Q tap) <= 42 MHz

    You have the wires soldered to a Full size SD Card? or was there something else at the blog spot you wanted to point at? You mentioned MicroSD, and all my analysis/diagrams are for MicroSD.

    Observations:

    10 CM (100mm) is a LONG cable

    the 47K pull-up need to be at, or proximate to the card interface.

    I'd want to see equal lengths, closer to 30-40 mm

    Have you considered using something like the

    http://www.newark.com/stmicroelectronics/stm32f4dis-bb/add-on-brd-base-brd-for-stm32f4/dp/47W1731

    ?

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    Tesla DeLorean
    Guru
    January 24, 2014
    Posted on January 24, 2014 at 19:38

    0690X0000060MnvQAE.gif

    0690X0000060MnwQAE.gif

    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    Tesla DeLorean
    Guru
    January 24, 2014
    Posted on January 25, 2014 at 00:03

    Burn the attached .HEX with the ST-Link Utilities, and then use the SWV option at 42 MHz. I suppressed the SD Card Detect pin based on previous forum discussions.

    FatFs Testing for asr.ahmed STM32 Forum
    ---- 600 /LOG.TXT
    ---- 32768000 /SPEEDTST.BIN
    ---- 0 /DIR.TXT
    Done
    STM32 1024 KB FLASH, 192 KB RAM, 003A003D-32314717-32303538 UNIQUE
    SYS:42000000, H:42000000, P1:42000000, P2:42000000
    CPU:42000000, SDIO:48000000,24000000
    CRC32 317BA605 Memory Image
    32768000 Bytes, 826783010 Cycles
    1.664592 MBps Write (FatFs)
    CRC32 317BA605 SPEEDTST.BIN
    32768000 Bytes, 827280041 Cycles
    1.663591 MBps Write (FatFs)
    CRC32 317BA605 SPEEDTST.BIN
    32768000 Bytes, 142024349 Cycles
    9.690282 MBps Read (FatFs)
    32768000 Bytes, 142018461 Cycles
    9.690684 MBps Read (FatFs)
    Done

    ________________

    Attachments :

    asr_ahmed_sdio.hex : https://st--c.eu10.content.force.com/sfc/dist/version/download/?oid=00Db0000000YtG6&ids=0680X000006Hzsn&d=%2Fa%2F0X0000000bQj%2FWin3y9k3GLU9Qz2CIMcyNXrb8Agn3CVeoKkf9.BqKOw&asPdf=false
    Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
    elec_st
    elec_stAuthor
    Associate III
    January 25, 2014
    Posted on January 25, 2014 at 22:41

    i try your hex file and it's like magic i read 9.5MB/SEC AT 42MHZ ONLY !!!. how you make this ? you are Genius 0.o plaese tell me how you do it pleas. and thank you alot for helping me i love you. you helping me alot from start .

    FatFs Testing for asr.ahmed STM32 Forum
    ---- 0 /DIR.TXT
    ---- 4 /LENGTH.TXT
    ---- 125 /LOG.TXT
    ---- 32768000 /SPEEDTST.BIN
    ---- 2419206 /1.BMP
    Done
    STM32 1024 KB FLASH, 192 KB RAM, 00240021-34314719-36343236 UNIQUE
    SYS:42000000, H:42000000, P1:42000000, P2:42000000
    CPU:42000000, SDIO:48000000,24000000
    CRC32 C47004E3 Memory Image
    32768000 Bytes, 481981050 Cycles
    2.855415 MBps Write (FatFs)
    CRC32 C47004E3 SPEEDTST.BIN
    32768000 Bytes, 487387505 Cycles
    2.823741 MBps Write (FatFs)
    CRC32 C47004E3 SPEEDTST.BIN
    32768000 Bytes, 145517716 Cycles
    9.457653 MBps Read (FatFs)
    32768000 Bytes, 145511631 Cycles
    9.458048 MBps Read (FatFs)
    Done