EmbeddedRelated.com
Forums
Memfault State of IoT Report

SD/MMC card on an sam7-ex256

Started by axl_dudu March 2, 2008
Hello,
does anyone has a working example for controlling the SD/MMC card on an
at91sam7 (preferably with the olimex's board sam7-ex256)? I have been
struggling to get working an example that someone gave me but it gets
stuck somewhere in the init part.

Thanks,
Tudor
Hi Tudor,

NutOS does this right out of the box.
Includes FTP.

I am now working to get it to format the card.

*E

On Sun, Mar 2, 2008 at 12:39 PM, axl_dudu wrote:

> Hello,
> does anyone has a working example for controlling the SD/MMC card on an
> at91sam7 (preferably with the olimex's board sam7-ex256)? I have been
> struggling to get working an example that someone gave me but it gets
> stuck somewhere in the init part.
>
> Thanks,
> Tudor
>
>
>
Thanks Eric.
I haven't tried yet the NutOS. I have been using FreeRTOS and I'd
like to continue with it(at least for the moment). But I will
consider migrating to the NutOS, if it includes FTP.

Tudor

--- In A..., "Eric Haver" wrote:
>
> Hi Tudor,
>
> NutOS does this right out of the box.
> Includes FTP.
>
> I am now working to get it to format the card.
>
> *E
>
> On Sun, Mar 2, 2008 at 12:39 PM, axl_dudu wrote:
>
> > Hello,
> > does anyone has a working example for controlling the SD/MMC card
on an
> > at91sam7 (preferably with the olimex's board sam7-ex256)? I have
been
> > struggling to get working an example that someone gave me but it
gets
> > stuck somewhere in the init part.
> >
> > Thanks,
> > Tudor
> >
> >
>
On Tue, Mar 04, 2008 at 08:09:42AM -0000, axl_dudu wrote:
> Thanks Eric.
> I haven't tried yet the NutOS. I have been using FreeRTOS and I'd
> like to continue with it(at least for the moment). But I will
> consider migrating to the NutOS, if it includes FTP.

You might want to consider efsl.
http://www.efsl.be/
It has some limitations on FAT with long filenames though.
But maybe you are just searching for the block functions and not for
filesystem support.

> --- In A..., "Eric Haver" wrote:
> >
> > Hi Tudor,
> >
> > NutOS does this right out of the box.
> > Includes FTP.
> >
> > I am now working to get it to format the card.
> >
> > *E
> >
> >
> >
> > On Sun, Mar 2, 2008 at 12:39 PM, axl_dudu wrote:
> >
> > > Hello,
> > > does anyone has a working example for controlling the SD/MMC card
> on an
> > > at91sam7 (preferably with the olimex's board sam7-ex256)? I have
> been
> > > struggling to get working an example that someone gave me but it
> gets
> > > stuck somewhere in the init part.
> > >
> > > Thanks,
> > > Tudor
> > >
> > >

--
B.Walter http://www.bwct.de http://www.fizon.de
b...@bwct.de i...@bwct.de s...@fizon.de
Yes. It is what I was looking for. I got an example made for this
board but it doesn't work properly. I have a microSD with an adapter
for the SD slot. The problem, as far as I went until now, is that
even thought the interface can read from the card, it detects invalid
FAT during the startup sequence of the EFSL. The card is just fine, I
checked it on the pc. I even installed a program that reads the Disk
Parameter Block and everything seems ok.

The person that gave me the example said he tried it with a 512MB
SANDISK SD card. I am using a 1GB A-DATA microSD with the available
adapter. Could this be a problem?

Tudor
--- In A..., Bernd Walter wrote:
>
> On Tue, Mar 04, 2008 at 08:09:42AM -0000, axl_dudu wrote:
> > Thanks Eric.
> > I haven't tried yet the NutOS. I have been using FreeRTOS and I'd
> > like to continue with it(at least for the moment). But I will
> > consider migrating to the NutOS, if it includes FTP.
>
> You might want to consider efsl.
> http://www.efsl.be/
> It has some limitations on FAT with long filenames though.
> But maybe you are just searching for the block functions and not for
> filesystem support.
>
> > --- In A..., "Eric Haver" wrote:
> > >
> > > Hi Tudor,
> > >
> > > NutOS does this right out of the box.
> > > Includes FTP.
> > >
> > > I am now working to get it to format the card.
> > >
> > > *E
> > >
> > >
> > >
> > > On Sun, Mar 2, 2008 at 12:39 PM, axl_dudu wrote:
> > >
> > > > Hello,
> > > > does anyone has a working example for controlling the SD/MMC
card
> > on an
> > > > at91sam7 (preferably with the olimex's board sam7-ex256)? I
have
> > been
> > > > struggling to get working an example that someone gave me but
it
> > gets
> > > > stuck somewhere in the init part.
> > > >
> > > > Thanks,
> > > > Tudor
> > > >
> > > >
>
> --
> B.Walter http://www.bwct.de http://www.fizon.de
> bernd@... info@... support@...
>
I'm not familiar with EFSL, but it sounds like it might be looking for the MBR (Master Boot
Record) in the wrong place.
There are primarily 2 ways of format & set up partition, it can't just look in sector (LBA) #0.
I would check the procedure and see if it supports :
1. FDISK method
2. Allows enough offset to go fetching the MBR in 2nd case.

Best Regards,
Kris

-----Original Message-----
From: A... [mailto:A...] On Behalf Of axl_dudu
Sent: Wednesday, 5 March 2008 4:11 AM
To: A...
Subject: [AT91SAM] Re: SD/MMC card on an sam7-ex256

Yes. It is what I was looking for. I got an example made for this
board but it doesn't work properly. I have a microSD with an adapter
for the SD slot. The problem, as far as I went until now, is that
even thought the interface can read from the card, it detects invalid
FAT during the startup sequence of the EFSL. The card is just fine, I
checked it on the pc. I even installed a program that reads the Disk
Parameter Block and everything seems ok.

The person that gave me the example said he tried it with a 512MB
SANDISK SD card. I am using a 1GB A-DATA microSD with the available
adapter. Could this be a problem?

Tudor
--- In A..., Bernd Walter wrote:
>
> On Tue, Mar 04, 2008 at 08:09:42AM -0000, axl_dudu wrote:
> > Thanks Eric.
> > I haven't tried yet the NutOS. I have been using FreeRTOS and I'd
> > like to continue with it(at least for the moment). But I will
> > consider migrating to the NutOS, if it includes FTP.
>
> You might want to consider efsl.
> http://www.efsl.be/
> It has some limitations on FAT with long filenames though.
> But maybe you are just searching for the block functions and not for
> filesystem support.
>
> > --- In A..., "Eric Haver" wrote:
> > >
> > > Hi Tudor,
> > >
> > > NutOS does this right out of the box.
> > > Includes FTP.
> > >
> > > I am now working to get it to format the card.
> > >
> > > *E
> > >
> > >
> > >
> > > On Sun, Mar 2, 2008 at 12:39 PM, axl_dudu wrote:
> > >
> > > > Hello,
> > > > does anyone has a working example for controlling the SD/MMC
card
> > on an
> > > > at91sam7 (preferably with the olimex's board sam7-ex256)? I
have
> > been
> > > > struggling to get working an example that someone gave me but
it
> > gets
> > > > stuck somewhere in the init part.
> > > >
> > > > Thanks,
> > > > Tudor
> > > >
> > > >
>
> --
> B.Walter http://www.bwct.de http://www.fizon.de
> bernd@... info@... support@...
>
Hello Eric!
How did you limit the speed? If you remember what changes you made to
do that, please post them (at least from what you remember).

Thanks,
Tudor

--- In A..., "Eric Pasquier" wrote:
>
> Hi,
>
> I am using a 2GB card with SPI protocol.
> I remember that I had to limit transfert rate during initialisation
phase.
>
> I hope this help.
>
> Eric Pasquier
> ----- Original Message -----
> From: axl_dudu
> To: A...
> Sent: Tuesday, March 04, 2008 6:10 PM
> Subject: [AT91SAM] Re: SD/MMC card on an sam7-ex256
> Yes. It is what I was looking for. I got an example made for this
> board but it doesn't work properly. I have a microSD with an
adapter
> for the SD slot. The problem, as far as I went until now, is that
> even thought the interface can read from the card, it detects
invalid
> FAT during the startup sequence of the EFSL. The card is just
fine, I
> checked it on the pc. I even installed a program that reads the
Disk
> Parameter Block and everything seems ok.
>
> The person that gave me the example said he tried it with a 512MB
> SANDISK SD card. I am using a 1GB A-DATA microSD with the
available
> adapter. Could this be a problem?
>
> Tudor
>
> --- In A..., Bernd Walter wrote:
> >
> > On Tue, Mar 04, 2008 at 08:09:42AM -0000, axl_dudu wrote:
> > > Thanks Eric.
> > > I haven't tried yet the NutOS. I have been using FreeRTOS and
I'd
> > > like to continue with it(at least for the moment). But I will
> > > consider migrating to the NutOS, if it includes FTP.
> >
> > You might want to consider efsl.
> > http://www.efsl.be/
> > It has some limitations on FAT with long filenames though.
> > But maybe you are just searching for the block functions and
not for
> > filesystem support.
> >
> > > --- In A..., "Eric Haver"
wrote:
> > > >
> > > > Hi Tudor,
> > > >
> > > > NutOS does this right out of the box.
> > > > Includes FTP.
> > > >
> > > > I am now working to get it to format the card.
> > > >
> > > > *E
> > > >
> > > >
> > > >
> > > > On Sun, Mar 2, 2008 at 12:39 PM, axl_dudu wrote:
> > > >
> > > > > Hello,
> > > > > does anyone has a working example for controlling the
SD/MMC
> card
> > > on an
> > > > > at91sam7 (preferably with the olimex's board sam7-ex256)?
I
> have
> > > been
> > > > > struggling to get working an example that someone gave me
but
> it
> > > gets
> > > > > stuck somewhere in the init part.
> > > > >
> > > > > Thanks,
> > > > > Tudor
> > > > >
> > > > >
> >
> > --
> > B.Walter http://www.bwct.de http://www.fizon.de
> > bernd@ info@ support@
>
The first thing to do is to check if your low level disk interface is properly working.
Now, of course if you just simply write somewhere and read it back (as a test) it might still
'appear' to be OK, but actually be writing wrong (and read back wrong, so it looks OK).

Having a 'sanity check' PC formatted card is your ticket out....

It actually does sound like your low level isn't running right. I'll have to dig up what your card
could be reading at offset 510 & 511 (where the signature is). AFAIK it *should* read 0x55AA
there, SFD or FDISK.

The best probably is to first check if your low level reads card size properly.
You need to read the CSD (Card Specific Data). If your Card Size makes sense, then you're on your
way, else this is where you should concentrate first.

In answer to your earlier question, you should first do the SPI operations (like putting into bit
mode etc.) at low clock (I used SPI at 2 MHz first on SAM7 and that worked fine on many SD cards).
Once init properly then you can go to full speed (I switched to 24 MHz SPI).

Perhaps this might get you started.

It might help if you tell which :
- Card you're using
- What FAT you have on it, 16/32
(bear in mind that XP now can format as FAT32 from 64 MB onwards)
- SPI settings you use

Best Regards,
Kris

-----Original Message-----
From: A... [mailto:A...] On Behalf Of axl_dudu
Sent: Wednesday, 5 March 2008 5:39 AM
To: A...
Subject: [AT91SAM] Re: SD/MMC card on an sam7-ex256

I've just checked to see if it reads the MBR and WHAT it reads from
there. First, the EFSL checks the Boot sector signature (that must be
0x55AA) but mine reads 0xABB0. Then it checks other stuff that I
haven't got the time to dig up.
I have checked the signature on the pc and it is just fine. So there
might be a problem when reading this address. Maybe it is a problem
with the device speed, as Eric suggested. If you have any other
suggestions, please post them.
Regards,
Tudor

--- In A..., "microbit" wrote:
>
> I'm not familiar with EFSL, but it sounds like it might be looking
for the MBR (Master Boot
> Record) in the wrong place.
> There are primarily 2 ways of format & set up partition, it can't
just look in sector (LBA) #0.
> I would check the procedure and see if it supports :
> 1. FDISK method
> 2. Allows enough offset to go fetching the MBR in 2nd case.
>
> Best Regards,
> Kris
>
> -----Original Message-----
> From: A... [mailto:A...] On
Behalf Of axl_dudu
> Sent: Wednesday, 5 March 2008 4:11 AM
> To: A...
> Subject: [AT91SAM] Re: SD/MMC card on an sam7-ex256
>
> Yes. It is what I was looking for. I got an example made for this
> board but it doesn't work properly. I have a microSD with an
adapter
> for the SD slot. The problem, as far as I went until now, is that
> even thought the interface can read from the card, it detects
invalid
> FAT during the startup sequence of the EFSL. The card is just fine,
I
> checked it on the pc. I even installed a program that reads the
Disk
> Parameter Block and everything seems ok.
>
> The person that gave me the example said he tried it with a 512MB
> SANDISK SD card. I am using a 1GB A-DATA microSD with the available
> adapter. Could this be a problem?
>
> Tudor
> --- In A..., Bernd Walter wrote:
> >
> > On Tue, Mar 04, 2008 at 08:09:42AM -0000, axl_dudu wrote:
> > > Thanks Eric.
> > > I haven't tried yet the NutOS. I have been using FreeRTOS and
I'd
> > > like to continue with it(at least for the moment). But I will
> > > consider migrating to the NutOS, if it includes FTP.
> >
> > You might want to consider efsl.
> > http://www.efsl.be/
> > It has some limitations on FAT with long filenames though.
> > But maybe you are just searching for the block functions and not
for
> > filesystem support.
> >
> > > --- In A..., "Eric Haver"
wrote:
> > > >
> > > > Hi Tudor,
> > > >
> > > > NutOS does this right out of the box.
> > > > Includes FTP.
> > > >
> > > > I am now working to get it to format the card.
> > > >
> > > > *E
> > > >
> > > >
> > > >
> > > > On Sun, Mar 2, 2008 at 12:39 PM, axl_dudu wrote:
> > > >
> > > > > Hello,
> > > > > does anyone has a working example for controlling the
SD/MMC
> card
> > > on an
> > > > > at91sam7 (preferably with the olimex's board sam7-ex256)? I
> have
> > > been
> > > > > struggling to get working an example that someone gave me
but
> it
> > > gets
> > > > > stuck somewhere in the init part.
> > > > >
> > > > > Thanks,
> > > > > Tudor
> > > > >
> > > > >
> >
> > --
> > B.Walter http://www.bwct.de
http://www.fizon.de
> > bernd@ info@ support@
> >
>
>
Hi,

I am using a 2GB card with SPI protocol.
I remember that I had to limit transfert rate during initialisation phase.

I hope this help.

Eric Pasquier
----- Original Message -----
From: axl_dudu
To: A...
Sent: Tuesday, March 04, 2008 6:10 PM
Subject: [AT91SAM] Re: SD/MMC card on an sam7-ex256
Yes. It is what I was looking for. I got an example made for this
board but it doesn't work properly. I have a microSD with an adapter
for the SD slot. The problem, as far as I went until now, is that
even thought the interface can read from the card, it detects invalid
FAT during the startup sequence of the EFSL. The card is just fine, I
checked it on the pc. I even installed a program that reads the Disk
Parameter Block and everything seems ok.

The person that gave me the example said he tried it with a 512MB
SANDISK SD card. I am using a 1GB A-DATA microSD with the available
adapter. Could this be a problem?

Tudor

--- In A..., Bernd Walter wrote:
>
> On Tue, Mar 04, 2008 at 08:09:42AM -0000, axl_dudu wrote:
> > Thanks Eric.
> > I haven't tried yet the NutOS. I have been using FreeRTOS and I'd
> > like to continue with it(at least for the moment). But I will
> > consider migrating to the NutOS, if it includes FTP.
>
> You might want to consider efsl.
> http://www.efsl.be/
> It has some limitations on FAT with long filenames though.
> But maybe you are just searching for the block functions and not for
> filesystem support.
>
> > --- In A..., "Eric Haver" wrote:
> > >
> > > Hi Tudor,
> > >
> > > NutOS does this right out of the box.
> > > Includes FTP.
> > >
> > > I am now working to get it to format the card.
> > >
> > > *E
> > >
> > >
> > >
> > > On Sun, Mar 2, 2008 at 12:39 PM, axl_dudu wrote:
> > >
> > > > Hello,
> > > > does anyone has a working example for controlling the SD/MMC
card
> > on an
> > > > at91sam7 (preferably with the olimex's board sam7-ex256)? I
have
> > been
> > > > struggling to get working an example that someone gave me but
it
> > gets
> > > > stuck somewhere in the init part.
> > > >
> > > > Thanks,
> > > > Tudor
> > > >
> > > >
>
> --
> B.Walter http://www.bwct.de http://www.fizon.de
> bernd@... info@... support@...
>
I was curious and ended up having a look at EFSL.
It seems to be in an 'in between' state 0.2.8 -> 0.3/4 , but overall I quite like it - the ioman
has some nice caching features. There's a few silly things too, but it seems that's WIP.

So, I got interested in fiddling and decided to set it up for my SAM7S256-EK which I added an
SD/MMC socket to quite some time ago.

To be able to work faster I've first set up a project under CrossWorks MSP430 with Simulator.
I simulate a 30 KB FAT12 drive there (which I first "force" format of course, as it's in simulated
RAM..)
This way I can familiarise myself way faster with the guts of it, as the code is little
documented.

I've written a formatting function so you can fmt from EFSL in FAT12/16/32, to be tested better.

I've actually had fun doing that, next I'll port my existing interface code from SAM7-EK that I
have under CrossWorks for ARM.

So, after I do this I can help you much better with EFSL if you want to.

Best Regards,
Kris

-----Original Message-----
From: A... [mailto:A...] On Behalf Of axl_dudu
Sent: Wednesday, 5 March 2008 5:39 AM
To: A...
Subject: [AT91SAM] Re: SD/MMC card on an sam7-ex256

I've just checked to see if it reads the MBR and WHAT it reads from
there. First, the EFSL checks the Boot sector signature (that must be
0x55AA) but mine reads 0xABB0. Then it checks other stuff that I
haven't got the time to dig up.
I have checked the signature on the pc and it is just fine. So there
might be a problem when reading this address. Maybe it is a problem
with the device speed, as Eric suggested. If you have any other
suggestions, please post them.
Regards,
Tudor

Memfault State of IoT Report