Hydra sdCard NOT working!

Have you tried a different card? Have you checked your power source?

Tested two different card (One FAT and one FAT32). Same problem. What do you mean by Power Source? I’m connected to my PC by USB. I also made a test with a 12V dual power.

If you are interested in shipping us your card, we can test it here for you.

I’m interested to ship you my card module, my SDCard and my Hydra board. I’m also having problem with I2C (http://www.tinyclr.com/forum/21/6160/#/2/msg59125)

So, what is the method? You can contact me by email in my GHI account.

email ghi please ghielec@ ghi…

Hello guys,
I have the same Problem mentioned above:

Basically i get the exception when i first run the debugger and when i physically remove the SD Card from the module and reinsert it again the event fires properly… Note i had similar issue with the spider that was fixed in the latest 24 FEB SDK…

here are my Hydra infor and the error:


HalSystemInfo.halVersion:               4.1.2821.0
HalSystemInfo.halVendorInfo:            Microsoft Copyright (C) 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 (C) Microsoft Corporation.  All rig
ClrInfo.targetFrameworkVersion:         4.1.2821.0
SolutionReleaseInfo.solutionVersion:    4.1.3.1
SolutionReleaseInfo.solutionVendorInfo: Copyright (C) GHI Electronics, LLC
SoftwareVersion.BuildDate:              Feb 23 2012
SoftwareVersion.CompilerVersion:        410462
FloatingPoint:                          True
SourceLevelDebugging:                   True
ThreadCreateEx:                         True
LCD.Width:                              320
LCD.Height:                             240
LCD.BitsPerPixel:                       16
AppDomains:                             True
ExceptionFilters:                       True
IncrementalDeployment:                  True
SoftReboot:                             True
Profiling:                              False
ProfilingAllocations:                   False
ProfilingCalls:                         False
IsUnknown:                              False


and visual Studio Debug Error:


The thread '<No Name>' (0x2) has exited with code 0 (0x0).
Using mainboard GHIElectronics-FEZHydra version 1.0
    #### Exception System.Exception - CLR_E_FAIL (1) ####
    #### Message: 
    #### GHIElectronics.OSH.NETMF.Hardware.StorageDev::MountSD [IP: 0000] ####
    #### GHIElectronics.Gadgeteer.FEZHydra::_MountStorageDevice [IP: 0003] ####
    #### Gadgeteer.Modules.GHIElectronics.SDCard::MountSDCard [IP: 0012] ####
    #### Gadgeteer.Modules.GHIElectronics.SDCard::.ctor [IP: 007f] ####
    #### GadgeteerApp4.Program::InitializeModules [IP: 0016] ####
    #### GadgeteerApp4.Program::Main [IP: 0010] ####
A first chance exception of type 'System.Exception' occurred in GHIElectronics.OSH.NETMF.Hardware.dll
SDCard ERROR : Error mounting SD card - no card detected.
Program Started
Physically Mounted the SD Card Note how the unmount event never fired either...
PulseDebugLED called
PulseDebugLED called

and my Application:



        void ProgramStarted()
        {
            sdCard.SDCardMounted += new SDCard.SDCardMountedEventHandler(sdCard_SDCardMounted);
            sdCard.SDCardUnmounted += new SDCard.SDCardUnmountedEventHandler(sdCard_SDCardUnmounted);
            button.ButtonPressed += new Gadgeteer.Modules.GHIElectronics.Button.ButtonEventHandler(button_ButtonPressed);
            Debug.Print("Program Started");
        }

        void sdCard_SDCardUnmounted(SDCard sender)
        {
            Debug.Print("unmouted sd Card");
        }

        private void sdCard_SDCardMounted(SDCard sender, GT.StorageDevice SDCard)
        {
            Debug.Print("sd Card is Mounted");
            for (int i = 0; i < 50; i++)
            {
                Thread.Sleep(100);
                PulseDebugLED(); //turn on the Mainboard LED so i can test it when running stand alone..
            }
        }
}

thank you.

Did you try updating the firmware on the Hydra since it fixed it for you last time on the Spider?

Steve is asking if the “gadgeteer” SDK is updated, not the firmware on hydra.

Also, please try different SD cards.

i have the latest SDK Feb 24 2012 installed…

the SD Card is fine and it works in the Hydra, i can read it fine…

What is not working are the MOUNT and UNMOUNT events which are not raised properly… causing an Issue only when the Hydra is first booted…and the card is inserted…

So if i have the card inserted and started the Hydra i get the exception shown earlier…
If i do not insert the Card and start the Hydra and then insert the card after Hydra has started then the SD Card Events are raised and i can read the card…

Please test it in your lab and let us know if you are experiencing similar issues.
another tip: if i insert the card right after the reboot message show in the output window of Vs2010 the Sd card event is raised properly… and the card can be accessed…

thank you…

Ummm, call me silly but you should only get event when the card is actually inserted or removed, i.e. when the state changes while the board is running. If the card is already in place at boot time then why would an event be fired?

On my PC if I plug a USB thumb drive in an event is raised which causes a pop up screen to open. If the USB drive is in place when I boot the PC that does not happen.

Your code could try to mount the SD card on boot up or look at the state of the SD card inserted switch on boot up to see if the card is present.

Well actually Jeff, not really…
in your PC the event do actually get raised when the system boots they are just different types of Events that’s how you get the USB or SDCard to show under my computer … basically it was detected when the system was started and an Icon was associated to it… let assume for a minute your PC would behave like the current Hydra… basically you would start your PC go to my Computer even though you have an SDCard inserted you will not see the icon… therefore they only way to get that icon is to Take the card and reinsert it again…

so why it should be fixed you ask… well imaging you have a device that has it’s application runnning off of the SD Card like pixy2 so basically when the device first starts it should raise the event that the card is mounted and load your application/settings… the current behavior is to ask the user to take out the card and reinsert it… NOT good…

Simply put the Spider behaves correctly now when it starts it mounts the card and raises the event…
on the Hydra it tires and fails…

anyway after tracing the code i found it failing here:


SDCard.cs latest change set from gadgeteer site
this is the code that raises the exception...
Mainboard.MountStorageDevice("SD");


Now does anyone know where to get the Source Code for GHIElectronics.OSH.NETMF.Hardware.StorageDev

i can’t seem to find it on gadgeteer.CodePlex…
Jay.
thanks.

It is there:

[quote]Well actually Jeff, not really…
in your PC the event do actually get raised when the system boots they are just different types of Events that’s how you get the USB or SDCard to show under my computer …[/quote]

An “inserted” or “removed” event only makes sense if it is raised when the card is actually inserted or removed (I think). When a PC starts up it enumerates any devices it finds on the various buses but it does not do the same thing as when you insert a memory stick when the machine is running.

Let’s say things work the way you want. When the board boots up a SD card inserted event is raised, but what if your initialization code in main has not even registered your inserted event handler yet? Well, then nothing happens, just like you are seeing now. This is a recipe for a race condition, sometimes it might seem to work, other times it will not.

What you should do is all the initialization that needs to be done when your program starts, then look to see if the card is present, then see if it is the right card, and then read what you need to from the card. This method will always work the same way every time.

The point that I am trying to get across is that an inserted/removed event is not the proper mechanism to check to see if an SD card is present at boot time. You have NO guarantee what state the board will be in when the event is thrown so there is no way you can handle it properly in the event handler.

Thanks Guys…

@ Architect hmm i thought Hydra uses the C# NetMF MoutFileSystem like the spider… see below…

here is the code that crashes:


FileName: FEZHydra.cs

     void _MountStorageDevice(string volumeName)
        {
            //_storage = new GHIOSH.StorageDev;
            //_storage.MountFileSystem();
            GHIOSH.StorageDev.MountSD();

            //make sure to send event
        }


i also noticed that the above code is a bit different from what’s in the FezSpider.cs which has:


            _storage = new PersistentStorage(volumeName);
            _storage.MountFileSystem();

@ Jeff

the sme issue even when i try to mount the sdcard throught code i get teh same exact exception see the code below:


         Debug.Print(sdCard.IsCardInserted.ToString() ); //returns true.
            Debug.Print(sdCard.IsCardMounted.ToString());//returns false
            sdCard.MountSDCard(); //crashes with the same exact exception as above.
            Debug.Print(sdCard.IsCardMounted.ToString());

any ideas?