SD Card Problem

@ RoSchmi:
Which Format (FAT/FAT32) and which blocksize (512/1024/2048) do you recommend?
I also tried a 128MB MMC which did not work. Does the driver support MMC?

@ Dat - Can you tell me where I can find the native SDCard driver in NETMF?

In my post #15. You can make new project, paste those code and it should work.
Try different frequency clock (Mount(xxxx)). Almost cards will be happy from 8-12MHz.

By using my code at post #15, if it doesn’t work, it will throw out something and following those exception, we probably know what should to do next.
SD Gadgeteer driver that you are using just a wrapper of those code, it helps you to be easier, faster when write code, but sometime we need go to lower layer a bit to see if there has a problem.

@ mflume - I only know from former posts and documentation that FAT16 and FAT32 should work. I have no ecpierence with different blocksizes. My knowledge about sd-cards is very limited.

try them all in FAT32 and keep others as default is the one I usually do.

I don’t think so.

@ Dat-
I have found no using directive / library to access the SDCard as described in your example.
I found an example similar to yours in an old beginners guide using “using GHIElectronics.NETMF.IO;”
Unfortunately I am not able to find this. Maybe you moved it.
I only find the “GTM.GHIElectronics.SDCard” but there is no Mount - Method where I can change the clock.
Any hint?

@ Dat-
Ok I found "GHI.IO.Storage.SDCard"
I tried the following:
I created a Gadgeteer App without a SDCard added.
Then I inserted your program.
The program is compiled without error. But I get a “Check your hardware” if I try to deploy it.
No Idea what is wrong. Do I have to connect to a socket? But how??
Here’s the code:


using Gadgeteer.Modules.GHIElectronics;
using System;
using System.IO;
using System.Collections;
using System.Threading;
using GHIElectronics.Gadgeteer;
using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using GHI.IO.Storage;
using Microsoft.SPOT;
using Microsoft.SPOT.IO;

namespace SD_Test_GHI_01
{
    public partial class Program
    {
        //static string _root;
        Thread sdThread;

        void ProgramStarted()
        {
            sdThread = new Thread(CheckSD);
            sdThread.Start();
            Debug.Print("Program Started");
        }

        private string toString(byte[] bytes)
        {
            string _result = new string(System.Text.Encoding.UTF8.GetChars(bytes));
            return _result;
        }

        void CheckSD()
        {
            // Which one to use?? - which soket ????
            GHI.IO.Storage.SDCard sdPS = new GHI.IO.Storage.SDCard();
            //GHI.IO.Storage.SDCard sdPS = new GHI.IO.Storage.SDCard(SDCard.SDInterface.SPI);
            //GHI.IO.Storage.SDCard sdPS = new GHI.IO.Storage.SDCard(SDCard.SDInterface.MCI);
            
            sdPS.Mount(8000); // try at 8MHz - 12MHz - 16MHz - 24 MHz
            VolumeInfo vol = VolumeInfo.GetVolumes()[0];
            if (vol.IsFormatted == false)
            {
                Debug.Print("Mount Failed...!");
            }
            else
            {
                Debug.Print("Mount OK....");
                Debug.Print("Label = " + vol.VolumeLabel);
                Debug.Print("Size = " + vol.TotalSize);
            }
        }
    }
}

@ mflume - just run your code on a spider II Mainboard.
Works with no issues.
Is the FAT of your SD-Card o.K.?

Card and FAT are o.k. if I try them on my PC or another controller.
At the moment I am quite sure, that it depends on the card if it works or not.
e.g. all my (10) small Sandisk cards don’t work. Same sized Panasonic Cards work with no problems.
Two of the cards shipped together with the 15 readers I baught don’t work. They work on PC. The others work together with the GHI - cardreader without problems.
Maybe it would help if GHI would give the possibility of setting the clock in their library.

@ mflume - just tried a 1 GB Sandisk Card, … worked for me.
did you try it with another Mainboard (e.g. Spider)?
Did you try Mike’s suggestion to use the cards with USB readers?

@ RoSchmi -
until now I did not try it with another mainboard, because I use the Reaper boards in my lessons so that this is my main target.
Unfortulately I have no USB - connector to plug in a USB - Cardreader.
As I have those GHI - cardreaders for all my pupils I would like to have them - pupils and readers :wink: - working.
I did not expect that SD - cards would make such big problems, since I use them for years now with other controllers - e.g. ATMega without problems.

@ RoSchmi -
regarding yourSandisk - card:
My Sandisk cards are quite old and have only 32 MB. Maybe yours is faster. That’s why I think reducing the clock speed would be a good idea.
btw. my Panasonic cards have the same age with a capacity from 16, 64, 128 MB and work without problems.

whats your paypal address, I’ll send you $20 and you can go buy a dozen 1Gb cards. If we get a few others to chip in we might get you to 2Gb or 8Gb cards…

1 Like

@ Brett-
thank you for your offer.
But I want to make sure that this was not the point for me to start this thread although we have a lack of money in my school all the time.
The reason was, that my pupils came to their lessons with their own (old) SD-cards and were disappointed that they did not work.
So I started a research as I did not believe that there would be a general problem.
I had to find out that it is so.
That’s why I started the thread hoping that might influence your developers to focus on this issue for the final release of you software package.

I didn’t really think that you were coming at it from that angle. I personallu just think that for the cost of “remediation”, the impact of this is relatively small and it’s easy to work past it.

@ mflume -

[quote]
The program is compiled without error. But I get a “Check your hardware” if I try to deploy it.[/quote]
Hi, just start VS → File → New Project → Micro Framework → Console Application → Click OK.

Easy way to get out of this is, reflash the board.