Hi.
Finally I got a new board with support for SDIO interface. But sooner was delighted, as was faced with several problems. At this point, the board has STM32F103ZET and external ASYNC 16 bit SRAM on FSMC.
First of all, I tested the memory and its speed. After numerous reviews in the direction of non-forest documentation writers still able to configure it for maximum speed. The test showed ~ 24MB/sec, though the same code on the internal memory gives 48MB/sec. Next began testing of SDIO interface.
The first problem is that the driver may not always initialize a memory card. So out of the four cards that I had, it was found that the normal initialization goes only SDHC card (it was only one: Transcend 32Gb 4class), and the other three (Sandisk Ulra II 1Gb, Sundisk uSD 1Gb, NoName uSD 256Mb) do not work. After studying the problem I found that the cards can be made ​​to work in two ways:
1. Insert a small pause after the clock setup to SDIO module:
Code: Select all
file ChibiOS\os\hal\src\sdc.c
...
191 bool_t sdcConnect(SDCDriver *sdcp) {
...
201 /* Card clock initialization.*/
202 sdc_lld_start_clk(sdcp);
>>> chThdSleepMilliseconds(10);
204 /* Enforces the initial card state.*/
205 sdc_lld_send_cmd_none(sdcp, MMCSD_CMD_GO_IDLE_STATE, 0);
...
2. Make some calls sdConnect in case of failure:
Code: Select all
/*
* SD card insertion event.
*/
static void InsertHandler(eventid_t id)
{
FRESULT err;
(void)id;
/*
* On insertion SDC initialization and FS mount.
*/
int retry = 5;
for (;;)
{
if (sdcConnect(&MMC_PORT) == CH_SUCCESS) break;
if (--retry == 0) return;
chThdSleepMilliseconds(10);
}
DEBUG_TRACE("SD CARD CONNECTED OK - %d, SIZE IS %d Kbytes\n\r", retry, MMC_PORT.capacity/2);
....
Both methods are stable, although not sure if this is a normal solution to the problem ...
Then I began to test the read/write speed of the memory cards and ran into another problem: reading is working, while the writing is causing the error FIFO UNDERRUN. The reason for this error is that I used buffer in external memory, and it is not fast enough for this purpose. If use the internal memory buffer, and it working. Also helps decrease the frequency of SDIO interface. But again, this does not guarantee the appearance of this error in the future, when the processor can be loaded with other tasks. The right solution - is to use hardware-based flow control, but ERRATA states that it is not working properly. Is there a way for software implementation of this algorithm? And yet why old cards do not work without pause?
P.S. During testing, the one memory turned bad (SDHC 32Gb)