Can't mount my microSD Card.. PLEASE HELP

Hello everyone…

I have a C# .Net Micro Framework that look like this:

using System;
using System.Collections;
using System.Threading;
using Microsoft.SPOT;
using Microsoft.SPOT.Presentation;
using Microsoft.SPOT.Presentation.Controls;
using Microsoft.SPOT.Presentation.Media;
using Microsoft.SPOT.Touch;

using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;

namespace GadgeteerApp3
{
    public partial class Program
    {

        private static double MOVEMENT_INDICATOR = 0.2F;
        private GT.StorageDevice sdKort;

        // This method is run when the mainboard is powered up or reset.   
        void ProgramStarted()
        {
            /*******************************************************************************************
            Modules added in the Program.gadgeteer designer view are used by typing 
            their name followed by a period, e.g.  button.  or  camera.
            
            Many modules generate useful events. Type +=<tab><tab> to add a handler to an event, e.g.:
                button.ButtonPressed +=<tab><tab>
            
            If you want to do something periodically, use a GT.Timer and handle its Tick event, e.g.:
                GT.Timer timer = new GT.Timer(1000); // every second (1000ms)
                timer.Tick +=<tab><tab>
                timer.Start();
            *******************************************************************************************/


            // Use Debug.Print to show messages in Visual Studio's "Output" window during debugging.
            Debug.Print("Program Started");

             sdCard.MountSDCard();
             sdKort = sdCard.GetStorageDevice();
            
       

            Accelerometer accellerometer = new Accelerometer(1);
            accellerometer.ContinuousMeasurementInterval = new TimeSpan(0, 0, 0, 0, 200);

            accellerometer.MeasurementComplete += new Accelerometer.MeasurementCompleteEventHandler(accellerometer_MeasurementComplete);
            accellerometer.StartContinuousMeasurements();

        }

        void accellerometer_MeasurementComplete(Accelerometer sender, Accelerometer.Acceleration acceleration)
        {
           // Debug.Print("Z-acc:" + acceleration.Z);
           // Debug.Print("X-acc:" + acceleration.X);
           // Debug.Print("Y-acc:" + acceleration.Y);

            if (acceleration.Z < MOVEMENT_INDICATOR)
            {
                // notify parents - got movement
                Mainboard.SetDebugLED(true);


                Thread.Sleep(5000);
                Mainboard.SetDebugLED(false);
                byte[] mp3er = sdKort.ReadFile("musik.wav");

                music.Play(mp3er);
              
            }

        }


    }

    
}

I need to mount my MicroSD Card into my Mainboard, so i can play the music in the music module from the MicroSD Card.

But every time i try to start a debugging, I get this error:

SDCard ERROR : Unable to mount SD card. Is card formatted as FAT32?

And the SD Card IS formattet as FAT32…

What could the problem be…?

Please help me…

I have pasted the whole Outline from Visual Studio…:

Found debugger!

Create TS.

 Loading start at 805b980, end 808459c

   Assembly: mscorlib (4.2.0.0)     Assembly: Microsoft.SPOT.Native (4.2.0.0)     Assembly: Microsoft.SPOT.Hardware (4.2.0.0)  
   Assembly: Microsoft.SPOT.Graphics (4.2.0.0)     Assembly: Microsoft.SPOT.TinyCore (4.2.0.0)  
   Assembly: Microsoft.SPOT.Hardware.SerialPort (4.2.0.0)     Assembly: Microsoft.SPOT.IO (4.2.0.0)  
   Assembly: System.IO (4.2.0.0)     Assembly: Microsoft.SPOT.Hardware.OneWire (4.2.0.0)  
   Assembly: Microsoft.SPOT.Hardware.Usb (4.2.0.0)     Assembly: Microsoft.SPOT.Hardware.PWM (4.2.0.1)  
   Assembly: Microsoft.SPOT.Net (4.2.0.0)     Assembly: System (4.2.0.0)  Loading Deployment Assemblies.

Attaching deployed file.

   Assembly: GHI.OSHW.Hardware (4.2.3.1)  Attaching deployed file.

   Assembly: Gadgeteer (2.42.0.0)  Attaching deployed file.

   Assembly: System.Http (4.2.0.0)  Attaching deployed file.

   Assembly: GTM.GHIElectronics.SDCard (1.1.1.0)  Attaching deployed file.

   Assembly: Microsoft.SPOT.Net.Security (4.2.0.0)  Attaching deployed file.

   Assembly: GHIElectronics.Gadgeteer.FEZCerberus (1.1.1.0)  Attaching deployed file.

   Assembly: Microsoft.SPOT.Touch (4.2.0.0)  Attaching deployed file.

   Assembly: GTM.GHIElectronics.Music (1.1.1.0)  Attaching deployed file.

   Assembly: System.Net.Security (4.2.0.0)  Attaching deployed file.

   Assembly: GadgeteerApp3 (1.0.0.0)  Attaching deployed file.

   Assembly: Gadgeteer.SPI (2.42.0.0)  Attaching deployed file.

   Assembly: GTM.GHIElectronics.UC_Battery_4xAA (1.1.1.0)  Resolving.

The debugging target runtime is loading the application assemblies and starting execution.
Ready.

'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.2\Assemblies\le\mscorlib.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Native.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Hardware.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Graphics.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.TinyCore.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Hardware.SerialPort.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.IO.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.2\Assemblies\le\System.IO.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Hardware.OneWire.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Hardware.Usb.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Hardware.PWM.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Net.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.2\Assemblies\le\System.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files (x86)\GHI Electronics\GHI OSHW NETMF v4.2 SDK\Assemblies\le\GHI.OSHW.Hardware.dll'
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files (x86)\Microsoft .NET Gadgeteer\Core\Assemblies\.NET Micro Framework 4.2\le\Gadgeteer.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Net.Security.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.2\Assemblies\le\System.Net.Security.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.2\Assemblies\le\System.Http.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files (x86)\GHI Electronics\GHI .NET Gadgeteer SDK\Modules\SDCard\NETMF 4.2\le\GTM.GHIElectronics.SDCard.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files (x86)\GHI Electronics\GHI .NET Gadgeteer SDK\Mainboards\FEZCerberus\NETMF 4.2\le\GHIElectronics.Gadgeteer.FEZCerberus.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.2\Assemblies\le\Microsoft.SPOT.Touch.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files (x86)\Microsoft .NET Gadgeteer\Core\Assemblies\.NET Micro Framework 4.2\le\Gadgeteer.SPI.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files (x86)\GHI Electronics\GHI .NET Gadgeteer SDK\Modules\Music\NETMF 4.2\le\GTM.GHIElectronics.Music.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Program Files (x86)\GHI Electronics\GHI .NET Gadgeteer SDK\Modules\UC_Battery_4xAA\NETMF 4.2\le\GTM.GHIElectronics.UC_Battery_4xAA.dll', Symbols loaded.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Managed): Loaded 'C:\Users\sccm-unv\Desktop\GadgeteerApp3\GadgeteerApp3\bin\Debug\le\GadgeteerApp3.exe', Symbols loaded.
The thread '<No Name>' (0x2) has exited with code 0 (0x0).
Using mainboard GHI Electronics FEZCerberus version 1.1
SDCard ERROR : Unable to mount SD card. Is card formatted as FAT32?
Program Started
SDCard ERROR : Unable to mount SD card. Is card formatted as FAT32?
Failed allocation for 20 blocks, 240 bytes

The thread '<No Name>' (0x3) has exited with code 0 (0x0).
A first chance exception of type 'System.NullReferenceException' occurred in GadgeteerApp3.exe
Exception performing Timer operation
A first chance exception of type 'System.NullReferenceException' occurred in GadgeteerApp3.exe
Exception performing Timer operation
A first chance exception of type 'System.NullReferenceException' occurred in GadgeteerApp3.exe
Exception performing Timer operation
The program '[1] Micro Framework application: Managed' has exited with code 0 (0x0).


Thank you in advance…

Best regards…
Jacob Lau

Using code tags will make your post more readable. This can be done in two ways:[ol]
Click the “101010” icon and paste your code between the

 tags or...
Select the code within your post and click the "101010" icon.[/ol]
(Generated by QuickReply)

Check this reply from Justin:

http://www.tinyclr.com/forum/topic?id=8556&page=2#msg84904

@ Architect - Hej…
Sorry but the same error still occur when i debug the problem…
Any other suggestions…?

@ jacob.lau1992 - Hi Jacob, can you update you firmware to the latest and greatest and try again?

PS - Welcome :slight_smile:

Have you tried the code in the link I have provided?

@ Architect - Different boards Master Yoda

@ jacob.lau1992 - Try the code from Tutorial page then

//Mount the SD card
sdCard.MountSDCard();
//Get the root directory
string rootDirectory = sdCard.GetStorageDevice().RootDirectory;
//Use Streamwriter to write a text file
StreamWriter textFile = new StreamWriter(rootDirectory + @ "\hello.txt");
textFile.WriteLine("Hello SD card");
textFile.Close();
 
//Use FileStream to read a text file
FileStream fileStream = new FileStream(rootDirectory + @ "\hello.txt", FileMode.Open);
//load the data from the stream
 byte[] data = new byte[fileStream.Length];
fileStream.Read(data, 0, data.Length);
fileStream.Close();
string text = new string(Encoding.UTF8.GetChars(data));
 
Debug.Print(text);

@ Architect - think it will still fail here:

//Mount the SD card
sdCard.MountSDCard();

Looks like his firmware is 2 behind…

@ Justin - Hi Justin…
Do you mean the Mainboards firmware…?

@ Justin - Why? Looks up to date to me. GHI.OSHW.Hardware (4.2.3.1)

@ jacob.lau1992 - Can you try a different card?

@ Architect - 4.2.3.3 is the latest…hmmm or maybe not…

Wiki says 4.2.3.3 but looks like your right as dll is 4.2.3.1

*Edit - i just need to read proper like - as you were…

You could also try this code:


void ProgramStarted()
        {
            Debug.Print("Program Started");
            Debug.Print("SD should be auto-mounted");
            //sdCard.MountSDCard();
            if (sdCard.IsCardMounted)
            {
                VolumeInfo vi = sdCard.GetStorageDevice().Volume;
                Debug.Print(vi.Name);
                Debug.Print(vi.IsFormatted.ToString());
                Debug.Print(vi.FileSystem);
                Debug.Print(vi.TotalFreeSpace.ToString());
 
                string root = sdCard.GetStorageDevice().RootDirectory;
                Debug.Print("Root: " + root);
                Debug.Print("Program Finished");
            }
            else
            {
                Debug.Print("SD Card Failed to mount!");
            }
        }

@ Architect - I have already tried three different MicroSD Card, and all of them has been formatted with FAT232 but causes the same error.

@ jacob.lau1992 - What size is the card, and what standard is it? (SD/SDHC/SDXC/MMC)

@ James - Hi James.
The card is MicroSDHC, and the size is 2GB…

@ stevepresley - Hi Steve.

When I try your code, I get this error, when I starts the debugging:

Using mainboard GHI Electronics FEZCerberus version 1.1
SDCard ERROR : Unable to mount SD card. Is card formatted as FAT32?
Program Started
SD should be auto-mounted
SD Card Failed to mount!
Failed allocation for 20 blocks, 240 bytes

A first chance exception of type 'System.NullReferenceException' occurred in GadgeteerApp3.exe
Exception performing Timer operation
Failed allocation for 66 blocks, 792 bytes

Failed allocation for 66 blocks, 792 bytes

Failed allocation for 39 blocks, 468 bytes

A first chance exception of type 'System.OutOfMemoryException' occurred in mscorlib.dll
Failed allocation for 15 blocks, 180 bytes

Failed allocation for 13 blocks, 156 bytes

Failed allocation for 10 blocks, 120 bytes

Failed allocation for 13 blocks, 156 bytes

An unhandled exception of type 'System.OutOfMemoryException' occurred in mscorlib.dll

@ Justin - Correct Justin.

The error still comming at the mount point