Main Site Documentation

SD problem on Rhino OEM kit


#1

Hello all,

it seems my Rhino OEM kit has some problems reading from SDs. The display and the wiznet ethernet module are working fine.

Here is the code I’m using for accessing the SD (it is that of the beginners book):

using System;
using System.Threading;

using Microsoft.SPOT;
using Microsoft.SPOT.IO;
using Microsoft.SPOT.Hardware;

using GHIElectronics.NETMF.FEZ;
using GHIElectronics.NETMF.IO;
using System.IO;
using System.Text;

namespace FEZ_Rhino_Application1
{
    public class Program
    {
        public static void Main()
        {
                PersistentStorage mSD = new PersistentStorage("SD");
                mSD.MountFileSystem();         
                string rootDirectory = VolumeInfo.GetVolumes()[0].RootDirectory;
                FileStream fileHandle = new FileStream(rootDirectory + @ "\records.txt", FileMode.Open, FileAccess.Read);
                byte[] data = new byte[100];
                int readCount = fileHandle.Read(data, 0, data.Length);
                fileHandle.Close();
                Debug.Print("The size of data we read is: " + readCount.ToString());
                Debug.Print("data from file:");
                Debug.Print(new string(Encoding.UTF8.GetChars(data),0, readCount));                
                mSD.UnmountFileSystem();

            }

        }

    }

I get the error on line

FileStream fileHandle ...

Attached you can find the screenshot of the error.
Using an external power supply (7.5 volts, 500mA) I received the same error.
Same code and same SD card are working using a fez domino without external power supply.
The SD card is FAT32. I also try to format the SD card using FAT16. Nothing. I read all the posts regarding this problem. Someone solve the problem paralleling a capacitor on C10 but that was on a Domino and not on a Rhino.
All the Rhino IOs are not used.

Gurus, any idea?

Bye!

Ste.


#2

Taking a guess here…

Have you made sure you have the latest and matching firmware and GHI SDK installed? NotSupported errors tend to be related to that kind of thing. And make sure if you do have to reinstall SDKs that you create a new project.


#3

Wow, good suggestion. Before deploying the software I checked the SDK version and firmware. But I’m going to check again… I will be back in few minutes…


#4

Result of the MFDeploy -> Target -> Device capabilities

Pinging… TinyCLR
HalSystemInfo.halVersion:
HalSystemInfo.halVendorInfo:
HalSystemInfo.oemCode: 0
HalSystemInfo.modelCode: 0
HalSystemInfo.skuCode: 0
HalSystemInfo.moduleSerialNumber:
HalSystemInfo.systemSerialNumber:
ClrInfo.clrVersion: 4.1.2821.0
ClrInfo.clrVendorInfo: Microsoft Copyright © Microsoft Corporation. All rig
ClrInfo.targetFrameworkVersion: 4.1.2821.0
SolutionReleaseInfo.solutionVersion: 4.1.3.0
SolutionReleaseInfo.solutionVendorInfo: GHI Electronics, LLC
SoftwareVersion.BuildDate: Oct 15 2010
SoftwareVersion.CompilerVersion: 310739
FloatingPoint: True
SourceLevelDebugging: True
ThreadCreateEx: True
LCD.Width: 0
LCD.Height: 0
LCD.BitsPerPixel: 0
AppDomains: True
ExceptionFilters: True
IncrementalDeployment: True
SoftReboot: True
Profiling: False
ProfilingAllocations: False
ProfilingCalls: False
IsUnknown: False

File C:\Program Files (x86)\GHI Electronics\GHI NETMF v4.1 SDK\Release Notes.rtf reports:


GHI Electronics, LLC
NETMF SDK for NETMF v4.1


SDK Version 1.0.11
October 15, 2010

I think firmware and SDK are correct. Aren’t they?


#5

SDK and firmware are matching.

See what your final full file path looks like.

Do:

Debug.Print(rootDirectory + @ "\records.txt");

Does the file exists on the card?
Have you tried different card?


#6
Debug.Print(rootDirectory + @ "\records.txt");

returns \SD\records.txt

The file exists on the card and the card can be read by the OS.

I did not try different cards. I’m going to search for other SDs…


#7

Kingston 2 Gb: does not work
Verbatim 2 Gb: does not work
Sandisk 4 Gb: does not work

It’s not an SD problem. I think it’s a Rhino problem. :’(


#8

What is the exception message you are getting?
Maybe you need to try to list files first? Take a look at the example in the PersistentStorage library documentation.


#9

Try to put Thread.Sleep :


...
mSD.MountFileSystem();
Thread.Sleep(100);
...

See following thread:
http://www.tinyclr.com/forum/6/2644/#/1/msg26107


#10

The exception is:

Exception System.NotSupportedException - CLR_E_NOT_SUPPORTED (1)

I’m going to look at the example.


#11
 
...
mSD.MountFileSystem();
Thread.Sleep(100);
...
 

Same error.


#12

@ Joe. In his first post in the image it shows that exception is thrown from

Microsoft.SPOT.IO.NativeIO::GetAttributes

May be this will provide you a hint on a possible cause of that.


#13

Could the complete debug window be useful?

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

'Microsoft.SPOT.Debugger.CorDebug.dll' (Gestito): caricato 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.1\Assemblies\le\mscorlib.dll', simboli caricati.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Gestito): caricato 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.1\Assemblies\le\Microsoft.SPOT.Native.dll', simboli caricati.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Gestito): caricato 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.1\Assemblies\le\Microsoft.SPOT.Hardware.dll', simboli caricati.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Gestito): caricato 'C:\Program Files (x86)\GHI Electronics\GHI NETMF v4.1 SDK\Assemblies\le\GHIElectronics.NETMF.System.dll'
'Microsoft.SPOT.Debugger.CorDebug.dll' (Gestito): caricato 'C:\Program Files (x86)\GHI Electronics\GHI NETMF v4.1 SDK\Assemblies\le\GHIElectronics.NETMF.IO.dll'
'Microsoft.SPOT.Debugger.CorDebug.dll' (Gestito): caricato 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.1\Assemblies\le\Microsoft.SPOT.IO.dll', simboli caricati.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Gestito): caricato 'C:\Program Files (x86)\Microsoft .NET Micro Framework\v4.1\Assemblies\le\System.IO.dll', simboli caricati.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Gestito): caricato 'J:\Dev\c#\TestStorage\TestStorageRhino\TestStorageRhino\bin\Debug\le\TestStorageRhino.exe', simboli caricati.
'Microsoft.SPOT.Debugger.CorDebug.dll' (Gestito): caricato 'C:\Program Files (x86)\GHI Electronics\GHI NETMF v4.1 SDK\Assemblies\le\FEZRhino_GHIElectronics.NETMF.FEZ.dll'
Il thread '<Nessun nome>' (0x2) è terminato con il codice 0 (0x0).
\SD\records.txt
    #### Exception System.NotSupportedException - CLR_E_NOT_SUPPORTED (1) ####
    #### Message: 
    #### Microsoft.SPOT.IO.NativeIO::GetAttributes [IP: 0000] ####
    #### System.IO.FileStream::.ctor [IP: 005c] ####
    #### System.IO.FileStream::.ctor [IP: 0009] ####
    #### FEZ_Rhino_Application1.Program::Main [IP: 0033] ####
Eccezione first-chance di tipo 'System.NotSupportedException' in Microsoft.SPOT.IO.dll
Eccezione first-chance di tipo 'System.NotSupportedException' in System.IO.dll
Eccezione non gestita di tipo 'System.NotSupportedException' in System.IO.dll

 Uncaught exception 
Il thread '<Nessun nome>' (0x1) è terminato con il codice 0 (0x0).


#14

Unfortunately a part of the debug window is in italian. Let me know if you need a translation…


#15

This is the debug window result when using the file listing example found in the documentation.

Storage “\SD” is inserted.
Getting files and folders:
Storage is not formatted. Format on PC with FAT32/FAT16 first.
Storage “\SD” is ejected.

Is there something special I have to do to format the card? I’m using Vista x64 OS; I right click on the SD and select format. I try to format again one of the SD and I got the same error (Storage is not formatted).


#16

Can you please upload screen shot of the format dialog settings that you are using?


#17

Format options attached.

Second combo means: default
Third combo means: device default

Thank you in advance to all for your help.


#18

If it can be useful, the USB file listing example is working fine.


#19

Try “Quick Format” with

“File system” -FAT32
"Allocation unit size" - 1024 bytes.


#20

Listing file example gave the same:

Storage “\SD” is inserted.
Getting files and folders:
Storage is not formatted. Format on PC with FAT32/FAT16 first.
Storage “\SD” is ejected.

Reading file:

Exception System.NotSupportedException - CLR_E_NOT_SUPPORTED (1)

:’(