Cerberus SD card .NETMF 4.3 "'System.Exception' occurred in GHI.Hardware.dll"

Hi guys,

Yet another simple thing that I can’t seem to fix:

the code


            if (sdCard.Mount())
            {
                Debug.Print("sd root dir: " + sdCard.StorageDevice.RootDirectory);
                sdCard.Unmount();
            }
            else 
            {
                Debug.Print("Failed to mount the SD card!");
            }

the output

[quote]Using mainboard GHI Electronics FEZ Cerberus version 1.3
A first chance exception of type ‘System.Exception’ occurred in GHI.Hardware.dll
A first chance exception of type ‘System.Exception’ occurred in GHI.Hardware.dll
Failed to mount the SD card![/quote]

I’ve found a mix of examples, but something easy as mounting the SD card fails …

Any help would be much appreciated :smiley:

@ thisway.ro - Can you verify that sdCard.IsCardInserted is true and that IsCardMounted is false? Can you try to format the card on your computer?

@ thisway.ro -

2 things:

  • Connection is bad. Check wire, socket…
  • Cerb is not happy with that SD. Reformat by PC or change different card.

@ John - yes, IsCardInserted has the value 1 and IsCardMounted the value 0. I have formatted it as FAT without any different result

@ Dat - the connection is good :slight_smile:

I have changed the code a bit, but no luck:


while (!sdCard.IsCardMounted)
            {
                Debug.Print("SD card not mounted yet ...");
                sdCard.Mount();
                Thread.Sleep(1000);
            }

            if (sdCard.IsCardMounted)
            {
                Debug.Print("sd root dir: " + sdCard.StorageDevice.RootDirectory);
                sdCard.Unmount();
            }
            else 
            {
                Debug.Print("Failed to mount the SD card!");
            }

[quote]A first chance exception of type ‘System.Exception’ occurred in GHI.Hardware.dll
SD card not mounted yet …
A first chance exception of type ‘System.Exception’ occurred in GHI.Hardware.dll
SD card not mounted yet …
[/quote]

and this goes on forever …

@ thisway.ro -

Make new project, non-gadgeteer, deploy tiny code below, it can check what problem is.

using System;
using System.Threading;
using System.IO;
using Microsoft.SPOT;
using Microsoft.SPOT.Hardware;
using Microsoft.SPOT.IO;


using GHI.IO;
using GHI.IO.Storage;

class Program
{
    static SDCard sd_card = null;
    static InputPort button = new InputPort((Cpu.Pin)xx, false, Port.ResistorMode.PullUp);
    public static void Main()
    {

        while (button.Read())
        {
                  Thread.Sleep(100);
                  Debug.print("Wait for pressing the button");
        }
       
         sd_card = new SDCard();
          // if exception here:
          // +  Check wire or connection
          // +  Try diffirent card.
          sd_card.Mount();
          // if exception here:
          // +  reduce SD clock
           // +  Format FAT32 by PC
          Debug.Print("SD Mounted");

    }
}