Main Site Documentation

SD Card not working


#1

Hello I don’t managed to make my sd card to work.
Here is the code

void ProgramStarted()
{
	sdCard.DebugPrintEnabled = true;
	sdCard.SDCardMounted += sdCard_SDCardMounted;
	sdCard.MountSDCard();
	Debug.Print("Mounted : " + sdCard.IsCardMounted + ", Inserted : " + sdCard.IsCardInserted);
}

void sdCard_SDCardMounted(SDCard sender, Gadgeteer.StorageDevice SDCard)
{
	Debug.Print("Mounted !");
}

Here is the output :

[quote]Using mainboard GHIElectronics-FEZSpider version 1.0
#### Exception System.Exception - 0xffffffff (1) ####
#### Message:
#### GHIElectronics.NETMF.IO.PersistentStorage::.ctor [IP: 0000] ####
#### Gadgeteer.Modules.GHIElectronics.SDCard::MountSDCard [IP: 000d] ####
#### Gadgeteer.Modules.GHIElectronics.SDCard::.ctor [IP: 007f] ####
#### DhomeBox.Micro.Program::InitializeModules [IP: 0006] ####
#### DhomeBox.Micro.Program::Main [IP: 0010] ####
A first chance exception of type ‘System.Exception’ occurred in GHIElectronics.NETMF.IO.dll
#### Exception System.Exception - 0xffffffff (1) ####
#### Message:
#### GHIElectronics.NETMF.IO.PersistentStorage::.ctor [IP: 0000] ####
#### Gadgeteer.Modules.GHIElectronics.SDCard::MountSDCard [IP: 000d] ####
#### DhomeBox.Micro.Program::ProgramStarted [IP: 0021] ####
#### DhomeBox.Micro.Program::Main [IP: 0015] ####
A first chance exception of type ‘System.Exception’ occurred in GHIElectronics.NETMF.IO.dll
SDCard : Error unmounting SD card - no card detected.
Mounted : False, Inserted : True
[/quote]

Here is the config

[quote]HalSystemInfo.halVersion: 4.1.2821.0
HalSystemInfo.halVendorInfo: Microsoft Copyright © Microsoft Corporation. All rig
HalSystemInfo.oemCode: 255
HalSystemInfo.modelCode: 0
HalSystemInfo.skuCode: 65535
HalSystemInfo.moduleSerialNumber: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
HalSystemInfo.systemSerialNumber: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
ClrInfo.clrVersion: 4.1.2821.0
ClrInfo.clrVendorInfo: Microsoft Copyright © Microsoft Corporation. All rig
ClrInfo.targetFrameworkVersion: 4.1.2821.0
SolutionReleaseInfo.solutionVersion: 4.1.7.0
SolutionReleaseInfo.solutionVendorInfo: GHI Electronics, LLC
SoftwareVersion.BuildDate: Sep 28 2011
SoftwareVersion.CompilerVersion: 410561[/quote]

My SD Card is a microSD adapter SDHC. Works fine on my computer. Do I need it to be in FAT16 or FAT32 ? I tried both but no luck :frowning:

Any idea ?


#2

Dunno if it will totally solve the problem but try something like this instead:

edit: I’m surprised the orginal code even compiles… Did C# change since I learned how to do events? I thought you always had to have a delegate in there…


#3

@ ddurant - the delegate will be inferred if it is not present. You can leave it in for clarity/readability, but it is not required. If the handler’s signature is not correct, you will get a compile error.


#4

I just did an exact replication of your problem, and mine ran fine. Could you give me more information about your program? Is that all that is going on in it right now?

Also, note that the error printed out

is incorrect and will change to the correct output soon. The correct output is “Error mounting SD card - no card detected.”, So that gives you something to look into. Try a different card if you have one.


#5

Has it always been line that?? Hate it when there’s an easy shortcut that everybody but me knows about…


#6

Not sure… even for the full framework. I discovered this about 2 years ago when I started using JetBrains ReSharper (which is a big time saver, BTW).


#7

+1 for Resharper. Well worth the money and it will teach you alot along the way.


#8

I just bought a new SD Card (2 GB), and tried it, nothing change, the card is not detected and cannot be mounted even tought the IsCardInserted works as expected. :’(


#9

Do I need to format in FAT 16 or FAT32 ??


#10

FAT16/FAT32 will work and any SD card of any size will work as well.


#11

I recieve Kingstone SD Card next week, I’ll try.

This card does not work (http://www.amazon.com/SanDisk-Secure-Digital-Memory-SDSDH-002G/dp/B004C5JA5A).

Also, microSD microSDHC Adapter does not seems to work also.


#12

We have used these adapters many times with no problems.


#13

So no suggestion ?
My code is right ?
No known workaround ?


#14

I ordered the exact same card you had used to test it out.


#15

Gus, here’s where a list of short-sharp code “test apps” that perform validation of some core function like SD card would assist - instead of asking whether my code is right or what, you simply load the SD test program that then goes and does its checks - if you fail then the chances are there’s something else wrong other than code.


#16

That’s a good idea, I had the same error on my sd cards as well, so checking this thread from time to time so see what happens :slight_smile:


#17

Hello,

what modules are connected to the mainboard? Only the DualPower and the SD?
I think that it could be usefull to know your modules configuration.
My SD module works fine in my configuration (DualPower, Display, Ethernet, SD) but perhaps any other modules connected to the fez spider could cause the SD problem.

@ Gus: am I right?


#18

In general yes it helps


#19

Yes just DualPower and SD.
Tried another card (http://www.webdistrib.com/cat/Carte-Memoire-SDHC-4Go-jusqu-a-16h-de-film-1000-photos-60h-de-musique--__p_500158.html, sorry I have not found it in english)

Same problem. IsInserted works but I can’t mount.


#20

I just need some byte of storage (50 bytes), is there another solution than SD card ?