Main Site Documentation

Spider - SD Card ERROR


#1

Hello!

Today I thought I would try out the SD card module but am getting a problem:

“SDCard ERROR : Error mounting SD card - no card detected.”

I went through the SD card info and program examples and put in all the assemblies, etc.
(I put in the premium assemblies).

I’m using an 8GB HD video SanDisk SD card which works fine with my camera.
When I insert it into the SD module, I get the above error after about 1 second.

Note that this line of code works ok - just showing that the sdCard is connected ok
to socket 5 (F type):
if (!sdCard.IsCardInserted || !sdCard.IsCardMounted)
{
Debug.Print( “SDCard is missing.”);
}

Note that when I insert the card, none of these events trigger, instead I just get the error.

sdCard.SDCardMounted += new GTM.GHIElectronics.SDCard.SDCardMountedEventHandler(sdCard_SDCardMounted);

sdCard.SDCardUnmounted += new GTM.GHIElectronics.SDCard.SDCardUnmountedEventHandler(sdCard_SDCardUnmounted);

Note that if I start the program with the card already inserted, I get the error before this line of code is called:

   void ProgramStarted()
    {
        sdCard.MountSDCard();
             ...........
    }

Then if I continue, I get the error again when sdCard.MountSDCard(); gets called.
Not sure what to do - from the documentation, it sounds like pretty much any SD card will work.

Also, if I try to create a persistent object as shown in the example 3 premium access of the sd module code examples -
pStore = new PersistentStorage(“SD”);

This causes an error window to pop up with this message:
"An unhandled exception of type ‘System.Exception’ occurred in GHI.Premium.IO.dll.

Thanks for your help!


#2

As the SD card been formatted as FAT32?

I believe that Gadgeteer automatically mounts the SD for you.


#3

Mike,

The card is definately formatted as I have some pictures on it and can see it in my camera.
I think the spider is trying to auto mount but gives the error…

As I just read some info on wiki, my card is SDHC - which means high capacity.

It looks like there are two kinds of HC - 1 below 7,8gig and and 1 above 7.8 gig.

below 7.8 gig uses FAT 32 -------> partition type 0Bh
above 7.8 gig uses FAT 32X ----------> partition type 0Ch

Mine is 8 gig so - I guess my question now is does the SD module support FAT 32X?


#4

@ dave001 - Use FAT32. I have never heard anything about FAT32X support. FAT32 will support a >8GB SD.


#5

Yes Mike, I was planning to try a different SD, but don’t have one right now.
Will have to get one later and try it.

After I do get another card, I’ll post again with the result…

thanks -


#6

Actually, looking on the internet, all I see are SDHC cards 8gig or greater, so
I kind of doubt that my card is the problem. I would guess the netmf file system
has to support FAT32X, otherwise, it wouldn’t support any of the cards out there
today…

I think most of the cards out there now use FAT32X…


#7

@ dave001 - You are assuming that FAT32X is required for cards >8GB. That is not true. FAT32 supports >8GB. I have used a FAT32 formatted 128GB SSD with NETMF. Reformat your SD with FAT32.


#8

Ok,

I think the wiki definition threw me off.

Anyway, I checked the format of the card and it is actually FAT32 (not FAT32X).

I reformatted it again to FAT32 anyway, just to give it a try, but I have the same problem.

I started a new project and tried to really simplify this so here is my code and the error:

using System;
using System.IO;
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.Presentation.Shapes;
using Microsoft.SPOT.Touch;
using Microsoft.SPOT.IO;

using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;
using GHI.Premium.IO;

namespace sdtest
{
public partial class Program
{
// This method is run when the mainboard is powered up or reset.
void ProgramStarted()
{

        Debug.Print("Program Started");
    }
}

}

So, you can see I am basically doing nothing. I start the program with an empty
SD module.
Then I insert the card and after 1 second get this :

Using mainboard GHI Electronics FEZSpider version 1.0
#### Exception System.Exception - 0xffffffff (1) ####
#### Message:
#### GHI.Premium.IO.PersistentStorage::.ctor [IP: 0000] ####
#### GHIElectronics.Gadgeteer.FEZSpider::MountStorageDevice [IP: 0005] ####
#### Gadgeteer.Modules.GHIElectronics.SDCard::MountSDCard [IP: 000f] ####
#### sdtest.Program::InitializeModules [IP: 0006] ####
A first chance exception of type ‘System.Exception’ occurred in GHI.Premium.IO.dll
SDCard ERROR : Error mounting SD card - no card detected.


#9

try a different SD card. Not everyone works.

I have stopped using SD cards. I use a USB Host module and flash drives. I have never had a problem, and the increased cost is not significant.


#10

Actually, that is a good idea to use the flash drive as it frees up i/o’s in socket 5 and
socket 3 is not really multi-purpose from what I can see.

I think I will end up using the usb host as you suggest, but still would like to see if
the SD module works…

thanks!


#11

Although I will try to get another SD card, I actually think that is not the problem.

I think the real problem has to do with this:

#### Exception System.Exception - 0xffffffff (1) ####
#### Message: 
#### GHI.Premium.IO.PersistentStorage::.ctor [IP: 0000] ####

This is the first part of the exception and as I mentioned in my first post on this subject,
I cannot create a persistent storage object as shown in the example 3 of the sd module
support document. I think the code behind the scenes is also trying to create one of these objects and cannot and that is why I get this problem.

This fails - pops up a window that says " An unhandled exception of type ‘System.ArgumentException’ occurred in GHI.Premium.IO.dll"

namespace sdtest
{
public partial class Program
{
private static PersistentStorage pStore;
private static VolumeInfo pStoreI;

    // This method is run when the mainboard is powered up or reset.   
    void ProgramStarted()
    {
   //      sdCard.MountSDCard();

        initSD();

        Debug.Print("Program Started");
    }
    static void initSD()
    {
        // This bombs!!
        pStore = new PersistentStorage("sdCard");
    }
}

}
anyone know why I cannot create this PersistentStorage object???
above the code, I include a bunch of stuff…

using System;
using System.IO;
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.Presentation.Shapes;
using Microsoft.SPOT.Touch;
using Microsoft.SPOT.IO;

using Gadgeteer.Networking;
using GT = Gadgeteer;
using GTM = Gadgeteer.Modules;
using Gadgeteer.Modules.GHIElectronics;
using GHI.Premium.Net;
using GHI.Premium.IO;

thanks!


#12

@ dave001 -

I remember there are just “SD” or “SD_SPI” in premium, not sure if we have “sdCard”


#13

Thanks Dat,

I originally tried “SD” as I just copied it from the example, but it gave me that exception, so I was just experimenting by changing to “sdCard” to see if that would do anything.

anyway, I won’t be able to work on this till next week, I’ll bring in another card see if it makes a difference - I don’t know how this PersistentStorage works, but it seems I have to be able to create one of these objects, either in my code or I think maybe some dll tries to do it.

But, as I say, it won’t instantiate in my code using “SD”.


#14

Here is an update!

I finally got the chance to get back on this.

  1. I got a new SD card and it is formatted with FAT 32.
  2. It still fails if the card is inserted!!

This time, I set a breakpoint in the Program.generated.cs file:

    private void InitializeModules() {
        this.usbSerial = new GTM.GHIElectronics.UsbSerial(4);
        this.display_T35 = new GTM.GHIElectronics.Display_T35(14, 13, 12, Socket.Unused);
        this.extender = new GTM.GHIElectronics.Extender(9);
        this.usbClientDP = new GTM.GHIElectronics.UsbClientDP(1);
        this.sdCard = new GTM.GHIElectronics.SDCard(5);   
    }

If the card is already inserted, then I see the error as soon as I step over the last line in InitializeModules().
Here is the error in the debug output when I start the program with the card already
inserted:

Using mainboard GHI Electronics FEZSpider version 1.0
#### Exception System.Exception - 0xffffffff (1) ####
#### Message:
#### GHI.Premium.IO.PersistentStorage::.ctor [IP: 0000] ####
#### GHIElectronics.Gadgeteer.FEZSpider::MountStorageDevice [IP: 0005] ####
#### Gadgeteer.Modules.GHIElectronics.SDCard::MountSDCard [IP: 000f] ####
#### led_Sim.Program::InitializeModules [IP: 002f] ####
A first chance exception of type ‘System.Exception’ occurred in GHI.Premium.IO.dll
SDCard ERROR : Error mounting SD card - no card detected.

If I run the program without the card inserted, I get no problem until I insert it, then I get this:

#### Exception System.Exception - 0xffffffff (1) ####
#### Message: 
#### GHI.Premium.IO.PersistentStorage::.ctor [IP: 0000] ####
#### GHIElectronics.Gadgeteer.FEZSpider::MountStorageDevice [IP: 0005] ####
#### Gadgeteer.Modules.GHIElectronics.SDCard::MountSDCard [IP: 000f] ####
#### System.Reflection.MethodBase::Invoke [IP: 0000] ####
#### Gadgeteer.Program::DoOperation [IP: 001a] ####
#### Microsoft.SPOT.Dispatcher::PushFrameImpl [IP: 0054] ####
#### Microsoft.SPOT.Dispatcher::PushFrame [IP: 001a] ####
#### Microsoft.SPOT.Dispatcher::Run [IP: 0006] ####
#### Gadgeteer.Program::Run [IP: 0020] ####

A first chance exception of type ‘System.Exception’ occurred in GHI.Premium.IO.dll
SDCard ERROR : Error mounting SD card - no card detected.

It seems like maybe my SD module is defective???
Does anyone out there understand this kind of problem?

thanks!


#15

Also, I am wondering from looking at various documentation if I need to add for SD Card
using GHIElectronics.NETMF.IO;

But, I am currently not able to add this reference as it does not appear in my list of available
references. I’m pretty new to this C# VStudio dev env. but currently see no way to
add this if in fact I do need it.

I already have these references among others:
using Microsoft.SPOT.IO;
using GHI.Premium.IO;

thanks!


#16

@ dave001 -
Hi,
if you have a Spider Mainboard and if you added the SD-Card-Module with the designer you can use the following code in Program.Starded, the Card must be inserted:
the code Mounts the sd-card and Shows the files in root.


                    //Mount SD-Card
                    sdCard.MountSDCard();
                    System.Threading.Thread.Sleep(500);
                    String rootDirectory = sdCard.GetStorageDevice().RootDirectory;
                    if (VolumeInfo.GetVolumes()[0].IsFormatted)
                    {
                        _root = VolumeInfo.GetVolumes()[0].RootDirectory;
                        string[] files = Directory.GetDirectories(_root);
                        for (int i = 0; i < files.Length; i++)
                        {
                            // Debug.Print(files[i]);
                        }
                    }
                    else
                    {
                        Debug.Print("Cannot use SD-Card");
                    }

Cheers Roland


#17

Hi Roschmi,

Of course, I already tried that a couple of weeks ago.
There are a lot of messages on this thread, I think the important thing to consider
now is this:

I do add the sd card with the designer and the designer generated code fails before
I even get a chance to try to mount anything.

Program.generated.cs

This.sdCard = new GTM.GHIElectronics.SDCard(5); // This fails!!!

It causes the error I showed a couple of posts ago.

When you run with the SD Card, do you include GHIElectronics.NETMF.IO?
Please indicate what assemblies are need and/or why would generated code fail?

thanks! I’ve been fighting this problem for a couple of weeks now and getting nowhere…


#18

Sorry, that I did not read everything.
In an appllication where I ued the SD-Card i included the following reference:

Microsoft.SPOT.IO
Microsoft.Spot.Hardware
GHI.Preminum.IO
GHI.Premium.System

I cannot say at the Moment, if all where needed for the SD-Card module.

I think that I did not include GHIelectronics.NETMF.IO
but I cannot say for sure as at the Moment I do not have access to the code for spider

Anyway the right reference should have been added by the designer.
Did you try new cables from power module to Spider and from Spider to the SD-Card module?

As a next step I would try the Code without having the display module connected, it could be a power issue.


#19

Hi RoSchmi,

I have the references you listed.

I tried it with the display unplugged and only the sd module but get the same problem.

It bombs in the generated code.

I suppose it is possible the sdmodule h/w has a problem and cannot detect the card, so it says there is no card inserted.

I have tried 2 different sd cards, one just recently purchased but same problem…


#20

@ dave001 - Did you get it working? If not, do you have anything attached to the extender?