EmbeddedRelated.com
Forums

Using FatFS on Olimex LPC2148 board

Started by richdinoso October 7, 2008
How do I adapt FatFS (http://elm-chan.org/fsw/ff/00index_e.html) to my
board?

I would like to be able to read/write to the SD card on my board. The
website I linked above says "It can be incorporated into cheap
microcontrollers, such as 8051, PIC, AVR, SH, Z80, H8, ARM and etc...,
without any change."

How true is that statement? I assume I have to change the code some.
How do I make FatFS know the address of the SD card slot, for example?

I'm new to this, and I just want to start out very small. I just want
to be able to read a file from an SD card.

Thanks in advance.

An Engineer's Guide to the LPC2100 Series

richdinoso wrote:
> How do I adapt FatFS (http://elm-chan.org/fsw/ff/00index_e.html) to
> my board?
>
> I would like to be able to read/write to the SD card on my board. The
> website I linked above says "It can be incorporated into cheap
> microcontrollers, such as 8051, PIC, AVR, SH, Z80, H8, ARM and
> etc..., without any change."
>
> How true is that statement? I assume I have to change the code some.
> How do I make FatFS know the address of the SD card slot, for example?
>
> I'm new to this, and I just want to start out very small. I just want
> to be able to read a file from an SD card.
>

Reading a FAT filesystem is not the most straightforward thing to start
with if you're just starting out...

Having said that, FatFS is one of the easier Fat libraries to integrate
into your code. It uses device driver routines to interface with your
media - see the section on the page you reference above titled "Disk IO
interface", but for "Disk" read "SD card". FatFS provides frameworks of
routines to do what you need - you have to fill in the gaps. So you need
to complete the routines to initialise the processor hardware to talk to
the card (disk_initialise), read a sector from the card (disk_read),
write a sector to the card (disk_write), etc.

Once you've done that, the rest of FatFS will use your low level
routines to talk to the SD card and you should be able to read the
filesystem.
--
Tim Mitchell
Thank you Tim. That helps alot.
--- In l..., "Tim Mitchell" wrote:
>
> richdinoso wrote:
> > How do I adapt FatFS (http://elm-chan.org/fsw/ff/00index_e.html) to
> > my board?
> >
> > I would like to be able to read/write to the SD card on my board. The
> > website I linked above says "It can be incorporated into cheap
> > microcontrollers, such as 8051, PIC, AVR, SH, Z80, H8, ARM and
> > etc..., without any change."
> >
> > How true is that statement? I assume I have to change the code some.
> > How do I make FatFS know the address of the SD card slot, for example?
> >
> > I'm new to this, and I just want to start out very small. I just want
> > to be able to read a file from an SD card.
> > Reading a FAT filesystem is not the most straightforward thing to start
> with if you're just starting out...
>
> Having said that, FatFS is one of the easier Fat libraries to integrate
> into your code. It uses device driver routines to interface with your
> media - see the section on the page you reference above titled "Disk IO
> interface", but for "Disk" read "SD card". FatFS provides frameworks of
> routines to do what you need - you have to fill in the gaps. So you need
> to complete the routines to initialise the processor hardware to talk to
> the card (disk_initialise), read a sector from the card (disk_read),
> write a sector to the card (disk_write), etc.
>
> Once you've done that, the rest of FatFS will use your low level
> routines to talk to the SD card and you should be able to read the
> filesystem.
> --
> Tim Mitchell
>