Main Site Documentation

Hydra sdCard NOT working!


#1

I updated my hydra last night as described in the hydra wiki and tested it for the first time since purchase. Everything else worked except the sd card. if I run my code a dialog pops up with “An unhandled exception of type ‘System.Exception’ occurred in Microsoft.SPOT.Hardware.dll”. If I switch to my fez spider with exactly the same code, it woks like charm!!!

If I hit ‘continue’ on the error dialog, the code is deployed and runs with this debug msg:

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

‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\Microsoft .NET Micro Framework\v4.1\Assemblies\le\mscorlib.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\Microsoft .NET Micro Framework\v4.1\Assemblies\le\Microsoft.SPOT.Native.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\Microsoft .NET Micro Framework\v4.1\Assemblies\le\Microsoft.SPOT.Hardware.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\Microsoft .NET Micro Framework\v4.1\Assemblies\le\Microsoft.SPOT.Graphics.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\Microsoft .NET Micro Framework\v4.1\Assemblies\le\Microsoft.SPOT.TinyCore.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\Microsoft .NET Micro Framework\v4.1\Assemblies\le\Microsoft.SPOT.IO.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\Microsoft .NET Micro Framework\v4.1\Assemblies\le\System.IO.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\Microsoft .NET Micro Framework\v4.1\Assemblies\le\Microsoft.SPOT.Hardware.Usb.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\Microsoft .NET Micro Framework\v4.1\Assemblies\le\System.Xml.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\Microsoft .NET Micro Framework\v4.1\Assemblies\le\Microsoft.SPOT.Hardware.SerialPort.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\Microsoft .NET Micro Framework\v4.1\Assemblies\le\Microsoft.SPOT.Net.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\Microsoft .NET Micro Framework\v4.1\Assemblies\le\System.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\Microsoft .NET Micro Framework\v4.1\Assemblies\le\Microsoft.SPOT.Touch.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\Microsoft .NET Micro Framework\v4.1\Assemblies\le\Microsoft.SPOT.Ink.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\Microsoft .NET Gadgeteer\Core\Assemblies.NET Micro Framework 4.1\le\Gadgeteer.dll’
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\Microsoft .NET Micro Framework\v4.1\Assemblies\le\Microsoft.SPOT.Net.Security.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\Microsoft .NET Micro Framework\v4.1\Assemblies\le\System.Net.Security.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\Microsoft .NET Micro Framework\v4.1\Assemblies\le\System.Http.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\Microsoft .NET Gadgeteer\Core\Assemblies.NET Micro Framework 4.1\le\Gadgeteer.WebClient.dll’
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\GHI Electronics\GHI NETMF v4.1 SDK\Assemblies\le\GHIElectronics.NETMF.System.dll’
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\GHI Electronics\GHI NETMF v4.1 SDK\Assemblies\le\GHIElectronics.NETMF.IO.dll’
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\GHI Electronics\GHI .NET Gadgeteer SDK\Modules\SDCard\NETMF 4.1\le\GTM.GHIElectronics.SDCard.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\GHI Electronics\GHI OSH NETMF v4.1 SDK\Assemblies\le\GHIElectronics.OSH.NETMF.Hardware.dll’
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\GHI Electronics\GHI .NET Gadgeteer SDK\Mainboards\FEZHydra\NETMF 4.1\le\GHIElectronics.Gadgeteer.FEZHydra.dll’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Users\Stone\Dropbox\My programs\C#\my_fez_hydra\my_fez_hydra\bin\Debug\le\my_fez_hydra.exe’, Symbols loaded.
‘Microsoft.SPOT.Debugger.CorDebug.dll’ (Managed): Loaded ‘C:\Program Files\Microsoft .NET Gadgeteer\Core\Assemblies.NET Micro Framework 4.1\le\Gadgeteer.WebServer.dll’
#### Exception System.Exception - CLR_E_DRIVER_NOT_REGISTERED (2) ####
#### Message:
#### Microsoft.SPOT.Hardware.NativeEventDispatcher::.ctor [IP: 0000] ####
#### GHIElectronics.NETMF.System.InternalEvent::.cctor [IP: 0014] ####
An unhandled exception of type ‘System.Exception’ occurred in Microsoft.SPOT.Hardware.dll

Uncaught exception
The thread ‘’ (0x2) has exited with code 0 (0x0).
Using mainboard GHIElectronics-FEZHydra version 1.0
#### Exception System.NotSupportedException - CLR_E_NOT_SUPPORTED (1) ####
#### Message:
#### Gadgeteer.Modules.GHIElectronics.SDCard::MountSDCard [IP: 000d] ####
#### Gadgeteer.Modules.GHIElectronics.SDCard::.ctor [IP: 007f] ####
#### my_fez_hydra.Program::InitializeModules [IP: 0006] ####
#### my_fez_hydra.Program::Main [IP: 0010] ####
A first chance exception of type ‘System.NotSupportedException’ occurred in GTM.GHIElectronics.SDCard.dll
SDCard ERROR : Error mounting SD card - no card detected.

Please Help me!


#2

Compare release notes files on your pc with ones on this website please


#3

Thanks for your response, from the release notes, I have installed -

GHI NETMF v4.1 SDK Build Date: 11:01 AM 1/6/2012

GHI NETMF SDK v1.0.18 12/21/2011
GHI .NET Gadgeteer SDK v1.0.3.0 1/5/2012
GHI OSH NETMF SDK v1.0.2 1/6/2012

Thanks


#4

Good, you have the latest SDK. Now, what is the firmware version on your hydra? Use “device capabilities” in mfdeploy.


#5

Device capabilities from mfdeploy:

Pinging… TinyCLR
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.2.1
SolutionReleaseInfo.solutionVendorInfo: Copyright © GHI Electronics, LLC
SoftwareVersion.BuildDate: Jan 6 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


#6

Ok so we now know you have the latest SDK and the latest firmware http://tinyclr.com/release-notes/ which is 4.1.2.1
And as the release notes says in the latest “Added SD card capabilities. This feature is in beta.” I am trying to help you so you know where to find all this info in future.

After verifying the version, now we can look into the issue! You showed unsupported exception which shouldn’t be the case but you also didn’t show the code behind it so I am not sure how to help.


#7

I just noticed you saying you tried the code on spider.

spider falls in the non-open library it uses GHIElectroncis.NETMF
hydra falls in the open library and it uses GHIElectronics.OSH.NETMF

If you do not change the included assemblies then your project will not work. Probably get the unsupported exception as well, as it is “unsupported”

Hope this helps


#8

Here is the code:


using System;
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;
using GHIElectronics.OSH.NETMF;

namespace my_fez_hydra
{
    public partial class Program
    {

        bool firstDismount = true;

        void ProgramStarted()
        {
            sdCard.DebugPrintEnabled = true;
            sdCard.SDCardMounted += sdCard_SDCardMounted;
            sdCard.SDCardUnmounted += sdCard_SDCardUnmounted;

            if (sdCard.IsCardMounted)
                sdCard.UnmountSDCard();
        }

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

        void sdCard_SDCardUnmounted(SDCard sender)
        {
            Debug.Print("Unmounted !");
            if (firstDismount)
            {
                Debug.Print("remounting card!");
                firstDismount = false;
                sdCard.MountSDCard();
            }
        }


    }
}


Thanks alot


#9

Have you tried other cards?


#10

I have 5 different cards with me here from 256mb to 16gb; none works. They all work on spider though.


#11

We will dig further into this. The SD support is beta as reported in the release notes.

As you know, this is an open source platform is you wanted to dig into the SD driver source codes.


#12

I have tried the SD Card module and I get an unhandled exception of type “System.Exception” in Microsoft.SPOT.Hardware.dll

My code do nothing with the module. It is only dropped into GUI designer and connected to socket 8.

When I go to debug in Visual Studio, I get the error. My Fez Hydra firmware is updated and I use the same version of SDK as KUSTOMIZER.


#13

Can you do this funny test :

1.Pinch and hold the SD Card module with your thumb and fore finger in a way that the thumb is over the connector and the forefinger behind the board. (the module should be connected to the mainboard ! )

2.Run you application from Visual Studio a few times to see if atleast one attempt mounts the card.

If you are able to get the SD Card to work at random using this method, let me know.


#14

Rajesh,
tried your ‘not so funny test’ without any luck.


#15

Kustomizer,

Currently the SD Card module drivers are dependent on FEZ Spider to work correctly. We are working with Microsoft to make this more generic. You can make a Gadgeteer project without adding the SD Card Module to the designer.

You will need to include the following in your project and code:
Assembly: GHIElectronics.OSH.NETMF.Hardware

using GHIElectronics.OSH.NETMF.Hardware;

StorageDev.MountSD();
StorageDev.UnmountSD();

After mounting, VolumeInfo, Directory, FileStream, etc. will work.


#16

It worked!! thanks to Aron!!


#17

@ KUSTOMIZER

Could you give a sample code of what you did, because I have the exact same problem than you and I wish to use my SD Card module.

The only difference is that I’m using SDK version 4.1.3.1


#18

@ KUSTOMIZER, jango_jas

The OSH SD Card for Gadgeteer now works properly under the new firmware and SDK. Add the SD Module as normal then add these lines of code in the ProgramStarted():


sdCard.SDCardMounted += new SDCard.SDCardMountedEventHandler(sdCard_SDCardMounted);
sdCard.SDCardUnmounted += new SDCard.SDCardUnmountedEventHandler(sdCard_SDCardUnmounted);

For the two event handlers this is some basic code that should work for you:


        void sdCard_SDCardUnmounted(SDCard sender)
        {
            Debug.Print("Unmounted");
        }

        void sdCard_SDCardMounted(SDCard sender, GT.StorageDevice SDCard)
        {
            Debug.Print("mounted");

            Debug.Print("Getting files and folders:");
            if (VolumeInfo.GetVolumes()[0].IsFormatted)
            {
                string rootDirectory =
                    VolumeInfo.GetVolumes()[0].RootDirectory;
                string[] files = Directory.GetFiles(rootDirectory);
                string[] folders = Directory.GetDirectories(rootDirectory);

                Debug.Print("Files available on " + rootDirectory + ":");
                for (int i = 0; i < files.Length; i++)
                    Debug.Print(files[i]);

                Debug.Print("Folders available on " + rootDirectory + ":");
                for (int i = 0; i < folders.Length; i++)
                    Debug.Print(folders[i]);
            }
            else
            {
                Debug.Print("Storage is not formatted. Format on PC with FAT32/FAT16 first.");
            }


#19

Thanks alot!


#20

I did the test with the code provided and I get the following message when I insert a card. I’m using the latest firmware. The one published by february 24th. my card is formated in FAT and is working on a Windows 7 PC.

I created an new gadgeteer project and aded sdCard module. I also added two “using” in the code.
[italic]using Microsoft.SPOT.IO;
using System.IO[/italic];

The error ////////////////////////////////

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::_sdCardDetect_Interrupt [IP: 000a] ####
#### Gadgeteer.Interfaces.InterruptInput::OnInterruptEvent [IP: 0055] ####
#### System.Reflection.MethodBase::Invoke [IP: 0000] ####
#### Gadgeteer.Program::DoOperation [IP: 001a] ####
#### Microsoft.SPOT.Dispatcher::PushFrameImpl [IP: 004a] ####
#### Microsoft.SPOT.Dispatcher::PushFrame [IP: 001d] ####
#### Microsoft.SPOT.Dispatcher::Run [IP: 0006] ####
#### Gadgeteer.Program::Run [IP: 001c] ####
#### GadgeteerApp1.Program::Main [IP: 001a] ####

Une exception de première chance de type ‘System.Exception’ s’est produite dans GHIElectronics.OSH.NETMF.Hardware.dll
SDCard ERROR : Error mounting SD card - no card detected.