This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

SDIO File system problems

Having a problem with openning and apending data to a file on a SD card using the SDIO perpherial on a stm32F103RE cortex m3 part.

/****************************************************************/

using 4.14 of the tool chain
using 4.13 of the RLARM libs
using the latest CMSIS std perpherial code from ST

the hardware is an unmodified STM3210E-EVAL board.

/****************************************************************/

Using the SDIO interface I appear to be able to read all I need to without issue
but when it comes to writing to sectors there are a number of faults that appear

I have tried three different version of the SDIO driver.
/************************/
1) The two provided by Keil

2) The driver adapted from the ST MSD application. (Used a version of fs_mmc.c and editted it to use the calls from the ST provided code to provide sector init read and write and card info functionailty).

/****************************************************************/
Using the ST provided driver I consistantly suffer the same faults

I get a CRC data error after an attempt to write data to the MMC card.
I get a data timeout error after an attempt to write data to the MMC card.
I get no errors reported but the MMC card does not appear to have been changed. (eg SD_OK at the end of the transfer)

When the SDIO does work I can only generate files up to 263K in size ( eg 512 sector writes)
before the SDIO stops working.

I have tried altering the SDIO transfer clk speed from 24mhz to 18Mhz but his does not appear to improve things significantly.

The ST SDIO code is used in the USB MSD and under USB control I can read and write to my hearts content on the MMC card.

/****************************************************************/
Using the Keil provided driver I very rarely get files up to 2 Mb in size
again most are around 263K before write problems start but none bigger.

These driver problems are it seems to get hung up in while loops in the driver. ( eg the DMA transfer doesnt appear to end - while (SDIO->STA != (SDIO_STA_DATAEND | SDIO_STA_DBCKEND)) )

/****************************************************************/
The app is simply this

Take the latest ST CMSIS std perpherial code go the the project templates and set it up to use the code for the SDIO in the examples directory.

add the source code for the FS

remove all optimisations and not using microlib - system clk set at 8mhz

change the startup code to use a stack and heap of 0x800

use as a SDIO driver either
an editted version of fs_mmc.c to read and write using the ST code.

the keil code (remembering to remove the ISR and NVIC code used by the ST code)

Then setup three tasks running under RTX with a 1ms tick.( 2 tasks are for noise e.g. context switching) stk size of 2Kb for file system task. make sure the target setting are using the OS.

In the lowest proirity task finit() and then in a loop after a 100ms delay open a file in a sub directory for apend and attempt to write 131Kb odd in blocks of 530 bytes.

/****************************************************************/

If anyone has any constructive suggestions I am more than willing to try them.

I am happy to provide my version of fs_mmc.c

Has anyone ou there got the SDIO perpherial working correctly ? I am have seen the other FS threads regarding writes fails to mmc cards but it wasnt clear if they are using the sdio

I have run lint over all the code and surprised at the number of warnings the code threw up.