Getting started with FAT Filesystem on SD/MMC cards over SPI
Robert S. Grimes
rsg at alum.mit.edu
Fri Sep 12 17:45:23 UTC 2008
Thanks Sebastian, I'll give it a try. Likely I won't have anything to
report on until next week.
One question in clarification: you said "it must be possible to drive
the clock with inactive chip select". Do you mean the clock must always
be running, or that there needs to be a way to drive the clock sometimes
while the socket is _not_ selected? Maybe it'll become obvious when I
delve into the code, but I was just a bit curious...
Thanks again, and say "Hello" to Thomas for me,
Sebastian Huber wrote:
> I wrote a SD Card driver that uses the LibI2C interface. It is already
> included in the RTEMS CVS under the LibChip:
> It works with the SPI drivers for the MPC5566EVB and MPC8313ERDB boards.
> I had problems to initialize some SD Cards (1 out of 10), but this is
> maybe a problem of the SPI interface in these cards. The initialization
> sequence is not perfect and may need improvement. One problem is that
> not all documents are publicly available.
> The SD Card driver registers itself to LibBlock so you can use easily
> imfs and dosfs.
> Example code:
> The crucial point for the SPI driver is that it must be possible to
> drive the clock with inactive chip select:
> /* Stop */
> sc = sd_card_stop( e);
> CHECK_SC( sc, "Stop");
> /* Start with inactive chip select */
> sc = rtems_libi2c_send_start( e->minor);
> CHECK_SC( sc, "Send start");
> /* Set transfer mode */
> rv = rtems_libi2c_ioctl( e->minor, RTEMS_LIBI2C_IOCTL_SET_TFRMODE,
> CLEANUP_RVSC( rv, sc, sd_card_driver_init_cleanup, "Set transfer mode");
> /* Send idle tokens with inactive chip select */
> rv = sd_card_query( e, e->response, SD_CARD_COMMAND_SIZE);
> CLEANUP_RVSC( rv, sc, sd_card_driver_init_cleanup, "Inactive chip select
> /* Activate chip select */
> sc = rtems_libi2c_send_addr( e->minor, 1);
> CLEANUP_SC( sc, sd_card_driver_init_cleanup, "Send address");
> So you have to activate the chip select in rtems_libi2c_send_addr() and
> not before.
> It would be nice if you could use this code.
> Gene Smith wrote:
>> What you are talking about here my h/w does and it is something I need
>> to do too. However, at this point I don't have a clue how. So a "HowTo"
>> would be most appreciated and I could contribute what I learn.
>> All I have worked with is the IMFS in a simple way.
>> Robert S. Grimes wrote:
>>> My hardware provides support for SD/MMC flash cards over SPI, so now I
>>> need to implement suitable drivers for this. Because it would need to
>>> be read by Windows machines, and because it is sufficient for my
>>> application, it seems the dosfs is the way to go.
>>> I've got a low level SPI driver for my BSP (powerpc/virtex under RTEMS
>>> 4.8), and I've written some chip drivers on top of that, so I'm
>>> comfortable with the SPI level.
>>> But where do I go from here?
>>> 1. How do I "include" the dosfs in my application? Is it a matter of
>>> #define CONFIGURE_ macros, and if so, which? (As an aside, is
>>> there one central place where all these macros are defined? If
>>> so, I haven't found it...)
>>> 2. How do I get dosfs to work via the SPI bus? What must my driver
>>> look like?
>>> Any pointers or roadmap well appreciated - TIA
>>> P.S. Sounds like a request for a "HowTo" on my part - I'd be happy to
>>> write one for the Wiki...
>> rtems-users mailing list
>> rtems-users at rtems.com
> Sebastian Huber, Embedded Brains GmbH
> Address : Obere Lagerstr. 30, D-82178 Puchheim, Germany
> Phone : +49 89 18 90 80 79-6
> Fax : +49 89 18 90 80 79-9
> E-Mail : sebastian.huber at embedded-brains.de
> PGP : Public key available on request
> Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.
> rtems-users mailing list
> rtems-users at rtems.com
More information about the users