[En-Nut-Discussion] EIR: SD-Card on SPI

Harald Kipp harald.kipp at egnite.de
Tue Jan 29 19:03:57 CET 2013


Hi Markus,

On 29.01.2013 11:29, Markus Dost wrote:

> thank you for your advices. At the moment, the SD-Card on my board is
> attached to the SSC like on the EIR. For I don't use the audio codec I
> would take the advantages of using SPI. But before I redesign my board I
> have to be shure that I can still use the Phat-filesystem.

In case you keep the MMC connected to SSC, you can strictly follow

http://www.ethernut.de/en/hardware/eir/mmc.html

Do not forget the hardware mod

http://www.ethernut.de/en/hardware/eir/spi.html

>> If you want SPI, the optimal way is to register the SPI bus
>>
>> http://www.ethernut.de/en/documents/ntn-6_spi.html
> I noticed this document, but the section
> 
>     "At the time of this writing file system support for devices
> attached to the SPI bus controller framework is almost non-existent.
> There is one exception, the rather simple raw file system.
> 
>     You may know, that Nut/OS offers the FAT compatible PHAT file
> system, which uses MMC/SD-Cards in SPI mode. However, the related low
> level drivers implement their own SPI routines. It would be a    
> benefit to re-write them for using the new SPI bus interface. Work is in
> progress to close this gap."
> 
> confused me and additional I didn't noticed Oles SPI driver.

You are right, that needs an update.



> Just to be sure: with this driver I initialize the SD-Card with
> 
>     NutRegisterDevice(&devPhat0, 0, 0);        // Phat filesystem
>     NutRegisterDevice(&devSpiMmcGpio, 0, 0);    // SPI driver for MMC
>     _open("MMC0:/PHAT0", _O_RDWR | _O_BINARY);    // mount the Card
> 
> and the functionality for reading/writing files and directory operations
> remains the same?

That's one of the essentials of Nut/OS. You only need to adapt the
initialization to a new target. The rest is based on C standard calls.
It will even run on your PC. More likely on Linux or OS X than on
Windows PC. Unfortunately Windows doesn't support TCP stdio streams or
doesn't provide C standard routines for directory access.

But in general it is no big problem to write applications running on
AVR, ARM, Freescale etc. under Nut/OS, or on a PC under Windows, OS X or
Linux. For example, I developed the uHTTP library on MS Visual Studio
and ported it to Nut/OS later by replacing a few functions and adding
some Nut/OS specific initializations.

Regards,

Harald



More information about the En-Nut-Discussion mailing list