cancel
Showing results for 
Search instead for 
Did you mean: 

Using SDIO instead of SPI in STM32

tinymanta
Associate II
Posted on January 09, 2013 at 14:14

Hi all,

How can I use the SDIO to access to an uSD card with EFSL filesystem.

The example I have is using EFSL with SPI as communication interface.

I should have an interface.c file where I do a low level interface implementation, to initialize the hardware, read sectors from the disc, and write sectors to the disc.

The function that initializes the hardware using is stm32_eval_spi_sd:

esint8 if_initInterface(hwInterface* file, eint8* opts)
{
euint32 sc;
SD_Init();
SD_GetCSDRegister(&SD_csd);
/* SDCard Capacity*/
sc = SD_csd.DeviceSize + 1;
sc *= (1 << (SD_csd.DeviceSizeMul + 2));
sc *= (1 << (SD_csd.RdBlockLen));
file->sectorCount = sc / 512;
if ( (sc % 512) != 0)
{
file->sectorCount--;
}
return(0);
}

How can I perform this function using the stm32_eval_sdio_sd instead of stm32_eval_spi_sd ?
11 REPLIES 11
harshad
Associate II
Posted on January 09, 2013 at 14:44

Hi Clive2,

I have never used EFSL but yes I have tried with FatFs. FatFs is very handy and generic you can easily port its SPI or generic example to STM32.

There is also some example based on STM32 and FatFs. 🙂
tinymanta
Associate II
Posted on January 09, 2013 at 15:24

Thanks HallMark,

I need really to use EFSL with SDIO as communication interface.

All the examples that I find on the net use EFSL with SPI communication interface...

Posted on January 09, 2013 at 16:11

Which STM32 part?

I guess you'd want to start by looking at the firmware and eval board examples for SDIO. FatFs uses the routines in diskio.c tp abstract sector level IO, suggest you look at that, and the interface routines for the SPI vs SDIO libraries/drivers.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
tinymanta
Associate II
Posted on January 10, 2013 at 18:41

Thanks Clive1, it's okay..

I can use SDIO instead of SPI, to implement the EFSL filesystem for STM32F4.

A question about EFSL, it provides some functions to access to the FAT volumes:

file_fopen (): to search for a file and initialize th file object available in 3 Modes

- READ - WRITE - APPEND

Is file_fopen () able to create a file and open it, or just open available files under the µSD card?

Posted on January 10, 2013 at 21:03

See pg 7

http://www.avrfreaks.net/modules/FreaksFiles/files/1371/manual.pdf

Pretty sure opening with 'w' gets you a new file.

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
tinymanta
Associate II
Posted on January 11, 2013 at 10:44

Thanks Clive 🙂

It's okay, I can create a file.txt and write some words on it.

I have just 2 little issues:

- once created the file.txt can not be overwritten.

- the file name can not be long more than 8 and 3 for extension, is there any EFSL config to modify to be able to support LFN.

With Regards,

Clive2

Posted on January 11, 2013 at 17:41

Can't you just append, seek to zero, or delete it?

What is the appeal of EFSL over something like FatFs?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
tinymanta
Associate II
Posted on January 29, 2013 at 16:21

Thanks Clive,

I've already implemented the EFSL filesystem using SDIO on STM32F2 eval board with µSD card. I can write a .txt file, but when I try to write a 225KB .bmp picture, i found a empty .bmp file in uSD. What would be probably the problem ?

jlamb
Associate II
Posted on February 02, 2013 at 22:24

Are you two brothers?

=)