Skip to main content
RShar.9
Associate III
August 30, 2019
Question

sd-card read write mode speed same in SD 1 bit mode and SD 4 bit mode?why

  • August 30, 2019
  • 3 replies
  • 3735 views

i m writing data in 1 bit mode or 4 bit both have the same speed, i m using stm32f746g discovery board. and what can be the max read write speed?

This topic has been closed for replies.

3 replies

dbgarasiya
Senior
September 19, 2019

Hello ,

I am using STM32F779BI controller ,

I have problem that i could be able to write sd card only sometimes otherwise i failed in f_mkfs

how you implement to write sd card

Thanks in advance

Best Regards

Dipak Garasiya

JChrist
Associate II
October 28, 2020

RShar.9

Did you ever figure out this issue?

I'm seeing the same thing.

I can read a 128k byte file from SD in 153ms and this is the same weather in 1-bit mode or 4-bit mode.

Jacob

Tesla DeLorean
Guru
October 28, 2020

Single block reads can have significant command/response overhead.

f_read() of small and unaligned data will also be slow.

Reading 32KB blocks, one should be able to hit many MB/s. Low effort probably looking at 8-9 MBps, so figure at least 10x the numbers you're reporting.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
JChrist
Associate II
October 28, 2020

Thanks for your response, my concern is not actually throughput as much as total write time of small bits of data. We want to make sure we can close files as fast as possible in the event of a power failure (which we can detect) to prevent corruption of data.

Jacob

JChrist
Associate II
October 28, 2020

So I've confirmed by stepping through the code that the 1 bit version of the code never attempts to change the bus width and that the 4 bit version of the code does attempt to change the bus width. Futher the SD card I'm using seems to claim that is support wide bus operation and the code attempts to put it into wide but operation in the SD_WideBus_Enable() which is called from HAL_SD_ConfigWideBusOperation()

So either my SD card does not really support "Wide" bus operation or there is a bug in the ST code.

Specifically what I see is that the the upper 32 bits of the SCR register to see if wide bus mode is supported (4 bits?) with this statement:

 if((scr[1U] & SDMMC_WIDE_BUS_SUPPORT) != SDMMC_ALLZERO)

Since

#define SDMMC_WIDE_BUS_SUPPORT       0x00040000U

And since bit 50 of the SCR register is the 4-bit wide supported bit my SD card seems to correctly claim that is supports wide mode.

Next I can see the software send the CMD55 (to use ACMD's) and ACMD6 with a parameter of 2 to set to 4-bit mode (Page 102 of the SD Card Physical Specification).

Finial I can see that the STM32 registers are adjusted to use the 4-bit mode.

Make no sense why the 1-bit mode and 4-bit mode take the same amount of time to transfer 128K of data.

Jacob

Tesla DeLorean
Guru
October 29, 2020

>>Make no sense why the 1-bit mode and 4-bit mode take the same amount of time to transfer 128K of data.

Pretty sure that's not the case, but not invested in proving it false. Benchmarking 1 vs 4-bit show distinct differences. 1-bit mode definitely can't hit 11 MBps reading 32KB blocks. Not using CubeMX boiler-plate here, so figure either that's delivered pre-broken, or you're yielding the core.

Tips, Buy me a coffee, or three.. PayPal Venmo (See Profile) Up vote any posts that you find helpful, it shows what's working..
JChrist
Associate II
October 29, 2020

Totally understand, thanks for all that you have provided so far. All I did was wrap a loop that reads 128KB file with a timer. The time is the same in 1-bit or 4-bit mode. If I pursue this further the scope is coming out to see if the other data lines are actually being twiddled.