Hi.
Today specifically bought 4 new cards for testing:
1. Transcend SDHC 8Gb 6 class.
2. Team SDHC 8Gb 10 class.
3. GOOD RAM 8Gb 10 class.
4. Transcend SDHC 32Gb 6 class.
All card work with driver without modifications. It seems the init problem is only in old SD cards.
Some benchmark (read 48 kb to internal memory 100 times starting from 0 sector, write same 48 kb buffer from internal memory 100 times, All debug options on, compilation optimization off):
Code: Select all
Transcend SDHC 8Gb 6 class: read 10810 kb/sec, write 7855 kb/sec
Team SDHC 8Gb 10 class: read 10690 kb/sec, write 7339 kb/sec
GOOD RAM 8Gb 10 class: read 7418 kb/sec, write 2845 kb/sec
Transcend SDHC 32Gb 6 class: read 10434 kb/sec, write 6357 kb/sec
Sandisk SD 1Gb Ultra II: read 10300 kb/sec, write 7754 kb/sec
Sandisk uSD 1Gb: read 10191 kb/sec, write 3086 kb/sec
It seems 'GOOD RAM' very BAD RAM
(on label MADE IN JAPAN).
Test my SDXC 64Gb card I was afraid - I check it later.
I think STM32 has very good performance... because my old atXMega on SPI has maximum 1900 kb/sec and I was pleased.
The test code:
Code: Select all
uint8_t test_buff[48*1024];
#define TEST_COUNT 100
static void testSDSpeed(void)
{
DEBUG_TRACE("TEST SD READ SPEED...\n\r");
RTCTime start, end;
rtcGetTime(&RTCD1, &start);
for (int i=0; i<TEST_COUNT; i++)
{
if (sdcRead(&MMC_PORT, 0, test_buff, sizeof(test_buff)/512) != CH_SUCCESS)
{
ERROR_TRACE("Error read from card %X!", sdcGetAndClearErrors(&MMC_PORT));
return;
}
}
rtcGetTime(&RTCD1, &end);
int time = (uint64_t) (end.tv_sec*1000+end.tv_msec) - (uint64_t) (start.tv_sec*1000+start.tv_msec);
DEBUG_TRACE("SD READ SPEED %d kb/s\n\r\n\r", (uint64_t) sizeof(test_buff)*TEST_COUNT*1000/time/1024);
DEBUG_PRINT_MEM(test_buff, 16);
DEBUG_TRACE("TEST SD WRITE SPEED...\n\r");
rtcGetTime(&RTCD1, &start);
for (int i=0; i<TEST_COUNT; i++)
{
if (sdcWrite(&MMC_PORT, 0, test_buff, sizeof(test_buff)/512) != CH_SUCCESS)
{
ERROR_TRACE("Error write to card %X!", sdcGetAndClearErrors(&MMC_PORT));
return;
}
}
rtcGetTime(&RTCD1, &end);
time = (uint64_t) (end.tv_sec*1000+end.tv_msec) - (uint64_t) (start.tv_sec*1000+start.tv_msec);
DEBUG_TRACE("SD WRITE SPEED %d kb/s\n\r\n\r", (uint64_t) sizeof(test_buff)*TEST_COUNT*1000/time/1024);
}
Last question what to do with FIFO overrun error? I think this error was the cause of my 32Gb card fault.